code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
/*:ja
 * @target MZ
 * @author ル
 *
 * @command showAvTree
 * @text AVツリー画面
 * @des AVツリー画面
 * @arg actorId
 * @type number
 *
 *
 */
var Nore;
(function (Nore) {
  var pluginName = "Nore_AvTree";
  PluginManager.registerCommand(pluginName, "showAvTree", function (args) {
    var actorId = Math.trunc(args.actorId);
    $gameParty.setMenuActorId(actorId);
    SceneManager.push(Scene_AvTree);
  });
})(Nore || (Nore = {}));
var SARASHIMONO_SW = 346;
var SYUSAN_AV_SKIP_SW = 21;
var Scene_AvTree = /** @class */ (function (_super) {
  __extends(Scene_AvTree, _super);
  function Scene_AvTree() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  Scene_AvTree.prototype.startInitialScenario = function () {
    if ($gameSwitches.value(208)) {
      return;
    }
    $gameSwitches.setValue(208, true);
    this._avTreeWindow.deactivate();
    this.playScenario("AVツリー説明_01");
  };
  Scene_AvTree.prototype.finishScenario = function () {
    this._avTreeWindow.activate();
  };
  Scene_AvTree.prototype.create = function () {
    this._backlogDisabled = true;
    this._actor = $gameParty.menuActor();
    $gameTemp.avActorId = this._actor.actorId();
    _super.prototype.create.call(this);
    this.createDark();
    this.createTachieSprite();
    this.createAvTreeWindow();
    this.createWindowLayer();
    this.createAllWindows();
    this.createLabelWindow();
    this.createConfirmWindow();
    this.createConfirm3Window();
    this.createMsgWindow();
    this.checkNinshin();
  };
  Scene_AvTree.prototype.createTachieSprite = function () {
    this._tachie = new Sprite_Tachie();
    this.addChild(this._tachie);
    this._tachie.setActorId($gameParty.menuActor().actorId());
  };
  Scene_AvTree.prototype.start = function () {
    _super.prototype.start.call(this);
    this._avTreeWindow.start();
    this.startInitialScenario();
  };
  Scene_AvTree.prototype.checkNinshin = function () {
    this._isNinshin = this._actor.isNinshin();
    this.showNinshinLabel();
  };
  Scene_AvTree.prototype.createLabelWindow = function () {
    this._label = new Window_Label(100, 90);
    this._label.x = 30;
    this._label.y = 20;
    this._avTreeWindow.addChild(this._label);
    this.updateLabelDefaultText();
  };
  Scene_AvTree.prototype.createDark = function () {
    var dark = new PIXI.Graphics();
    dark.beginFill(0, 0.8);
    dark.drawRect(0, 0, Graphics.boxWidth + 10, Graphics.boxHeight + 10);
    dark.endFill();
    this.addChild(dark);
  };
  Scene_AvTree.prototype.createAvTreeWindow = function () {
    this._avTreeWindow = new Window_AvTree(this._actor);
    this.addChild(this._avTreeWindow);
    this._avTreeWindow.setHandler("ok", this.onOk.bind(this));
    this._avTreeWindow.setHandler("cancel", this.onCancel.bind(this));
    this._avTreeWindow.setHandler("change", this.onChange.bind(this));
  };
  Scene_AvTree.prototype.createConfirmWindow = function () {
    this._confirmWindow = new Nore.Window_Confirm(500);
    this._confirmWindow.setText(TextManager.confirmRecording);
    this.addChild(this._confirmWindow);
    this._confirmWindow.visible = false;
    this._confirmWindow.setHandler("ok", this.onConfirmOk.bind(this));
    this._confirmWindow.setHandler("cancel", this.onConfirmCancel.bind(this));
  };
  Scene_AvTree.prototype.createConfirm3Window = function () {
    this._confirm3Window = new Nore.Window_Confirm3Buttons("Skip", 500);
    this._confirm3Window.setTexts([
      TextManager.confirmAvOk,
      TextManager.confirmAvSkip1,
      TextManager.confirmAvSkip2,
    ]);
    this.addChild(this._confirm3Window);
    this._confirm3Window.visible = false;
    this._confirm3Window.setHandler("ok", this.onConfirmOk.bind(this));
    this._confirm3Window.setHandler("cancel", this.onConfirmCancel.bind(this));
    this._confirm3Window.setHandler("center", this.onConfirmSkip.bind(this));
  };
  Scene_AvTree.prototype.onConfirmSkip = function () {
    var avItem = this._avTreeWindow.selectedAv();
    var last = $slg.avInfo().lastAv(avItem.itemId());
    var av = new Av(avItem.actorId(), avItem.itemId());
    av.setMainMan(last.mainManId());
    av.setSubMan1(last.subMan1Id());
    av.setSubMan2(last.subMan2Id());
    av.setAuto();
    $gameAvJacketList.clear();
    $slg.makeAv(av);
    $gameTemp.av = av;
    $gameParty.setMenuActorId(avItem.actorId());
    $gameSwitches.setValue(SYUSAN_AV_SKIP_SW, true);
    $gameVariables.setValue(Nore.VIDEO_ID_VAR, $gameTemp.av.itemId());
    SceneManager.popAllScene();
    AudioManager.playSe({
      name: "FCPC1_SE01_Select01",
      volume: 70,
      pitch: 120,
      pan: 0,
    });
  };
  Scene_AvTree.prototype.createMsgWindow = function () {
    this._msgWindow = new Nore.Window_Msg(140);
    this._msgWindow.setText("体験版ではこのAVを撮影できません");
    this.addChild(this._msgWindow);
    this._msgWindow.visible = false;
    this._msgWindow.setHandler("ok", this.onConfirmCancel.bind(this));
  };
  Scene_AvTree.prototype.updateLabelDefaultText = function () {
    if (this._actor.hpRate() < 1) {
      this._label.setText(TextManager.hpNg);
      this._label.show();
    } else {
      this._label.hide();
    }
  };
  Scene_AvTree.prototype.onChange = function () {
    this._tachie.setActorId($gameParty.menuActor().actorId());
    if (this._isNinshin) {
      this.showNinshinLabel();
      return;
    }
    this.updateLabelDefaultText();
    var av = this._avTreeWindow.selectedAv();
    if (!av) {
      return;
    }
    if (av.isCondition() && av.isConditionValid()) {
      return;
    }
    if (!av.switchOk()) {
      this._label.setText(av.description());
      this._label.show();
    }
    if (av.isCondition() && !av.isConditionValid()) {
      var desc = av.description();
      p(desc);
      this._label.setText(desc);
      this._label.show();
    }
    if (av.isHireNg()) {
      this._label.setText(TextManager.hireNg);
      this._label.show();
    }
  };
  Scene_AvTree.prototype.showNinshinLabel = function () {
    if (!this._isNinshin) {
      return;
    }
    this._label.setText("安定期になるまでは撮影できません");
    this._label.show();
  };
  Scene_AvTree.prototype.onOk = function () {
    var av = this._avTreeWindow.selectedAv();
    if (!av) {
      SoundManager.playBuzzer();
      this._avTreeWindow.activate();
      return;
    }
    if (this._actor.hpRate() < 1) {
      SoundManager.playBuzzer();
      this._avTreeWindow.activate();
      return;
    }
    if (av.type == AvItemType.center) {
      $gameTemp.lastSelectedEroStatusIndex = 0;
      SceneManager.push(Nore.Scene_EroStatus);
      return;
    }
    if (!this._avTreeWindow.isItemEnabled(av)) {
      SoundManager.playBuzzer();
      this._avTreeWindow.activate();
      return;
    }
    if (!$gameSystem.isTaikenbanOkAv(av.itemId())) {
      this._msgWindow.show();
      this._msgWindow.activate();
      return;
    }
    if (av.type == AvItemType.sarashi) {
      var avItem = this._avTreeWindow.selectedAv();
      SceneManager.popAllScene();
      var common = parseInt(avItem.item().meta["common"]);
      p("common" + common);
      $gameParty.addCommonEvent(common, -1);
      return;
    }
    var count = $slg.avInfo().countAv(av.itemId());
    if (count >= 1) {
      this._confirm3Window.visible = true;
      this._confirm3Window.select(0);
      this._confirm3Window.activate();
    } else {
      this._confirmWindow.visible = true;
      this._confirmWindow.select(0);
      this._confirmWindow.activate();
    }
  };
  Scene_AvTree.prototype.onCancel = function () {
    this.popScene();
  };
  Scene_AvTree.prototype.onConfirmOk = function () {
    $gameSwitches.setValue(SYUSAN_AV_SKIP_SW, false);
    var avItem = this._avTreeWindow.selectedAv();
    if (avItem.isSarashimono()) {
      SceneManager.popAllScene();
      var common = parseInt(avItem.item().meta["common"]);
      p("common" + common);
      $gameParty.addCommonEvent(common, -1);
      return;
    }
    var av = new Av(avItem.actorId(), avItem.itemId());
    $gameTemp.av = av;
    $gameParty.setMenuActorId(avItem.actorId());
    SceneManager.push(Nore.Scene_Av);
  };
  Scene_AvTree.prototype.onConfirmCancel = function () {
    this._confirmWindow.visible = false;
    this._confirm3Window.visible = false;
    this._msgWindow.visible = false;
    this._avTreeWindow.activate();
  };
  return Scene_AvTree;
})(Nore.Scene_Talk);
var Window_Label = /** @class */ (function (_super) {
  __extends(Window_Label, _super);
  function Window_Label(x, y, width) {
    if (width === void 0) {
      width = 600;
    }
    var _this = _super.call(this, new Rectangle(x, y, width, 60)) || this;
    _this.backOpacity = 0;
    return _this;
  }
  Window_Label.prototype._createFrameSprite = function () {
    this._frameSprite = new Sprite();
  };
  Window_Label.prototype._refreshFrame = function () {};
  Window_Label.prototype.setText = function (text) {
    this.contents.textColor = ColorManager.deathColor();
    this.contents.clear();
    this.drawText(text, 0, 0, this.width, "left");
  };
  return Window_Label;
})(Window_Base);
var SENRI_AV;
var NONOKA_AV;
var MARINA_AV;
var SAKI_AV;
var MIYU_AV;
var KANAMI_AV;
var KOKONA_AV;
var AV_ITEM_Y = 1000;
var Window_AvTree = /** @class */ (function (_super) {
  __extends(Window_AvTree, _super);
  function Window_AvTree(actor) {
    var _this = this;
    var r = new Rectangle(80, 40, 890, 700);
    _this = _super.call(this, r) || this;
    _this._actor = actor;
    ImageManager.loadSystem("tree");
    return _this;
  }
  Window_AvTree.prototype.start = function () {
    this.makeItems();
    this.refresh();
    this.selectInitialAv();
    this.activate();
  };
  Window_AvTree.prototype.itemRect = function (index) {
    var rect = _super.prototype.itemRect.call(this, index);
    rect.width = 188;
    rect.x += 65;
    rect.y += 90;
    return rect;
  };
  Window_AvTree.prototype.itemWidth = function () {
    return 202;
  };
  Window_AvTree.prototype.refresh = function () {
    this._windowContentsBackSprite.removeChildren();
    this._windowContentsBackSprite2.removeChildren();
    this._windowContentsSprite.removeChildren();
    _super.prototype.refresh.call(this);
    //this.addDark();
  };
  Window_AvTree.prototype.addDark = function () {
    if (this._actor.isBote()) {
      var dark = new PIXI.Graphics();
      dark.beginFill(0x111111, 0.4);
      var offset = 0;
      if (this._actor.actorId() == 13 || this._actor.actorId() == 17) {
        offset = -100;
      }
      dark.drawRect(this._ninshinX + 10, 0, 610 + offset, 700);
      dark.endFill();
      this.addChild(dark);
      dark.y = 0;
      dark.x = 0;
      this._windowContentsSprite.addChild(dark);
    } else {
      var dark = new PIXI.Graphics();
      dark.beginFill(0x111111, 0.4);
      var offset = 0;
      if (this._actor.actorId() == 13 || this._actor.actorId() == 17) {
        offset = -100;
      }
      dark.drawRect(this._ninshinX + 610 + offset, 0, 610, 700);
      dark.endFill();
      this.addChild(dark);
      dark.y = 0;
      dark.x = 0;
      this._windowContentsSprite.addChild(dark);
    }
  };
  Window_AvTree.prototype.selectInitialAv = function () {
    if ($gameTemp.av) {
      var av = this.findAv($gameTemp.av.itemId());
      if (!av) {
        this.selectCenter();
        return;
      }
      var index = this.indexOf(av);
      if (index >= 0) {
        this.select(index);
      }
    } else {
      this.selectCenter();
    }
  };
  Window_AvTree.prototype.selectCenter = function () {
    var center = this.findType(AvItemType.center);
    var index = this.indexOf(center);
    if (index >= 0) {
      this.select(index);
    }
  };
  Window_AvTree.prototype.indexOf = function (av) {
    return av.y * this.maxCols() + av.x;
  };
  Window_AvTree.prototype.refreshCursor = function () {
    if (this._cursorAll) {
      this.refreshCursorForAll();
    } else if (this.index() >= 0) {
      var rect = this.itemRect(this.index());
      this.setCursorRect(
        rect.x - 5,
        rect.y - 5,
        rect.width - 9,
        rect.height - 14
      );
    } else {
      this.setCursorRect(0, 0, 0, 0);
    }
  };
  Window_AvTree.prototype.findType = function (type) {
    for (var key in this._avMap) {
      var av = this._avMap[key];
      if (av.type == type) {
        return av;
      }
    }
    return null;
  };
  Window_AvTree.prototype.findAv = function (itemId) {
    for (var key in this._avMap) {
      var av = this._avMap[key];
      if (av.itemId() == itemId) {
        return av;
      }
    }
    return null;
  };
  Window_AvTree.prototype.makeItems = function () {
    this._avMap = {};
    var list;
    switch (this._actor.actorId()) {
      case 4:
        list = MARINA_AV;
        break;
      case 8:
        list = SENRI_AV;
        break;
      case 9:
        list = NONOKA_AV;
        break;
      case 10:
        list = KANAMI_AV;
        break;
      case 11:
        list = MIYU_AV;
        break;
      case 13:
        list = SAKI_AV;
        break;
      case 17:
        list = KOKONA_AV;
        break;
    }
    this.checkFinished(list);
    for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
      var av = list_1[_i];
      if (!av.isVisible()) {
        continue;
      }
      this._avMap[this.createKey(av.x, av.y)] = av;
    }
  };
  Window_AvTree.prototype.checkFinished = function (list) {
    var avList = $slg.avInfo().actorAvList(this._actor.actorId());
    for (var _i = 0, list_2 = list; _i < list_2.length; _i++) {
      var avItem = list_2[_i];
      avItem.clear();
    }
    for (var _a = 0, list_3 = list; _a < list_3.length; _a++) {
      var avItem = list_3[_a];
      if (this.contains(avItem, avList)) {
        avItem.countUp();
      }
    }
  };
  Window_AvTree.prototype.contains = function (avItem, avList) {
    for (var _i = 0, avList_1 = avList; _i < avList_1.length; _i++) {
      var av = avList_1[_i];
      if (av.itemId() == avItem.itemId()) {
        return true;
      }
    }
    return false;
  };
  Window_AvTree.prototype.maxCols = function () {
    return 4;
  };
  Window_AvTree.prototype.itemHeight = function () {
    return 70;
  };
  Window_AvTree.prototype.maxItems = function () {
    if (!this._avMap) {
      return 0;
    }
    return this.maxY() * this.maxCols();
  };
  Window_AvTree.prototype.maxY = function () {
    var max = 0;
    for (var key in this._avMap) {
      var num = parseInt(key);
      var y = Math.round(num / AV_ITEM_Y);
      if (max < y) {
        max = y;
      }
    }
    return max + 1;
  };
  Window_AvTree.prototype.bgWidth = function () {
    return 166;
  };
  Window_AvTree.prototype.createKey = function (x, y) {
    return x + y * AV_ITEM_Y;
  };
  Window_AvTree.prototype.drawAllItems = function () {
    this.drawNinshinLine();
    this.drawAllLines();
    _super.prototype.drawAllItems.call(this);
  };
  Window_AvTree.prototype.drawNinshinLine = function () {
    this.contents.fontSize = 22;
    var normalX = 214;
    if (this._actor.actorId() == 13 || this._actor.actorId() == 17) {
      normalX += 100;
    }
    this._ninshinX = normalX;
    var g = new PIXI.Graphics();
    //g.beginFill(0x2189ff, 1);
    g.beginFill(0xcf54b6, 0.3);
    var hh = 756;
    g.drawRect(0, 0, 768, 700);
    g.endFill();
    g.x = 660;
    g.y = 0;
    this._windowContentsBackSprite2.addChild(g);
    //this.contents.fillRect(602 + 57, 0, 768, 700, '#cf54b64b');
    var rect = new Rectangle(48 * 2, 48 * 7, 60, 48);
    if (ConfigManager.language == "en") {
      rect = new Rectangle(0, 48 * 11, 140, 48);
    }
    var sprite = this.getSprite(rect.x, rect.y, rect.width, rect.height);
    sprite.x = 730;
    sprite.y = 4;
    if (ConfigManager.language == "en") {
      sprite.x = 700;
      sprite.y = 14;
    }
    this._windowContentsBackSprite.addChild(sprite);
    //this.drawText(TextManager.childbirth, 740, 4, 100);
  };
  Window_AvTree.prototype.getSprite = function (x, y, w, h) {
    var baseTexture = Nore.getSystemBaseTexture("tree");
    var r = new Rectangle(x, y, w, h);
    var texture = new PIXI.Texture(baseTexture, r);
    var s = new PIXI.Sprite(texture);
    return s;
  };
  Window_AvTree.prototype.drawItemBackground = function (index) {};
  Window_AvTree.prototype.isCurrentItemEnabled = function () {
    var av = this.selectedAv();
    if (!av) {
      return false;
    }
    if (av.type == AvItemType.center) {
      return true;
    }
    return this.isItemEnabled(av);
  };
  Window_AvTree.prototype.drawAvBg = function (av, rect) {
    if (av.type == AvItemType.center) {
      this.drawCenter(av, rect);
    } else if (av.isCondition()) {
      this.drawCondition(av, rect);
    } else {
      this.drawNormalAv(av, rect);
    }
  };
  Window_AvTree.prototype.drawCenter = function (av, rect) {
    var sprite = this.getSprite(0, 0, 172, 48);
    sprite.x = rect.x;
    sprite.y = rect.y;
    this._windowContentsBackSprite.addChild(sprite);
    this.contents.fontSize = 16;
    this.drawIcon(av.iconIndex(), rect.x + 9, rect.y + 7);
    this.drawText(av.name(), rect.x + 44, rect.y + 6, 120);
  };
  Window_AvTree.prototype.drawCondition = function (av, rect) {
    var sprite;
    var disabled = false;
    if (av.canSelect(this._avMap) && av.isConditionValid()) {
      sprite = this.getSprite(0, 48 * 4, 172, 48);
    } else {
      sprite = this.getSprite(0, 48 * 5, 172, 48);
      if (!this.isSelectableCondition(av)) {
        sprite.alpha = 0.5;
        disabled = true;
      }
    }
    sprite.x = rect.x;
    sprite.y = rect.y;
    this._windowContentsBackSprite.addChild(sprite);
    var name = av.name();
    if (av.isMask(this._avMap)) {
      var mask = "";
      for (var i = 0; i < name.length; i++) {
        mask += "?";
      }
      name = mask;
    }
    this.contents.fontSize = 14;
    this.changePaintOpacity(!disabled);
    this.drawIcon(av.iconIndex(), rect.x + 9, rect.y + 7);
    this.drawText(name, rect.x + 44, rect.y + 6, 120);
    this.changePaintOpacity(true);
  };
  Window_AvTree.prototype.isSelectableCondition = function (av) {
    var before = av.searchBeforeAv(this._avMap);
    if (before.isAv()) {
      var count = $slg.avInfo().countAv(before.itemId());
      if (count > 0) {
        return true;
      }
    } else if (before.isCondition()) {
      return before.isConditionValid();
    } else if (before.isCenter()) {
      return true;
    }
    return false;
  };
  Window_AvTree.prototype.drawNormalAv = function (av, rect) {
    var enabled = this.isItemEnabled(av);
    this.drawNormalAvBg(av, rect);
    this.drawPhoto(av, rect, enabled);
    this.drawNormalAvName(av, rect, enabled);
    this.drawBoteOk(av, rect, enabled);
  };
  Window_AvTree.prototype.drawNormalAvBg = function (av, rect) {
    var sprite;
    if (!this.isItemEnabled(av)) {
      sprite = this.getSprite(0, 48 * 3, 172, 48);
    } else if (av.isSarashimono()) {
      sprite = this.getSprite(0, 48 * 6, 172, 48);
      this.drawIcon(av.iconIndex(), rect.x + 9, rect.y + 7);
    } else if (av.isFinished(this._avMap)) {
      sprite = this.getSprite(0, 48 * 2, 172, 48);
      //sprite = this.getSprite(0, 48 * 1, 172, 48);
    } else {
      sprite = this.getSprite(0, 48 * 1, 172, 48);
      //sprite = this.getSprite(0, 48 * 2, 172, 48);
    }
    sprite.x = rect.x;
    sprite.y = rect.y;
    this._windowContentsBackSprite.addChild(sprite);
  };
  Window_AvTree.prototype.drawNormalAvName = function (av, rect, enabled) {
    this.contents.fontSize = 14;
    //this.drawIcon(av.iconIndex(), rect.x + 9, rect.y + 5);
    var name = av.name();
    if (av.isMask(this._avMap)) {
      var mask = "";
      for (var i = 0; i < name.length; i++) {
        mask += "?";
      }
      name = mask;
    }
    this.changePaintOpacity(enabled && this.isItemEnabled(av));
    if (av.isSarashimono()) {
      this.drawText(name, rect.x + 25 + 20, rect.y + 6, 121, "center");
    } else {
      this.drawText(name, rect.x + 50 + 20, rect.y + 6, 96, "center");
    }
    this.drawCount(av, rect);
    this.changePaintOpacity(true);
  };
  Window_AvTree.prototype.drawCount = function (av, rect) {
    var count = $slg.avInfo().countAv(av.itemId());
    if (count > 0) {
      this.contents.fontSize = 12;
      if (av.isOnce()) {
        this.drawText(TextManager.once, rect.x, rect.y - 24, 84);
      } else {
        this.drawText(
          TextManager.recordingCount.format(count),
          rect.x,
          rect.y - 24,
          84
        );
      }
    }
  };
  Window_AvTree.prototype.drawPhoto = function (av, rect, enabled) {
    var count = $slg.avInfo().countAv(av.itemId());
    if (!$gameSystem.isTaikenbanOkAv(av.itemId())) {
      return;
    }
    if (count > 0) {
      var lastAv = $slg.avInfo().lastAv(av.itemId());
      var ss = lastAv.screenShot();
      if (ss) {
        var sprite = new Sprite_AvScreenShot(ss, false);
        sprite.x = rect.x + 16;
        sprite.y = rect.y + 16;
        sprite.scale.x = 0.44;
        sprite.scale.y = 0.44;
        this._windowContentsSprite.addChild(sprite);
        if (!this.isItemEnabled(av)) {
          var g = new PIXI.Graphics();
          g.beginFill(0.0, 0.5);
          g.drawRect(0, 0, 66, 41);
          g.endFill();
          g.x = sprite.x;
          g.y = sprite.y;
          this._windowContentsSprite.addChild(g);
        }
      }
      return;
    }
    if (!av.canSelect(this._avMap)) {
      return;
    }
    if (av.isSarashimono()) {
      return;
    }
    if (count == 0) {
      var sprite = this.getSprite(0, 48 * 7, 63, 40);
      sprite.x = rect.x + 4;
      sprite.y = rect.y + 4;
      this._windowContentsBackSprite.addChild(sprite);
    }
  };
  Window_AvTree.prototype.isItemEnabled = function (av) {
    if (av.isCondition()) {
      return false;
    }
    if (av.count() > 0 && av.isOnce()) {
      return false;
    }
    if (!av.boteAndNotBote()) {
      if (av.isBote() && this._actor.boteId == 0) {
        return false;
      }
      if (!av.isBote() && this._actor.boteId >= 1) {
        return false;
      }
    }
    return av.canSelect(this._avMap);
  };
  Window_AvTree.prototype.drawAllLines = function () {
    var topIndex = this.topIndex();
    for (var i = 0; i < this.maxVisibleItems(); i++) {
      var index = topIndex + i;
      if (index < this.maxItems()) {
        this.drawLineItem(index);
      }
    }
  };
  Window_AvTree.prototype.drawLineItem = function (index) {
    var key = this.createKey(
      index % this.maxCols(),
      Math.floor(index / this.maxCols())
    );
    var av = this._avMap[key];
    if (!av) {
      return;
    }
    if (!av.isVisible()) {
      return;
    }
    var rect = this.itemRect(index);
    this.drawAvLine(av, rect);
  };
  Window_AvTree.prototype.drawItem = function (index) {
    var rect = this.itemRect(index);
    var key = this.createKey(
      index % this.maxCols(),
      Math.floor(index / this.maxCols())
    );
    var av = this._avMap[key];
    if (!av) {
      return;
    }
    if (!av.isVisible()) {
      return;
    }
    rect.x -= 1;
    rect.y -= 3;
    this.drawAvBg(av, rect);
    this.drawAvCondition(av, rect);
    this.drawTaikenban(av, rect);
  };
  Window_AvTree.prototype.drawBoteOk = function (av, rect, enabled) {
    if (!av.isSyusan()) {
      if (!av.boteAndNotBote()) {
        return;
      }
    }
    this.changePaintOpacity(enabled);
    this.drawIcon(Icon.bote, rect.x + 130, rect.y - 20);
    this.changePaintOpacity(true);
  };
  Window_AvTree.prototype.drawTaikenban = function (av, rect) {
    if (!av.isAv()) {
      return;
    }
    if ($gameSystem.isTaikenbanOkAv(av.itemId())) {
      return;
    }
    this.contents.fillRect(
      rect.x,
      rect.y,
      rect.width - 20,
      rect.height - 24,
      "#111111AA"
    );
    this.contents.fontSize = 14;
    this.drawText(TextManager.taikenbanNg, rect.x, rect.y - 20, rect.width);
  };
  Window_AvTree.prototype.drawAvCondition = function (av, rect) {
    var condition = av.condition();
    if (!condition) {
      return;
    }
    var iconIndex = condition.iconIndex();
    this.drawIcon(iconIndex, rect.x, rect.y - 26);
    if (condition.type == AvConditionType.dousei) {
      this.drawText(condition.text(), rect.x + 14, rect.y - 26, 144);
    }
    if (condition.type == AvConditionType.av) {
      var actorId = av.actorId();
      var actor = $gameActors.actor(actorId);
      var value = actor.countAv(AvEroType.number);
      //value *= AV_SALES_RATE;
      this.drawText(value + "本", rect.x + 14, rect.y - 26, 144);
    }
  };
  Window_AvTree.prototype.drawAvLine = function (av, rect) {
    switch (av.direction) {
      case AvItemDirection.left:
        this.drawLineLeft(rect);
        break;
      case AvItemDirection.leftBottom:
        this.drawLineLeftBottom(rect);
        break;
      case AvItemDirection.top:
        this.drawLineTop(rect);
        break;
      case AvItemDirection.bottom:
        this.drawLineBottom(rect);
        break;
      case AvItemDirection.right:
        this.drawLineRight(rect);
        break;
      case AvItemDirection.rightTop:
        this.drawLineRightTop(rect);
        break;
      case AvItemDirection.leftTop:
        this.drawLineLeftTop(rect);
        break;
      case AvItemDirection.rightBottom:
        this.drawLineRightBottom(rect);
        break;
    }
  };
  Window_AvTree.prototype.drawLineLeft = function (rect) {
    var s = this.getSprite(48, 48 * 8, 40, 10);
    s.x = rect.x - 35;
    s.y = rect.y + 18;
    this._windowContentsBackSprite2.addChild(s);
    //this.contents.fillRect(rect.x - 48, rect.y + 15, 68, 8, '#bbbbbb');
  };
  Window_AvTree.prototype.drawLineLeftBottom = function (rect) {
    this.contents.fillRect(rect.x - 130, rect.y + 15, 168, 8, "#bbbbbb");
    this.contents.fillRect(rect.x - 130, rect.y + 22, 8, 58, "#bbbbbb");
  };
  Window_AvTree.prototype.drawLineRight = function (rect) {
    var s = this.getSprite(48, 48 * 8, 40, 10);
    s.x = rect.x + 167;
    s.y = rect.y + 18;
    this._windowContentsBackSprite2.addChild(s);
    //this.contents.fillRect(rect.x + 140, rect.y + 15, 88, 8, '#bbbbbb');
  };
  Window_AvTree.prototype.drawLineTop = function (rect) {
    var s = this.getSprite(0, 48 * 8, 10, 40);
    s.x = rect.x + 85;
    s.y = rect.y - 28;
    this._windowContentsBackSprite2.addChild(s);
    //this.contents.fillRect(rect.x + 70, rect.y - 27, 8, 28, '#bbbbbb');
  };
  Window_AvTree.prototype.drawLineBottom = function (rect) {
    var s = this.getSprite(0, 48 * 8, 10, 40);
    s.x = rect.x + 85;
    s.y = rect.y + 41;
    this._windowContentsBackSprite2.addChild(s);
    //this.contents.fillRect(rect.x + 70, rect.y + 42, 8, 28, '#bbbbbb');
  };
  Window_AvTree.prototype.drawLineRightTop = function (rect) {
    // right
    this.contents.fillRect(rect.x + 140, rect.y + 15, 52, 8, "#bbbbbb");
    // top
    this.contents.fillRect(rect.x + 190, rect.y - 47, 8, 70, "#bbbbbb");
  };
  Window_AvTree.prototype.drawLineLeftTop = function (rect) {
    // left
    this.contents.fillRect(rect.x - 14, rect.y + 15, 34, 8, "#bbbbbb");
    // top
    this.contents.fillRect(rect.x - 16, rect.y - 47, 8, 70, "#bbbbbb");
  };
  Window_AvTree.prototype.drawLineRightBottom = function (rect) {
    // right
    this.contents.fillRect(rect.x + 140, rect.y + 15, 52, 8, "#bbbbbb");
    // bottom
    this.contents.fillRect(rect.x + 190, rect.y + 15, 8, 70, "#bbbbbb");
  };
  Window_AvTree.prototype.selectedAv = function () {
    var index = this.index();
    var key = this.createKey(
      index % this.maxCols(),
      Math.floor(index / this.maxCols())
    );
    var av = this._avMap[key];
    return av;
  };
  Window_AvTree.prototype.destroy = function () {
    this._windowContentsSprite.removeChildren();
    _super.prototype.destroy.call(this);
  };
  Window_AvTree.prototype.update = function () {
    _super.prototype.update.call(this);
    this.updateWheel();
    this.updateKey();
  };
  Window_AvTree.prototype.updateWheel = function () {
    if (TouchInput.wheelY > 0) {
      this.nextActor();
    } else if (TouchInput.wheelY < 0) {
      this.previousActor();
    }
  };
  Window_AvTree.prototype.updateKey = function () {
    if (Input.isTriggered("pageup")) {
      this.nextActor();
    } else if (Input.isTriggered("pagedown")) {
      this.previousActor();
    }
  };
  Window_AvTree.prototype.nextActor = function () {
    SoundManager.playCursor();
    $gameParty.makeMenuActorNext();
    this._actor = $gameParty.menuActor();
    this.makeItems();
    this.refresh();
    this.callHandler("change");
  };
  Window_AvTree.prototype.previousActor = function () {
    SoundManager.playCursor();
    $gameParty.makeMenuActorPrevious();
    this._actor = $gameParty.menuActor();
    this.makeItems();
    this.refresh();
    this.callHandler("change");
  };
  return Window_AvTree;
})(Window_Selectable);
var AvItemType;
(function (AvItemType) {
  AvItemType["center"] = "center";
  AvItemType["shojo"] = "shojo";
  AvItemType["sex"] = "sex";
  AvItemType["ninshin"] = "ninshin";
  AvItemType["notNinshin"] = "notNinshin";
  AvItemType["dousei"] = "dousei";
  AvItemType["sw"] = "sw";
  AvItemType["man"] = "man";
  AvItemType["acce"] = "acce";
  AvItemType["sarashi"] = "sarashi";
  AvItemType["av"] = "av";
  AvItemType["facility"] = "facility";
})(AvItemType || (AvItemType = {}));
var AvConditionType;
(function (AvConditionType) {
  AvConditionType["friendship"] = "friendship";
  AvConditionType["fukuju"] = "fukuju";
  AvConditionType["ninshin"] = "ninshin";
  AvConditionType["dousei"] = "dousei";
  AvConditionType["sw"] = "sw";
  AvConditionType["acce"] = "acce";
  AvConditionType["av"] = "av";
})(AvConditionType || (AvConditionType = {}));
var AvCondition = /** @class */ (function () {
  function AvCondition(type, value1, value2) {
    this.type = type;
    this._value1 = value1;
    this._value2 = value2;
  }
  AvCondition.prototype.iconIndex = function () {
    switch (this.type) {
      case AvConditionType.friendship:
        return 2209;
      case AvConditionType.fukuju:
        return 1952;
    }
    return 0;
  };
  AvCondition.prototype.value = function () {
    return this._value1;
  };
  AvCondition.prototype.value2 = function () {
    return this._value2;
  };
  AvCondition.prototype.text = function () {
    return this._value2 + "/" + this._value1;
  };
  return AvCondition;
})();
var DouseiAvCondition = /** @class */ (function (_super) {
  __extends(DouseiAvCondition, _super);
  function DouseiAvCondition(itemId, actorId) {
    var _this = _super.call(this, AvConditionType.dousei, 0, 0) || this;
    _this._itemId = itemId;
    _this._actorId = actorId;
    return _this;
  }
  DouseiAvCondition.prototype.playCount = function () {
    var item = $dataItems[this._itemId];
    var manId = Math.trunc(item.meta["dousei"]);
    var actor = $gameActors.actor(this._actorId);
    var dousei = actor.dousei();
    var playCount = dousei.history(manId).count(DouseiPlayId.sex);
    playCount += dousei.history(manId).count(DouseiPlayId.anal);
    playCount += dousei.history(manId).count(DouseiPlayId.chichi);
    playCount += dousei.history(manId).count(DouseiPlayId.fela);
    playCount += dousei.history(manId).count(DouseiPlayId.kunni);
    playCount += dousei.history(manId).count(DouseiPlayId.sm);
    return playCount;
  };
  DouseiAvCondition.prototype.text = function () {
    var item = $dataItems[this._itemId];
    var count = Math.trunc(item.meta["count"]);
    return this.playCount() + "/" + count;
  };
  DouseiAvCondition.prototype.value2 = function () {
    return this.playCount();
  };
  return DouseiAvCondition;
})(AvCondition);
var AvItem = /** @class */ (function () {
  function AvItem(x, y, type, itemId, dir) {
    if (dir === void 0) {
      dir = AvItemDirection.none;
    }
    this.x = x - 1;
    this.y = y;
    this.type = type;
    this._itemId = itemId;
    this.direction = dir;
    this.clear();
  }
  AvItem.prototype.countUp = function () {
    this._finished = true;
    this._count++;
  };
  AvItem.prototype.clear = function () {
    this._finished = false;
    this._count = 0;
  };
  AvItem.prototype.count = function () {
    return this._count;
  };
  AvItem.prototype.condition = function () {
    var item = this.item();
    if (item.meta["av"]) {
      var value = Math.trunc(item.meta["av"]);
      return new AvCondition(AvConditionType.av, value, 0);
    }
    if (item.meta["friendship"]) {
      var value = Math.trunc(item.meta["friendship"]);
      return new AvCondition(AvConditionType.friendship, value, 0);
    }
    if (item.meta["fukuju"]) {
      var value = Math.trunc(item.meta["fukuju"]);
      return new AvCondition(AvConditionType.fukuju, value, 0);
    }
    if (item.meta["manId"]) {
      var value = Math.trunc(item.meta["manId"]);
      return new AvCondition(AvConditionType.ninshin, value, 0);
    }
    if (item.meta["sw"]) {
      var value = Math.trunc(item.meta["sw"]);
      return new AvCondition(AvConditionType.sw, value, 0);
    }
    if (item.meta["dousei"]) {
      var actor = this.actor();
      return new DouseiAvCondition(item.id, actor.actorId());
    }
    return null;
  };
  AvItem.prototype.item = function () {
    return $dataItems[this._itemId];
  };
  AvItem.prototype.iconIndex = function () {
    var item = this.item();
    if (!item) {
      return 0;
    }
    if (this.isCondition()) {
      if (this.isConditionValid()) {
        return Icon.ok;
      } else {
        return Icon.lock;
      }
    }
    return item.iconIndex;
  };
  AvItem.prototype.name = function () {
    var item = this.item();
    if (!item) {
      return "";
    }
    switch (ConfigManager.language) {
      case "en":
        if (item.meta["nameEn"]) {
          return item.meta["nameEn"];
        }
        break;
      case "ch":
      case "jp":
        break;
    }
    return item.name;
  };
  AvItem.prototype.isOnce = function () {
    return this.item().meta["once"];
  };
  AvItem.prototype.isBote = function () {
    return this.item().meta["bote"];
  };
  AvItem.prototype.isSyusan = function () {
    return this.item().meta["syusan"];
  };
  AvItem.prototype.boteAndNotBote = function () {
    return this.item().meta["boteOk"];
  };
  AvItem.prototype.isAv = function () {
    switch (this.type) {
      case AvItemType.sex:
        return true;
    }
    return false;
  };
  AvItem.prototype.isCenter = function () {
    switch (this.type) {
      case AvItemType.center:
        return true;
    }
    return false;
  };
  AvItem.prototype.isCondition = function () {
    switch (this.type) {
      case AvItemType.sw:
        return true;
      case AvItemType.shojo:
        return true;
      case AvItemType.ninshin:
        return true;
      case AvItemType.notNinshin:
        return true;
      case AvItemType.dousei:
        return true;
      case AvItemType.man:
        return true;
      case AvItemType.acce:
        return true;
      case AvItemType.av:
        return true;
      case AvItemType.facility:
        return true;
    }
    return false;
  };
  AvItem.prototype.isFinished = function (map) {
    if (this.type == AvItemType.center) {
      return true;
    }
    var before = this.searchBeforeAv(map);
    if (before) {
      if (!before.isFinished(map)) {
        return false;
      }
    }
    if (
      this.type == AvItemType.ninshin ||
      this.type == AvItemType.dousei ||
      this.type == AvItemType.av
    ) {
      return this.isConditionValid();
    }
    if (this.type == AvItemType.sw) {
      return this.switchOk();
    }
    if (this.type == AvItemType.man) {
      return this.manOk();
    }
    if (this.type == AvItemType.acce) {
      return this.acceOk();
    }
    if (this.type == AvItemType.facility) {
      return this.facilityOk();
    }
    return this._finished;
  };
  AvItem.prototype.facilityOk = function () {
    return $slg.facilityInfo().hasFacility(this.facilityId());
  };
  AvItem.prototype.facilityId = function () {
    var acce1 = parseInt(this.item().meta["facility"]);
    if (acce1 > 0) {
      return acce1;
    }
    return -1;
  };
  AvItem.prototype.acceOk = function () {
    if (this.switchOk()) {
      return true;
    }
    var acce1 = this.acce1();
    var acce2 = this.acce2();
    var actorId = this.actorId();
    var actor = $gameActors.actor(actorId);
    if (actor.hasAcce(acce1)) {
      return true;
    }
    if (acce2 && actor.hasAcce(acce2)) {
      return true;
    }
    return false;
  };
  AvItem.prototype.acce1 = function () {
    var acce1 = parseInt(this.item().meta["acce1"]);
    if (acce1 > 0) {
      return acce1;
    }
    return -1;
  };
  AvItem.prototype.acce2 = function () {
    var acce2 = parseInt(this.item().meta["acce2"]);
    if (acce2 > 0) {
      return acce2;
    }
    return -1;
  };
  AvItem.prototype.canSelect = function (map) {
    var actor = $gameParty.menuActor();
    if (actor.isNinshin()) {
      return false;
    }
    if (this.isSyusan()) {
      if (this.isSyusanNg()) {
        return false;
      }
    }
    var before = this.searchBeforeAv(map);
    if (!before) {
      return true;
    }
    if (!before.isFinished(map)) {
      return false;
    }
    if (this.isCondition() && this.isConditionValid()) {
      return true;
    }
    if (!this.switchOk()) {
      return false;
    }
    if (this.type == AvItemType.sw) {
      return true;
    }
    if (this.isNotNinshin()) {
      if (this.actor().boteId != 0) {
        return false;
      }
    }
    return true;
  };
  AvItem.prototype.switchOk = function () {
    var sw = this.sw();
    if (sw > 0) {
      return $gameSwitches.value(sw);
    }
    return true;
  };
  AvItem.prototype.avOk = function () {
    var av = this.av();
    var actorId = this.actorId();
    var actor = $gameActors.actor(actorId);
    var value = actor.countAv(AvEroType.number);
    return av <= value;
  };
  AvItem.prototype.isSyusanNg = function () {
    return false;
  };
  AvItem.prototype.isHireNg = function () {
    if (this.type == AvItemType.man) {
      var man = parseInt(this.item().meta["man"]);
      return !$slg.manInfo().contains(man);
    }
    return false;
  };
  AvItem.prototype.isNotNinshin = function () {
    if (this.item().meta["notNinshin"]) {
      return true;
    } else {
      return false;
    }
  };
  AvItem.prototype.av = function () {
    var av = parseInt(this.item().meta["av"]);
    if (av > 0) {
      return av;
    }
    return -1;
  };
  AvItem.prototype.sw = function () {
    var sw = parseInt(this.item().meta["sw"]);
    if (sw > 0) {
      return sw;
    }
    return -1;
  };
  AvItem.prototype.searchBeforeAv = function (map) {
    var x = this.x;
    var y = this.y;
    switch (this.direction) {
      case AvItemDirection.top:
        y--;
        break;
      case AvItemDirection.bottom:
        y++;
        break;
      case AvItemDirection.left:
        x--;
        break;
      case AvItemDirection.leftTop:
        x--;
        y--;
        break;
      case AvItemDirection.leftBottom:
        x--;
        y++;
        break;
      case AvItemDirection.right:
        x++;
        break;
      case AvItemDirection.rightBottom:
        x++;
        y++;
        break;
      case AvItemDirection.rightTop:
        x++;
        y--;
        break;
    }
    for (var key in map) {
      var av = map[key];
      if (av.x == x && av.y == y) {
        return av;
      }
    }
    return null;
  };
  AvItem.prototype.isVisible = function () {
    var item = this.item();
    if (item.meta["stage"]) {
      var value = Math.trunc(item.meta["stage"]);
      return $slg.stage() >= value;
    }
    if (this.isSarashimono()) {
      var value = Math.trunc(item.meta["sw"]);
      if (!$gameSwitches.value(value)) {
        return false;
      }
    }
    return true;
  };
  AvItem.prototype.isSarashimono = function () {
    var item = this.item();
    if (item.meta["sarashi"]) {
      return true;
    }
    if (item.meta["av"]) {
      return true;
    }
    return false;
  };
  AvItem.prototype.actorId = function () {
    var item = this.item();
    if (item.meta["actorId"]) {
      var value = Math.trunc(item.meta["actorId"]);
      return value;
    }
    return -1;
  };
  AvItem.prototype.itemId = function () {
    return this._itemId;
  };
  AvItem.prototype.actor = function () {
    return $gameActors.actor(this.actorId());
  };
  AvItem.prototype.manOk = function () {
    var man = parseInt(this.item().meta["man"]);
    return $slg.manInfo().contains(man);
  };
  AvItem.prototype.isConditionValid = function () {
    if (this.type == AvItemType.av) {
      return this.avOk();
    }
    if (this.type == AvItemType.sw) {
      return this.switchOk();
    }
    if (this.type == AvItemType.man) {
      return this.manOk();
    }
    if (this.type == AvItemType.acce) {
      return this.acceOk();
    }
    if (this.type == AvItemType.facility) {
      return this.facilityOk();
    }
    var condition = this.condition();
    if (!condition) {
      return false;
    }
    if (condition.type == AvConditionType.ninshin) {
      var baby = this.actor().lastBaby();
      if (!baby) {
        return false;
      }
      if (baby.progress() != BabyProgress.bote) {
        return false;
      }
      if (condition.value() == 0) {
        return true;
      }
      if (condition.value() == baby.taneoyaId()) {
        return true;
      }
      return false;
    }
    if (condition.type == AvConditionType.dousei) {
      var count = parseInt(this.item().meta["count"]);
      /*if (this.actor().dousei().manId() != douseiManId) {
                return false;
            }*/
      return count <= condition.value2();
    }
    return false;
  };
  AvItem.prototype.description = function () {
    var sw = this.sw();
    if (sw > 0 || this.item().description.length > 0) {
      if (ConfigManager.language == "en") {
        if (this.item().meta["descEn"]) {
          return this.item().meta["descEn"];
        }
      }
      return this.item().description;
    }
    return "";
  };
  AvItem.prototype.isMask = function (map) {
    if (this.isCenter()) {
      return false;
    }
    if (this.count() > 0) {
      return false;
    }
    if (!this.isCondition() && !this.switchOk()) {
      return true;
    }
    if (this.isCondition() && this.isConditionValid()) {
      return false;
    }
    var avItem = this.searchBeforeAv(map);
    if (!avItem) {
      return false;
    }
    if (avItem.isCenter()) {
      if (this.item().meta["mask"]) {
        return true;
      }
      return false;
    }
    if (avItem.count() > 0) {
      return false;
    }
    if (avItem.isCondition() && avItem.isConditionValid()) {
      return false;
    }
    return true;
  };
  return AvItem;
})();
var AvItemDirection;
(function (AvItemDirection) {
  AvItemDirection["none"] = "none";
  AvItemDirection["top"] = "top";
  AvItemDirection["bottom"] = "bottom";
  AvItemDirection["left"] = "left";
  AvItemDirection["leftBottom"] = "leftBottom";
  AvItemDirection["leftTop"] = "leftTop";
  AvItemDirection["right"] = "right";
  AvItemDirection["rightTop"] = "rightTop";
  AvItemDirection["rightBottom"] = "rightBottom";
})(AvItemDirection || (AvItemDirection = {}));
var AvItemManager = /** @class */ (function () {
  function AvItemManager() {
    this.createSenri();
    this.createNonoka();
    this.createMarina();
    this.createMiyu();
    this.createSaki();
    this.createKokona();
    this.createKanami();
  }
  AvItemManager.prototype.createSenri = function () {
    SENRI_AV = [
      new AvItem(2, 3, AvItemType.center, 100),
      //new AvItem(3, 3, AvItemType.sex, 94, AvItemDirection.left), // くぱぁ
      //new AvItem(2, 3, AvItemType.shojo, 99, AvItemDirection.top),
      //new AvItem(3, 6, AvItemType.ninshin, 107, AvItemDirection.leftTop), //妊娠
      //new AvItem(4, 6, AvItemType.sex, 108, AvItemDirection.left), //汎用出産
      new AvItem(3, 5, AvItemType.ninshin, 96, AvItemDirection.left), //妊娠
      new AvItem(3, 1, AvItemType.ninshin, 98, AvItemDirection.left), //妊娠
      //new AvItem(2, 2, AvItemType.notNinshin, 97, AvItemDirection.bottom),
      new AvItem(2, 4, AvItemType.sex, 101, AvItemDirection.top), // 快楽
      new AvItem(2, 5, AvItemType.sex, 102, AvItemDirection.top), // ヨシオ本番
      new AvItem(4, 5, AvItemType.sex, 106, AvItemDirection.left), // ヨシオ出産
      //new AvItem(1, 5, AvItemType.sex, 105, AvItemDirection.right), // ヨシオ種付け
      new AvItem(1, 5, AvItemType.sex, 91, AvItemDirection.right), // ヨシオバック
      new AvItem(1, 6, AvItemType.sex, 90, AvItemDirection.top), // ヨシオバック
      new AvItem(2, 6, AvItemType.dousei, 88, AvItemDirection.left), // 同棲条件
      new AvItem(2, 7, AvItemType.sex, 87, AvItemDirection.top), // お風呂
      new AvItem(1, 7, AvItemType.sex, 89, AvItemDirection.right), // 同棲セックス
      //new AvItem(1, 4, AvItemType.sex, 103, AvItemDirection.bottom), // ヨシオアナル
      new AvItem(1, 3, AvItemType.sw, 92, AvItemDirection.right), // レン条件
      new AvItem(1, 2, AvItemType.sex, 201, AvItemDirection.bottom), // レン調教
      new AvItem(1, 1, AvItemType.sw, 93, AvItemDirection.bottom), // レンとマリナ
      new AvItem(2, 1, AvItemType.sex, 112, AvItemDirection.left), // レン本番
      new AvItem(2, 0, AvItemType.sex, 110, AvItemDirection.bottom), // レン本番2
      new AvItem(1, 0, AvItemType.sex, 113, AvItemDirection.right), // レン本番3
      new AvItem(4, 1, AvItemType.sex, 111, AvItemDirection.left), // レン出産
    ];
  };
  AvItemManager.prototype.createNonoka = function () {
    NONOKA_AV = [
      new AvItem(2, 4, AvItemType.center, 119),
      new AvItem(1, 4, AvItemType.av, 151, AvItemDirection.right), // AV販売
      new AvItem(1, 5, AvItemType.sarashi, 152, AvItemDirection.top), // さらしもの
      new AvItem(2, 5, AvItemType.sex, 121, AvItemDirection.top), // 快楽
      new AvItem(2, 6, AvItemType.sex, 122, AvItemDirection.top), // 処女喪失
      new AvItem(2, 7, AvItemType.sex, 129, AvItemDirection.top), // 睡眠姦
      //new AvItem(0, 7, AvItemType.sex, 125, AvItemDirection.right), // ボテ腹正常位
      new AvItem(1, 6, AvItemType.dousei, 145, AvItemDirection.right), // 同棲条件
      new AvItem(1, 7, AvItemType.sex, 146, AvItemDirection.top), // 同棲セックス
      new AvItem(3, 7, AvItemType.ninshin, 131, AvItemDirection.left), // 睡眠出産(条件)
      new AvItem(4, 7, AvItemType.sex, 133, AvItemDirection.left), // 睡眠出産
      new AvItem(3, 6, AvItemType.ninshin, 120, AvItemDirection.left),
      new AvItem(4, 6, AvItemType.sex, 124, AvItemDirection.left), // 毒島出産
      new AvItem(2, 3, AvItemType.sw, 127, AvItemDirection.bottom), // 学校(条件)
      new AvItem(2, 2, AvItemType.sw, 126, AvItemDirection.bottom), // 学校(条件)
      new AvItem(3, 3, AvItemType.ninshin, 131, AvItemDirection.left), // 学出産(条件)
      new AvItem(3, 3, AvItemType.sex, 128, AvItemDirection.left), // 学校騎乗位
      new AvItem(4, 3, AvItemType.sex, 132, AvItemDirection.left), // 学校騎乗位出産
      new AvItem(3, 2, AvItemType.sex, 130, AvItemDirection.bottom), // 部室バック
      new AvItem(3, 1, AvItemType.sex, 153, AvItemDirection.left), // 男優別
      new AvItem(1, 2, AvItemType.sex, 142, AvItemDirection.right), // 校門さらしもの
      new AvItem(3, 4, AvItemType.sw, 155, AvItemDirection.top), // レンの乳搾り
      new AvItem(3, 5, AvItemType.sex, 154, AvItemDirection.top), // レンの乳搾り
      //new AvItem(0, 2, AvItemType.sex, 143, AvItemDirection.right), // 校門さらしもの(ボテ)
      //new AvItem(3, 2, AvItemType.sex, 149, AvItemDirection.left), // 学校(未定)
      new AvItem(2, 1, AvItemType.sw, 136, AvItemDirection.bottom), // 公園
      new AvItem(1, 1, AvItemType.sex, 138, AvItemDirection.right), // 公衆便所 男性便器
      new AvItem(1, 0, AvItemType.sex, 137, AvItemDirection.bottom), // 公衆便所
      new AvItem(2, 0, AvItemType.sex, 140, AvItemDirection.left), // テント
      new AvItem(3, 0, AvItemType.ninshin, 131, AvItemDirection.left), // 出産(条件)
      new AvItem(4, 0, AvItemType.sex, 135, AvItemDirection.left), // 公衆便所 男性便器 出産
    ];
  };
  AvItemManager.prototype.createMarina = function () {
    MARINA_AV = [
      new AvItem(2, 5, AvItemType.center, 160),
      new AvItem(1, 5, AvItemType.av, 184, AvItemDirection.right), // AV販売
      new AvItem(1, 6, AvItemType.sarashi, 183, AvItemDirection.top), // さらしもの
      new AvItem(2, 6, AvItemType.sex, 161, AvItemDirection.top), // 近親相姦
      new AvItem(2, 7, AvItemType.sex, 162, AvItemDirection.top), // 近親種付け
      new AvItem(1, 7, AvItemType.sex, 163, AvItemDirection.right), // 騎乗位種付け
      new AvItem(2, 4, AvItemType.sex, 168, AvItemDirection.bottom), // タロウ
      new AvItem(1, 4, AvItemType.sw, 169, AvItemDirection.right), // 学校(条件)
      new AvItem(1, 3, AvItemType.sex, 170, AvItemDirection.bottom), // 学校タロウ
      new AvItem(1, 2, AvItemType.sex, 173, AvItemDirection.bottom), // 学校教え子
      new AvItem(2, 3, AvItemType.dousei, 171, AvItemDirection.bottom), //  同棲(条件)
      new AvItem(2, 2, AvItemType.sex, 172, AvItemDirection.bottom), //  同棲H
      new AvItem(3, 2, AvItemType.sex, 186, AvItemDirection.left), //  男優別
      new AvItem(2, 1, AvItemType.facility, 178, AvItemDirection.bottom), //  乳首ピアス(条件)
      new AvItem(3, 1, AvItemType.sex, 179, AvItemDirection.left), //  ピアスH
      new AvItem(3, 0, AvItemType.acce, 181, AvItemDirection.bottom), //  ラビアピアス(条件)
      new AvItem(2, 0, AvItemType.sex, 180, AvItemDirection.right), //  ピアスH
      new AvItem(1, 1, AvItemType.sex, 182, AvItemDirection.bottom), //  セーラー
      new AvItem(3, 4, AvItemType.ninshin, 175, AvItemDirection.left), // 妊娠
      new AvItem(4, 4, AvItemType.sex, 176, AvItemDirection.left), // 出産
      new AvItem(3, 6, AvItemType.ninshin, 164, AvItemDirection.left), // 妊娠(レン)
      new AvItem(4, 6, AvItemType.sex, 165, AvItemDirection.left), // レン出産
    ];
  };
  AvItemManager.prototype.createMiyu = function () {
    MIYU_AV = [
      new AvItem(2, 1, AvItemType.center, 220),
      new AvItem(2, 2, AvItemType.sex, 221, AvItemDirection.top), // 売春
      new AvItem(2, 4, AvItemType.sex, 222, AvItemDirection.top), // 売春2
      new AvItem(2, 5, AvItemType.sex, 223, AvItemDirection.top), // 売春3
      new AvItem(2, 3, AvItemType.man, 237, AvItemDirection.top), // デブオ出産(催眠術)
      new AvItem(3, 3, AvItemType.ninshin, 225, AvItemDirection.left), // デブオ出産(条件)
      new AvItem(3, 4, AvItemType.ninshin, 226, AvItemDirection.left), // クズオ出産(条件)
      new AvItem(3, 5, AvItemType.ninshin, 227, AvItemDirection.left), // ガリオ出産(条件)
      new AvItem(4, 3, AvItemType.sex, 233, AvItemDirection.left), // デブオ出産
      new AvItem(4, 4, AvItemType.sex, 234, AvItemDirection.left), // クズオ出産
      new AvItem(4, 5, AvItemType.sex, 235, AvItemDirection.left), // ガリオ出産
      new AvItem(1, 3, AvItemType.sex, 229, AvItemDirection.right), // 売春
      new AvItem(1, 4, AvItemType.sex, 230, AvItemDirection.right), // 売春
      new AvItem(1, 5, AvItemType.sex, 231, AvItemDirection.right), // 売春
    ];
  };
  AvItemManager.prototype.createKanami = function () {
    KANAMI_AV = [
      new AvItem(2, 3, AvItemType.center, 341),
      new AvItem(2, 4, AvItemType.man, 342, AvItemDirection.top), // 催眠条件
      new AvItem(2, 5, AvItemType.sex, 343, AvItemDirection.top), // 催眠
      new AvItem(2, 6, AvItemType.sex, 344, AvItemDirection.top), // 催眠2
      new AvItem(2, 7, AvItemType.sex, 345, AvItemDirection.top), // 催眠3
      new AvItem(3, 5, AvItemType.ninshin, 346, AvItemDirection.left), // 催眠出産条件
      new AvItem(4, 5, AvItemType.sex, 347, AvItemDirection.left), // 催眠出産
      new AvItem(1, 3, AvItemType.sw, 348, AvItemDirection.right), // 基地条件
      new AvItem(1, 2, AvItemType.sex, 349, AvItemDirection.bottom), // ユヅキ調教
      new AvItem(2, 2, AvItemType.sex, 350, AvItemDirection.left), // ユヅキSEX
      new AvItem(2, 1, AvItemType.sex, 351, AvItemDirection.bottom), // ユヅキSEX2
      new AvItem(2, 0, AvItemType.sex, 352, AvItemDirection.bottom), // ユヅキSEX3
      new AvItem(3, 2, AvItemType.ninshin, 354, AvItemDirection.left), // ユヅキ出産(条件)
      new AvItem(4, 2, AvItemType.sex, 355, AvItemDirection.left), // ユヅキ出産
      new AvItem(3, 1, AvItemType.ninshin, 354, AvItemDirection.left), // ユヅキ出産(条件)
      new AvItem(4, 1, AvItemType.sex, 356, AvItemDirection.left), // ユヅキ出産2
    ];
  };
  AvItemManager.prototype.createSaki = function () {
    SAKI_AV = [
      new AvItem(2, 1, AvItemType.center, 260),
      new AvItem(2, 0, AvItemType.av, 284, AvItemDirection.bottom), // AV
      new AvItem(1, 0, AvItemType.sarashi, 285, AvItemDirection.right), // さらしもの
      new AvItem(3, 1, AvItemType.sex, 261, AvItemDirection.left), // 処女喪失
      new AvItem(3, 0, AvItemType.ninshin, 265, AvItemDirection.bottom),
      new AvItem(4, 0, AvItemType.sex, 266, AvItemDirection.left), // 出産
      new AvItem(3, 2, AvItemType.sex, 273, AvItemDirection.top), // フェラ
      new AvItem(2, 2, AvItemType.sex, 267, AvItemDirection.right), // 制服
      new AvItem(1, 1, AvItemType.dousei, 269, AvItemDirection.right), // 同棲
      new AvItem(1, 2, AvItemType.sex, 262, AvItemDirection.top), // アナル調教
      new AvItem(1, 3, AvItemType.facility, 287, AvItemDirection.top), // ピアススタジオ
      new AvItem(1, 4, AvItemType.sex, 263, AvItemDirection.top), // スパンキング
      new AvItem(1, 5, AvItemType.dousei, 270, AvItemDirection.top), // 同棲
      new AvItem(1, 6, AvItemType.sex, 279, AvItemDirection.top), // 同棲セックス
      new AvItem(2, 4, AvItemType.sex, 264, AvItemDirection.left), // 吊るし
      new AvItem(2, 5, AvItemType.sw, 271, AvItemDirection.top), // 学校(条件)
      new AvItem(3, 5, AvItemType.sex, 288, AvItemDirection.left), //  男優別
      new AvItem(2, 6, AvItemType.sex, 272, AvItemDirection.top), // 学校H
      new AvItem(1, 7, AvItemType.sex, 280, AvItemDirection.top), // DVD販売
      new AvItem(3, 4, AvItemType.ninshin, 276, AvItemDirection.left),
      new AvItem(4, 4, AvItemType.sex, 277, AvItemDirection.left), // 出産
      new AvItem(2, 3, AvItemType.sex, 275, AvItemDirection.bottom), // スパンキング2
      new AvItem(3, 3, AvItemType.ninshin, 276, AvItemDirection.left),
      new AvItem(2, 7, AvItemType.sex, 281, AvItemDirection.top), // 騎乗位
      new AvItem(4, 3, AvItemType.sex, 282, AvItemDirection.left), // 出産
      new AvItem(3, 6, AvItemType.ninshin, 289, AvItemDirection.left),
      new AvItem(4, 6, AvItemType.sex, 290, AvItemDirection.left), // 出産
    ];
  };
  AvItemManager.prototype.createKokona = function () {
    KOKONA_AV = [
      new AvItem(2, 0, AvItemType.center, 301),
      new AvItem(1, 0, AvItemType.av, 317, AvItemDirection.right), // AV販売
      new AvItem(1, 1, AvItemType.sarashi, 318, AvItemDirection.top), // さらしもの
      new AvItem(2, 1, AvItemType.sex, 302, AvItemDirection.top), // 初H
      new AvItem(2, 2, AvItemType.sex, 303, AvItemDirection.top), // バック
      new AvItem(2, 3, AvItemType.sex, 304, AvItemDirection.top), // 公開種付け
      new AvItem(2, 4, AvItemType.sex, 310, AvItemDirection.top), // ちんぽ敗北
      new AvItem(1, 4, AvItemType.sex, 311, AvItemDirection.right), // アナル
      new AvItem(1, 5, AvItemType.sex, 312, AvItemDirection.top), // ヤリ部屋
      new AvItem(2, 5, AvItemType.sex, 313, AvItemDirection.top), // 浮浪者
      new AvItem(2, 6, AvItemType.sex, 314, AvItemDirection.top), // デカチン
      new AvItem(1, 3, AvItemType.sex, 319, AvItemDirection.right), // 男優別
      new AvItem(3, 1, AvItemType.ninshin, 305, AvItemDirection.left), // 妊娠(オリバー)
      new AvItem(4, 1, AvItemType.sex, 306, AvItemDirection.left), // オリバー出産
      new AvItem(3, 3, AvItemType.ninshin, 307, AvItemDirection.left), // 妊娠
      new AvItem(4, 3, AvItemType.sex, 308, AvItemDirection.left), // 出産
      new AvItem(3, 5, AvItemType.ninshin, 307, AvItemDirection.left), // 妊娠
      new AvItem(4, 5, AvItemType.sex, 315, AvItemDirection.left), // 出産
      new AvItem(3, 4, AvItemType.ninshin, 307, AvItemDirection.left), // 妊娠
      new AvItem(4, 4, AvItemType.sex, 321, AvItemDirection.left), // 出産
    ];
  };
  return AvItemManager;
})();
var Window_AvTreeDatail = /** @class */ (function (_super) {
  __extends(Window_AvTreeDatail, _super);
  function Window_AvTreeDatail() {
    return (_super !== null && _super.apply(this, arguments)) || this;
  }
  return Window_AvTreeDatail;
})(Window_Base);
var $avItemManager = new AvItemManager();


code:
/*:ja
 * @target MZ
 * @author ル
 *
 * @command showAv
 * @text AV画面
 * @des AV画面
 * @arg actorId
 * @type number
 * @arg avId
 * @type number
 *
 *
 */
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
var Nore;
(function (Nore) {
  var pluginName = "Nore_AvUi";
  PluginManager.registerCommand(pluginName, "showAv", function (args) {
    var avId = Math.trunc(args.avId);
    var actorId = Math.trunc(args.actorId);
    var av = new Av(actorId, avId);
    $gameTemp.av = av;
    SceneManager.push(Nore.Scene_Av);
  });
  var RIGHT_WINDOW_X = 696;
  var Scene_Av = /** @class */ (function (_super) {
    __extends(Scene_Av, _super);
    function Scene_Av() {
      return (_super !== null && _super.apply(this, arguments)) || this;
    }
    Scene_Av.prototype.create = function () {
      this._av = $gameTemp.av;
      _super.prototype.create.call(this);
      this.createAvWindow();
      this.createConfirmWindow();
    };
    Scene_Av.prototype.start = function () {
      _super.prototype.start.call(this);
      this.onAvChange();
    };
    Scene_Av.prototype.createBackground = function () {};
    Scene_Av.prototype.createAvWindow = function () {
      this._avWindow = new Window_Av(this._av);
      this.addChild(this._avWindow);
      this._avWindow.activate();
      this._avWindow.select(0);
      this._avWindow.setHandler("ok", this.onOk.bind(this));
      this._avWindow.setHandler("cancel", this.onCancel.bind(this));
      this._avWindow.setHandler("change", this.onAvChange.bind(this));
      this._paramWindow = new Window_AvParam(this._av);
      this.addChild(this._paramWindow);
      this._manWindow = new Window_AvMan(this._av, this._avWindow);
      this.addChild(this._manWindow);
      this._manWindow.setHandler("ok", this.onManOk.bind(this));
      this._manWindow.setHandler("cancel", this.onManCancel.bind(this));
      this._manWindow.setHandler("change", this.onManChange.bind(this));
      this._manWindow.hide();
      this._manParamWindow = new Window_AvManParams(this._av);
      this.addChild(this._manParamWindow);
      //this._manParamWindow.hide();
    };
    Scene_Av.prototype.createConfirmWindow = function () {
      this._confirmWindow = new Nore.Window_Confirm(500);
      this.addChild(this._confirmWindow);
      this._confirmWindow.visible = false;
      this._confirmWindow.setHandler("ok", this.onConfirmOk.bind(this));
      this._confirmWindow.setHandler("cancel", this.onConfirmCancel.bind(this));
    };
    Scene_Av.prototype.onOk = function () {
      /*if (this._avWindow.index() == this._avWindow.autoIndex()) {
                // 避妊
                if (! this._av.actor().canContraception() || ! this._av.canContraception()) {
                   SoundManager.playBuzzer();
                } else {
                    const b = this._av.isContraception();
                    this._av.setContraception(! b);
                    this._avWindow.refresh();
                }
                this._avWindow.activate();
                return;
            }*/
      if (this._avWindow.index() == this._avWindow.okIndex()) {
        this.confirmOk();
        return;
      }
      if (this._avWindow.index() == this._avWindow.cancelIndex()) {
        this.confirmCancel();
        return;
      }
      this._manWindow.makeData();
      this._manWindow.refresh();
      this._manWindow.show();
      this._manParamWindow.show();
      this._manWindow.activate();
      this._manWindow.select(0);
    };
    Scene_Av.prototype.onCancel = function () {
      this.popScene();
    };
    Scene_Av.prototype.onManOk = function () {
      var actor = this._manWindow.selectedActor();
      var actorId;
      if (actor) {
        actorId = actor.actorId();
      } else {
        actorId = 0;
      }
      this._manWindow.deactivate();
      this._manWindow.select(-1);
      var index = this._avWindow.index();
      if (index == 0) {
        this._av.setMainMan(actorId);
      } else if (index == 1) {
        this._av.setSubMan1(actorId);
      } else {
        this._av.setSubMan2(actorId);
      }
      this._paramWindow.refresh();
      this._avWindow.refresh();
      this._avWindow.activate();
      this._manWindow.hide();
    };
    Scene_Av.prototype.onManCancel = function () {
      this._paramWindow.refresh();
      this._avWindow.refresh();
      this._avWindow.activate();
      this._manWindow.hide();
      this._manParamWindow.hide();
    };
    Scene_Av.prototype.onManChange = function () {
      var actor = this._manWindow.selectedActor();
      this._manParamWindow.setMan(actor);
    };
    Scene_Av.prototype.onAvChange = function () {
      var actor = this._avWindow.selectedActor();
      if (actor) {
        this._manParamWindow.setMan(actor);
        this._manParamWindow.show();
      } else {
        this._manParamWindow.setMan(null);
        this._manParamWindow.hide();
      }
    };
    Scene_Av.prototype.confirmCancel = function () {
      this._inCancel = true;
      this._confirmWindow.setText(TextManager.confirmAvCancel);
      this._confirmWindow.visible = true;
      this._confirmWindow.select(0);
      this._confirmWindow.activate();
    };
    Scene_Av.prototype.confirmOk = function () {
      this._inCancel = false;
      this._confirmWindow.setText(TextManager.confirmAvOk);
      this._confirmWindow.visible = true;
      this._confirmWindow.select(0);
      this._confirmWindow.activate();
    };
    Scene_Av.prototype.onConfirmOk = function () {
      if (this._inCancel) {
        this.popScene();
      } else {
        $gameAvJacketList.clear();
        $slg.makeAv($gameTemp.av);
        $gameVariables.setValue(Nore.VIDEO_ID_VAR, $gameTemp.av.itemId());
        $gameSwitches.setValue(62, true);
        SceneManager.popAllScene();
      }
    };
    Scene_Av.prototype.onConfirmCancel = function () {
      this._inCancel = false;
      this._confirmWindow.visible = false;
      this._avWindow.activate();
    };
    return Scene_Av;
  })(Scene_MenuBase);
  Nore.Scene_Av = Scene_Av;
  var Window_Av = /** @class */ (function (_super) {
    __extends(Window_Av, _super);
    function Window_Av(av) {
      var _this = this;
      var r = new Rectangle(25, 35, 660, 735);
      _this = _super.call(this, r) || this;
      _this._av = av;
      _this.createTachieLayer();
      _this.autoSet();
      _this.refresh();
      return _this;
    }
    Window_Av.prototype.autoSet = function () {
      if (this._av.avCount() <= 1) {
        return;
      }
      if (!this._av.isSyusan()) {
        //return;
      }
      var last = $slg.avInfo().lastAv(this._av.itemId());
      this._av.setSubMan1(last.subMan1Id());
      this._av.setSubMan2(last.subMan2Id());
      this._av.setMainMan(last.mainManId());
    };
    Window_Av.prototype.createTachieLayer = function () {
      this._actorLayer = new Sprite();
      this.addChild(this._actorLayer);
    };
    Window_Av.prototype.refresh = function () {
      _super.prototype.refresh.call(this);
      this.drawDescription();
      this.drawAv();
      this.drawButton();
      this.drawTachie();
    };
    Window_Av.prototype.maxItems = function () {
      return 5;
    };
    Window_Av.prototype.itemRect = function (index) {
      /*if (index == this.autoIndex()) {
                return new Rectangle(380, 400, 220, 40);
            }*/
      if (index == this.okIndex()) {
        return new Rectangle(380, 450, 140, 40);
      }
      if (index == this.cancelIndex()) {
        return new Rectangle(380, 500, 140, 40);
      }
      var r = _super.prototype.itemRect.call(this, index);
      r.x += 280;
      r.y += 176 + index * 15;
      r.width = 220;
      return r;
    };
    Window_Av.prototype.drawAv = function () {
      this.contents.fontSize = 24;
      this.changeTextColor(ColorManager.normalColor());
      var y = 130;
      this.drawAVContents(y);
      this.drawMainActor(this.itemRect(0).y + 3);
      this.drawSubActor1(this.itemRect(1).y + 3);
      this.drawSubActor2(this.itemRect(2).y + 3);
    };
    Window_Av.prototype.drawAVContents = function (y) {
      this.drawSpriteLabel(0, y);
      this.drawText(this._av.name(), this.contentsX(), y, 300);
    };
    Window_Av.prototype.drawMainActor = function (y) {
      if (this._av.isMainManFixed()) {
        this.drawIcon(Icon.lock, 252, y);
      }
      this.drawSpriteLabel(63, y + 4);
      this.drawIcon(this._av.mainManIconIndex(), this.valueX(), y);
      this.drawText(
        this._av.mainManName(),
        this.valueX() + this.iconWidth(),
        y,
        300
      );
    };
    Window_Av.prototype.drawSubActor1 = function (y) {
      this.drawSpriteLabel(63 * 2, y + 4);
      this.drawIcon(this._av.subMan1IconIndex(), this.valueX(), y);
      this.drawText(
        this._av.subMan1Name(),
        this.valueX() + this.iconWidth(),
        y,
        300
      );
    };
    Window_Av.prototype.drawSubActor2 = function (y) {
      this.drawSpriteLabel(63 * 3, y + 4);
      this.drawIcon(this._av.subMan2IconIndex(), this.valueX(), y);
      this.drawText(
        this._av.subMan2Name(),
        this.valueX() + this.iconWidth(),
        y,
        300
      );
    };
    Window_Av.prototype.iconWidth = function () {
      return 40;
    };
    Window_Av.prototype.drawSpriteLabel = function (sy, y) {
      var rect = new Rectangle(0, sy, 120, 40);
      if (ConfigManager.language == "en") {
        rect.x += 120;
        rect.width += 30;
      }
      var s = this.getSprite(rect.x, rect.y, rect.width, rect.height);
      s.x = this.titleX();
      s.y = y + 8;
      this._windowContentsSprite.addChild(s);
    };
    Window_Av.prototype.titleX = function () {
      return 120;
    };
    Window_Av.prototype.contentsX = function () {
      return 290;
    };
    Window_Av.prototype.valueX = function () {
      return this.contentsX() + 4;
    };
    Window_Av.prototype.getSprite = function (x, y, w, h) {
      var baseTexture = Nore.getSystemBaseTexture("av");
      var r = new Rectangle(x, y, w, h);
      var texture = new PIXI.Texture(baseTexture, r);
      var s = new PIXI.Sprite(texture);
      return s;
    };
    Window_Av.prototype.hininIndex = function () {
      return -1;
    };
    Window_Av.prototype.autoIndex = function () {
      return -1;
    };
    Window_Av.prototype.okIndex = function () {
      return 3;
    };
    Window_Av.prototype.cancelIndex = function () {
      return 4;
    };
    Window_Av.prototype.drawButton = function () {
      var rect3 = this.itemRect(this.okIndex());
      this.changePaintOpacity(this._av.isEnabled());
      this.drawText("OK", rect3.x, rect3.y, rect3.width, "center");
      this.changePaintOpacity(true);
      var rect4 = this.itemRect(this.cancelIndex());
      this.drawText("Cancel", rect4.x, rect4.y, rect3.width, "center");
    };
    Window_Av.prototype.isCurrentItemEnabled = function () {
      if (this.index() == 0) {
        if (this._av.isMainManFixed()) {
          return false;
        }
      }
      if (this.index() == this.okIndex()) {
        return this._av.isEnabled();
      }
      return true;
    };
    Window_Av.prototype.selectedActor = function () {
      var actorId = this.selectedActorId();
      if (actorId > 0) {
        return $gameActors.actor(actorId);
      }
      return null;
    };
    Window_Av.prototype.selectedActorId = function () {
      switch (this.index()) {
        case 0:
          return this._av.mainManId();
        case 1:
          return this._av.subMan1Id();
        case 2:
          return this._av.subMan2Id();
      }
      return 0;
    };
    Window_Av.prototype.drawDescription = function () {
      this.changeTextColor(ColorManager.crisisColor());
      this.contents.fontSize = 23;
      var ww = 620;
      var y1 = 20;
      var y2 = 64;
      if (this._av.mainManId() == 0) {
        this.drawText(TextManager.setMainMan, 50, 50, ww, "center");
      } else if (!this._av.isEnabledParam()) {
        this.drawText(TextManager.setSubMan1, 0, y1, ww, "center");
        this.drawText(TextManager.setSubMan2, 0, y2, ww, "center");
      } else if (!this._av.isEnabledSkill()) {
        this.drawText(TextManager.setAvSkill, 0, y1, ww, "center");
      } else {
        if ($slg.avInfo().findBeforeAv(this._av)) {
          this.changeTextColor(ColorManager.deathColor());
          if (this._av.isGeneralAv()) {
            this.drawText(TextManager.canMakeAv2nd5, 20, y1, ww - 24, "center");
            this.drawText(TextManager.canMakeAv2nd4, 20, y2, ww, "center");
          } else if (this._av.isSyusan()) {
            this.drawText(TextManager.canMakeAv2nd3, 20, y1, ww - 24, "center");
            this.drawText(TextManager.canMakeAv2nd4, 20, y2, ww, "center");
          } else {
            this.drawText(TextManager.canMakeAv2nd, 0, y1, ww, "center");
            //this.drawText(TextManager.canMakeAv2nd2, 0, y2, ww, 'center');
          }
        } else {
          this.drawText(TextManager.canMakeAv, 0, y1, ww, "center");
        }
      }
    };
    Window_Av.prototype.drawTachie = function () {
      var actor = this._av.actor();
      var x = -40 + this.getTachieOffsetX(actor.actorId());
      var y = 200 + this.getTachieOffsetY(actor.actorId());
      var rect = new Rectangle(20, 120, 380, 600);
      this.drawTachieActor(
        actor,
        this._actorLayer,
        x,
        y,
        rect,
        actor._defaultFaceId,
        0.8
      );
    };
    Window_Av.prototype.getTachieOffsetY = function (actorId) {
      switch (actorId) {
        case 8:
          return -50;
        case 10:
          return -60;
        case 11:
          return -60;
        case 13:
          return -20;
        case 17:
          return -50;
      }
      return 0;
    };
    Window_Av.prototype.getTachieOffsetX = function (actorId) {
      switch (actorId) {
        case 4:
          return 0;
        case 8:
          return 20;
      }
      return 0;
    };
    Window_Av.prototype.faceId = function () {
      switch (this._av.actorId()) {
        case 8:
          return 1;
        case 10:
          return 1;
        case 11:
          return 2;
        case 17:
          return 8;
        default:
          return 4;
      }
    };
    Window_Av.prototype.itemHeight = function () {
      return 45;
    };
    return Window_Av;
  })(Window_Selectable);
  var Window_AvParam = /** @class */ (function (_super) {
    __extends(Window_AvParam, _super);
    function Window_AvParam(av) {
      var _this = this;
      var r = new Rectangle(RIGHT_WINDOW_X, 35, 500, 346);
      _this = _super.call(this, r) || this;
      _this._av = av;
      _this.refresh();
      return _this;
    }
    Window_AvParam.prototype.refresh = function () {
      _super.prototype.refresh.call(this);
      this.drawParams();
      this.drawSkills();
    };
    Window_AvParam.prototype.titleX = function () {
      return 27;
    };
    Window_AvParam.prototype.drawParams = function () {
      this.changePaintOpacity(true);
      this.drawSpriteLabel(237, 25);
      var yy = 52;
      var list = this._av.avParamList();
      for (var i = 0; i < list.length; i++) {
        var avParam = list[i];
        this.drawParamTitle(avParam, yy);
        this.drawParamValue(avParam, yy);
        this.drawParamGauge(216, yy, avParam);
        yy += this.lineHeight();
      }
    };
    Window_AvParam.prototype.drawParamTitle = function (avParam, y) {
      var iconX = 20;
      var iconY = 2;
      var xx = 64 - 5;
      this.changeTextColor(ColorManager.normalColor());
      this.contents.fontSize = 18;
      this.drawIcon(avParam.iconIndex(), iconX, y + iconY);
      this.drawText(avParam.name(), xx, y, 59);
    };
    Window_AvParam.prototype.drawParamValue = function (avParam, yy) {
      var valueX = 84;
      var param = avParam.woman();
      if (param + avParam.plus() < avParam.value()) {
        this.contents.textColor = ColorManager.textColor(7);
      } else {
        this.contents.textColor = ColorManager.normalColor();
      }
      this.drawText(param + avParam.plus(), valueX - 12, yy, 80, "right");
      this.contents.textColor = ColorManager.normalColor();
      this.drawText("/", valueX, yy, 80, "right");
      this.drawText(avParam.value(), valueX + 40, yy, 80, "right");
    };
    Window_AvParam.prototype.lineHeight = function () {
      return 38;
    };
    Window_AvParam.prototype.drawParamGauge = function (x, y, avParam) {
      var param = avParam.woman();
      var requiredValue = avParam.value();
      var plus = avParam.plus();
      y += 10;
      var hh = 17;
      var rate = 2;
      var m = 1;
      var boxWidth = Math.max(param + plus, requiredValue);
      var maxBox = 90;
      if (boxWidth >= maxBox) {
        boxWidth = maxBox;
      }
      if (param >= maxBox) {
        param = maxBox;
      }
      this.contents.fillRect(
        x - m * 2,
        y - m * 2,
        boxWidth * rate + m * 4,
        hh + m * 4,
        "#FFFFFF"
      );
      this.contents.fillRect(
        x - m * 1,
        y - m * 1,
        boxWidth * rate + m * 2,
        hh + m * 2,
        "#000000"
      );
      this.contents.gradientFillRect(
        x,
        y,
        param * rate,
        hh,
        "#29f19c",
        "#02a1f9"
      );
      if (param < maxBox) {
        if (param + plus > maxBox) {
          plus = maxBox - param;
          this.contents.gradientFillRect(
            x + param * rate,
            y,
            plus * rate,
            hh,
            "#ffff39",
            "#ffff39"
          );
        } else {
          this.contents.gradientFillRect(
            x + param * rate,
            y,
            plus * rate,
            hh,
            "#ff8939",
            "#ffd25e"
          );
        }
      }
      if (param + plus >= requiredValue) {
        this.contents.fillRect(
          x + requiredValue * rate,
          y - m * 4,
          2,
          hh + m * 8,
          "#DD0000"
        );
      }
      var remain = requiredValue - plus - param;
      this.contents.fontSize = 14;
      if (remain > 0) {
        this.changeTextColor(ColorManager.normalColor());
        this.drawText(
          TextManager.paramRemain.format(remain),
          x + requiredValue * rate + 10,
          y - 6,
          100
        );
      } else {
        this.changeTextColor(ColorManager.crisisColor());
        var xx = param + plus;
        if (xx >= maxBox) {
          xx = maxBox;
        }
        this.drawText("OK +" + -remain, x + xx * rate + 10, y - 6, 100);
      }
    };
    Window_AvParam.prototype.drawSkills = function () {
      this.contents.fontSize = 18;
      this.drawRequiredSkills();
      this.drawEffectiveSkills();
    };
    Window_AvParam.prototype.drawRequiredSkills = function () {
      this.drawSpriteLabel(239 + 30, 190);
      var allSkills = this._av.allSkills();
      this.changePaintOpacity(true);
      this.changeTextColor(ColorManager.normalColor());
      var yy = 210;
      var xx = 70;
      for (var _i = 0, _a = this._av.requiredSkills(); _i < _a.length; _i++) {
        var skill = _a[_i];
        if (allSkills.contains(skill)) {
          this.changePaintOpacity(true);
        } else {
          this.changePaintOpacity(false);
        }
        this.drawText(this.skillName(skill), xx, yy, 200);
        xx += 120;
      }
    };
    Window_AvParam.prototype.drawSpriteLabel = function (sy, y) {
      var rect = new Rectangle(0, sy, 300, 32);
      if (ConfigManager.language == "en") {
        rect.y += 102;
      }
      var s = this.getSprite(rect.x, rect.y, rect.width, rect.height);
      s.x = this.titleX();
      s.y = y;
      this._windowContentsSprite.addChild(s);
    };
    Window_AvParam.prototype.getSprite = function (x, y, w, h) {
      var baseTexture = Nore.getSystemBaseTexture("av");
      var r = new Rectangle(x, y, w, h);
      var texture = new PIXI.Texture(baseTexture, r);
      var s = new PIXI.Sprite(texture);
      return s;
    };
    Window_AvParam.prototype.drawEffectiveSkills = function () {
      this.drawSpriteLabel(239 + 30 + 32, 258);
      var allSkills = this._av.allSkills();
      var xx = 70;
      var yy = 276;
      this.changeTextColor(ColorManager.systemColor());
      this.changePaintOpacity(true);
      this.changeTextColor(ColorManager.normalColor());
      for (var _i = 0, _a = this._av.effectiveSkills(); _i < _a.length; _i++) {
        var skill = _a[_i];
        if (allSkills.contains(skill)) {
          this.changePaintOpacity(true);
        } else {
          this.changePaintOpacity(false);
        }
        this.drawText(this.skillName(skill), xx, yy, 130);
        xx += 140;
      }
      var bonus = this._av.skillBonusRate();
      if (bonus > 0) {
        this.changeTextColor(ColorManager.textColor(14));
        this.changePaintOpacity(true);
        this.drawText(TextManager.avReward + " +" + bonus + "％", xx, yy, 200);
      }
    };
    Window_AvParam.prototype.skillName = function (skill) {
      if (ConfigManager.language == "en") {
        var nameEn = skill.meta["nameEn"];
        if (nameEn) {
          return nameEn;
        }
      }
      return skill.name;
    };
    return Window_AvParam;
  })(Window_Selectable);
  var Window_AvMan = /** @class */ (function (_super) {
    __extends(Window_AvMan, _super);
    function Window_AvMan(av, avWindow) {
      var _this = this;
      var r = new Rectangle(RIGHT_WINDOW_X, 390, 280, 380);
      _this = _super.call(this, r) || this;
      _this._av = av;
      _this._avWindow = avWindow;
      _this.makeData();
      _this.refresh();
      return _this;
    }
    Window_AvMan.prototype.makeData = function () {
      this._itemList = $slg.manList();
      if (this._av.isMainManFixed()) {
        var mainFixedMan = $gameActors.actor(this._av.mainManId());
        var index = this._itemList.indexOf(mainFixedMan);
        if (index >= 0) {
          this._itemList.splice(index, 1);
        }
      }
      if (this._av.mainManId() > 0 && this._avWindow.index() == 0) {
        var main = $gameActors.actor(this._av.mainManId());
        var index = this._itemList.indexOf(main);
        if (index >= 0) {
          this._itemList.splice(index, 1);
        }
      }
      if (this._av.subMan1Id() > 0 && this._avWindow.index() == 1) {
        var main = $gameActors.actor(this._av.subMan1Id());
        var index = this._itemList.indexOf(main);
        if (index >= 0) {
          this._itemList.splice(index, 1);
        }
      }
      if (this._av.subMan2Id() > 0 && this._avWindow.index() == 2) {
        var main = $gameActors.actor(this._av.subMan2Id());
        var index = this._itemList.indexOf(main);
        if (index >= 0) {
          this._itemList.splice(index, 1);
        }
      }
      this._itemList.push(null);
    };
    Window_AvMan.prototype.maxItems = function () {
      if (!this._itemList) {
        return 0;
      }
      return this._itemList.length;
    };
    Window_AvMan.prototype.selectedActor = function () {
      return this._itemList[this.index()];
    };
    Window_AvMan.prototype.drawItem = function (index) {
      var actor = this._itemList[index];
      if (!actor) {
        return null;
      }
      if (this._av.containsMan(actor.actorId())) {
        this.changePaintOpacity(false);
      } else {
        this.changePaintOpacity(true);
      }
      this.contents.fontSize = 22;
      var rect = this.itemRect(index);
      this.drawIcon(actor.iconIndex(), rect.x + 20, rect.y);
      this.drawText(actor.name(), rect.x + 30 + 30, rect.y, rect.width);
      this.changePaintOpacity(true);
    };
    return Window_AvMan;
  })(Window_Selectable);
  var Window_AvManParams = /** @class */ (function (_super) {
    __extends(Window_AvManParams, _super);
    function Window_AvManParams(av, height) {
      if (height === void 0) {
        height = 380;
      }
      var _this = this;
      var r = new Rectangle(984, 390, 270, height);
      _this = _super.call(this, r) || this;
      _this._av = av;
      _this.refresh();
      return _this;
    }
    Window_AvManParams.prototype.setMan = function (actor) {
      this._actor = actor;
      this.refresh();
    };
    Window_AvManParams.prototype.refresh = function () {
      this._windowContentsSprite.removeChildren();
      this.contents.clear();
      this.contents.fontSize = 20;
      var list = Nore.$avParamManager.list();
      for (var i = 0; i < list.length; i++) {
        this.drawItem(i, list[i]);
      }
      this.drawSkills();
    };
    Window_AvManParams.prototype.drawItem = function (index, info) {
      this.changePaintOpacity(this._av.isMatchParam(info.type()));
      this.changeTextColor(ColorManager.normalColor());
      var yy = index * this.lineHeight() + 12;
      var left = 48;
      this.drawIcon(info.iconIndex(), left, yy);
      this.drawText(info.name(), left + 42, yy, 100);
      if (!this._actor) {
        return;
      }
      this.drawText(this._actor.eroParam(info.type()), 102, yy, 100, "right");
    };
    Window_AvManParams.prototype.getSprite = function (x, y, w, h) {
      var baseTexture = Nore.getSystemBaseTexture("av");
      var r = new Rectangle(x, y, w, h);
      var texture = new PIXI.Texture(baseTexture, r);
      var s = new PIXI.Sprite(texture);
      return s;
    };
    Window_AvManParams.prototype.drawSkills = function () {
      this.changeTextColor(ColorManager.systemColor());
      this.changePaintOpacity(true);
      var yyy = this.lineHeight() * 6 + 2;
      this.contents.fontSize = 20;
      var s = this.getSprite(0, 430, 200, 50);
      s.x = 22;
      s.y = 258;
      this._windowContentsSprite.addChild(s);
      this.contents.fillRect(10, 238, 218, 2, "#9091a4");
      if (!this._actor) {
        return;
      }
      this.changeTextColor(ColorManager.normalColor());
      var yy = this.lineHeight() * 7 - 6;
      var skills = this._actor.manSkillList();
      for (var i = 0; i < skills.length; i++) {
        var skill = skills[i];
        if (
          this._av.isRequiredSkill(skill) ||
          this._av.isEffectiveSkill(skill)
        ) {
          this.changePaintOpacity(true);
        } else {
          this.changePaintOpacity(false);
        }
        this.drawText(this.skillName(skill), 92, yy, 130);
        yy += this.lineHeight() - 5;
      }
    };
    Window_AvManParams.prototype.skillName = function (skill) {
      if (ConfigManager.language == "en") {
        var nameEn = skill.meta["nameEn"];
        if (nameEn) {
          return nameEn;
        }
      }
      return skill.name;
    };
    return Window_AvManParams;
  })(Window_Base);
  Nore.Window_AvManParams = Window_AvManParams;
})(Nore || (Nore = {}));

repo_name: onms/dead

license: unknown


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
/*:ja
 * @target MZ
 * @author ル
 *
 * @command makeBabyRoom
 * @text 赤ん坊画面作成
 * @des 赤ん坊画面作成
 * @arg actorId
 * @type number
 *
 *
 */
var Nore;
(function (Nore) {
  var pluginName = "Nore_Baby";
  PluginManager.registerCommand(pluginName, "makeBabyRoom", function (args) {
    var actorId = Math.trunc(args.actorId);
    var actor = $gameActors.actor(actorId);
    for (var i = 0; i < 15; i++) {
      var varId = getBabyVar(i);
      $gameVariables.setValue(varId, 0);
    }
    var index = 0;
    var babyList = [];
    for (var _i = 0, _a = actor.babyList(); _i < _a.length; _i++) {
      var b = _a[_i];
      if (!b.isSyusan()) {
        continue;
      }
      babyList.unshift(b);
    }
    for (var _b = 0, babyList_1 = babyList; _b < babyList_1.length; _b++) {
      var baby = babyList_1[_b];
      var id = imageId(baby);
      var varId = getBabyVar(index);
      $gameVariables.setValue(varId, id);
      index++;
      if (index >= 15) {
        break;
      }
    }
    $gameVariables.setValue(960, index);
  });
  function getBabyVar(index) {
    return 959 - index;
  }
  function imageId(baby) {
    if (baby.isBlack()) {
      if (baby.imageIndex() == 1) {
        return 13 + baby.growth();
      } else {
        return 16 + baby.growth();
      }
    }
    if (baby.isMale()) {
      if (baby.imageIndex() == 1) {
        return 7 + baby.growth();
      } else {
        return 10 + baby.growth();
      }
    }
    if (baby.imageIndex() == 1) {
      return 1 + baby.growth();
    } else {
      return 4 + baby.growth();
    }
  }
})(Nore || (Nore = {}));
var Sprite_BabyCharacter = /** @class */ (function (_super) {
  __extends(Sprite_BabyCharacter, _super);
  function Sprite_BabyCharacter(event) {
    var _this = _super.call(this, event) || this;
    _this.calcBabyActor(event);
    _this._baby = _this.lastBaby();
    $gameSwitches.setValue(_this.backSw(), _this._baby != null);
    return _this;
  }
  Sprite_BabyCharacter.prototype.backSw = function () {
    switch (this._babyActorId) {
      case 9:
        return 163;
      case 4:
        return 169;
      case 13:
        return 166;
      case 17:
        return 172;
    }
    return -1;
  };
  Sprite_BabyCharacter.prototype.calcBabyActor = function (event) {
    this._babyActorId = parseInt(event.event().meta["baby"]);
  };
  Sprite_BabyCharacter.prototype.updateBitmap = function () {
    if (this.isImageChanged()) {
      this._tilesetId = $gameMap.tilesetId();
      this._tileId = this._character.tileId();
      if (this._baby) {
        this._characterName = this._baby.babyImageId();
        this._characterIndex = 0;
      } else {
        this._characterName = "";
        this._characterIndex = 0;
      }
      this.setCharacterBitmap();
    }
  };
  Sprite_BabyCharacter.prototype.characterPatternY = function () {
    if (!this._baby) {
      return 0;
    }
    return this._baby.growth();
  };
  Sprite_BabyCharacter.prototype.lastBaby = function () {
    var actor = $gameActors.actor(this._babyActorId);
    var manId = actor.dousei().manId();
    if (manId == 0) {
      return null;
    }
    var babyList = actor.babyList();
    for (var i = 0; i < babyList.length; i++) {
      var baby = babyList[babyList.length - 1 - i];
      if (baby.isSyusan()) {
        if (baby.taneoyaId() == manId) {
          return baby;
        }
      }
    }
    return null;
  };
  return Sprite_BabyCharacter;
})(Sprite_Character);
function isBabyCharacterEvent(event) {
  if (!event) {
    return false;
  }
  if (!event.event()) {
    return false;
  }
  return event.event().meta["baby"] != null;
}


code:
var __extends =
  (this && this.__extends) ||
  (function () {
    var extendStatics = function (d, b) {
      extendStatics =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (d, b) {
            d.__proto__ = b;
          }) ||
        function (d, b) {
          for (var p in b)
            if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
        };
      return extendStatics(d, b);
    };
    return function (d, b) {
      if (typeof b !== "function" && b !== null)
        throw new TypeError(
          "Class extends value " + String(b) + " is not a constructor or null"
        );
      extendStatics(d, b);
      function __() {
        this.constructor = d;
      }
      d.prototype =
        b === null
          ? Object.create(b)
          : ((__.prototype = b.prototype), new __());
    };
  })();
//=============================================================================
// Nore_BackLog.js
//=============================================================================
/*:ja
 * @plugindesc バックログを表示するプラグインです。
 *
 *
 * @param backLogButton
 * @desc バックログを表示するボタンです
 * @default pageup
 *
 * @param marginLeft
 * @desc 本文の左のスペースです。変更した場合、改行位置がずれる場合があります。
 * @default 70
 *
 * @param marginRight
 * @desc 本文の右のスペースです。変更した場合、改行位置がずれる場合があります。
 * @default 30
 *
 * @param nameLeft
 * @desc 名前の左のスペースです。
 * @default 20
 *
 * @param fontSize
 * @desc フォントサイズです。変更した場合、改行位置がずれる場合があります。
 * @default 24
 *
 * @param scrollSpeed
 * @desc カーソルキーでスクロールするときの速度です
 * @default 5
 *
 * @param windowHeight
 * @desc ウィンドウの高さです。大きいほど多く表示できます。
 * @default 2000
 *
 * @param maxLogCount
 * @desc ログを保存しておく最大数です
 * @default 50
 *
 * @param bottmMargin
 * @desc バックログウィンドウの下の空き空間です
 * @default 50
 *
 * @param logMargin
 * @desc ログとログの間の隙間です
 * @default 34
 *
 * @param windowSkin
 * @desc バックログ表示に使うウィンドウです
 * @default WindowBacklog
 * @require 1
 * @dir img/system/
 * @type file
 *
 * @param backOpacity
 * @desc 背景の透明度です
 * @default 230
 *
 *
 * @help
 * Ver
 *
 * テキストのバックログを表示するプラグインです。
 * 立ち絵スクリプトとの併用を想定しています。
 * 併用しない場合、独自に
 * $gameBackLog.addLog(name, message);
 * を呼ぶ必要があります。
 *
 */
var Game_BackLog = /** @class */ (function () {
  function Game_BackLog() {
    this.logList = [];
  }
  Game_BackLog.prototype.addLog = function (name, message) {
    message = message.replace("V[20]", $gameVariables.value(20) + "");
    message = message.replace("V[21]", $gameVariables.value(21) + "");
    message = message.replace("V[22]", $gameVariables.value(22) + "");
    message = message.replace("V[23]", $gameVariables.value(23) + "");
    message = message.replace("V[24]", $gameVariables.value(24) + "");
    this.logList.push(new Game_TalkLog(name, message));
    if (this.logList.length >= 50) {
      this.logList.shift();
    }
  };
  return Game_BackLog;
})();
var Game_TalkLog = /** @class */ (function () {
  function Game_TalkLog(name, message) {
    this.name = name;
    this.message = message;
  }
  return Game_TalkLog;
})();
var Nore;
(function (Nore) {
  var BackLog;
  (function (BackLog) {
    var parameters = PluginManager.parameters("Nore_BackLog");
    BackLog.backLogButton = parameters["backLogButton"];
    var scrollSpeed = parseInt(parameters["scrollSpeed"]);
    var bottmMargin = parseInt(parameters["bottmMargin"]);
    var windowHeight = parseInt(parameters["windowHeight"]);
    var fontSize = parseInt(parameters["fontSize"]);
    var logMargin = parseInt(parameters["logMargin"]);
    var marginLeft = parseInt(parameters["marginLeft"]);
    var marginRight = parseInt(parameters["marginRight"]);
    var nameLeft = parseInt(parameters["nameLeft"]);
    var backOpacity = parseInt(parameters["backOpacity"]);
    /**
     * バックログを表示するウィンドウクラスです。
     */
    var Window_BackLog = /** @class */ (function (_super) {
      __extends(Window_BackLog, _super);
      function Window_BackLog() {
        var _this =
          _super.call(
            this,
            new Rectangle(0, 0, Graphics.width, windowHeight)
          ) || this;
        _this._isNoSumi = true;
        _this._margin = 0;
        _this.frameVisible = false;
        _this.backOpacity = backOpacity;
        _this.opacity = 255;
        _this.contentsOpacity = 255;
        _this._refreshBack();
        _this.drawLogs();
        return _this;
      }
      Window_BackLog.prototype.drawLogs = function () {
        var y = 0;
        for (
          var _i = 0, _a = BackLog.$gameBackLog.logList;
          _i < _a.length;
          _i++
        ) {
          var log = _a[_i];
          y += this.drawLog(log, y);
          y += this.logMargin();
        }
        if (y > windowHeight) {
          this._maxHeight = windowHeight;
          // 一回目の描画ではみだしていたら、はみ出す部分をけずって歳描画
          var diff = y - windowHeight + bottmMargin;
          while (true) {
            if (BackLog.$gameBackLog.logList.length === 0) {
              break;
            }
            var log = BackLog.$gameBackLog.logList.shift();
            if (diff < log.y) {
              break;
            }
          }
          this.contents.clear();
          y = 0;
          for (
            var _b = 0, _c = BackLog.$gameBackLog.logList;
            _b < _c.length;
            _b++
          ) {
            var log = _c[_b];
            y += this.drawLog(log, y);
            y += this.logMargin();
          }
          this._maxHeight = y + bottmMargin;
          if (this._maxHeight > windowHeight) {
            this._maxHeight = windowHeight;
          }
          // 一番下までスクロールさせる
          this.y = Graphics.height - this._maxHeight;
        } else {
          this._maxHeight = y + bottmMargin;
          if (this._maxHeight > windowHeight) {
            this._maxHeight = windowHeight;
          }
          if (this._maxHeight < Graphics.height) {
            this._maxHeight = Graphics.height;
          }
          this.y = Graphics.height - this._maxHeight;
        }
      };
      /**
       * ログをひとつ描画します
       * @param  {Game_TalkLog} log 描画するログ
       * @param  {number}       y   描画する y 座標
       * @return {number}           描画した高さ
       */
      Window_BackLog.prototype.drawLog = function (log, y) {
        this._lineCount = 1;
        var message = log.message;
        var height = 0;
        if (log.name) {
          this.drawTextEx(log.name, nameLeft, y);
          if (message.charAt(message.length - 1) === "。") {
            message = message.substring(0, message.length - 1);
          }
          message = message + "」";
          y += this.standardFontSize() + 8;
          height = this.standardFontSize() + 8;
          this.drawTextEx("「", marginLeft - this.standardFontSize(), y);
        }
        this.drawTextEx(message, marginLeft, y);
        height += this._lineCount * (this.standardFontSize() + 8);
        log.y = y + height;
        return height;
      };
      Window_BackLog.prototype.processNewLine = function (textState) {
        this._lineCount++;
        _super.prototype.processNewLine.call(this, textState);
      };
      Window_BackLog.prototype.logMargin = function () {
        return logMargin;
      };
      Window_BackLog.prototype.textAreaWidth = function () {
        return this.contentsWidth() - marginRight;
      };
      Window_BackLog.prototype.update = function () {
        _super.prototype.update.call(this);
        if (Input.isPressed("down")) {
          this.y -= scrollSpeed;
          if (this.y < Graphics.height - this._maxHeight) {
            this.y = Graphics.height - this._maxHeight;
          }
        } else if (Input.isPressed("up")) {
          this.y += scrollSpeed;
          if (this.y > 0) {
            this.y = 0;
          }
        }
        if (TouchInput.wheelY > 0) {
          this.y -= scrollSpeed * 4;
          if (this.y < Graphics.height - this._maxHeight) {
            this.y = Graphics.height - this._maxHeight;
          }
        } else if (TouchInput.wheelY < 0) {
          this.y += scrollSpeed * 4;
          if (this.y > 0) {
            this.y = 0;
          }
        }
      };
      Window_BackLog.prototype.standardFontSize = function () {
        return fontSize;
      };
      Window_BackLog.prototype.backPaintOpacity = function () {
        return 128;
      };
      return Window_BackLog;
    })(Window_Base);
    BackLog.Window_BackLog = Window_BackLog;
    var _Scene_Message_update = Scene_Message.prototype.update;
    Scene_Message.prototype.update = function () {
      if (this._windowBackLog) {
        this._windowBackLog.update();
        if (
          Input.isTriggered(BackLog.backLogButton) ||
          Input.isTriggered("cancel") ||
          Input.isTriggered("ok") ||
          TouchInput.isTriggered()
        ) {
          this.removeChild(this._windowBackLog);
          this._windowBackLog = null;
          SoundManager.playCancel();
          TouchInput.clear();
          Input.clear();
        }
        return;
      }
      _Scene_Message_update.call(this);
      this.updateBackLog();
    };
    Scene_Message.prototype.updateBackLog = function () {
      if (this._backlogDisabled) {
        return;
      }
      if (Input.isTriggered(BackLog.backLogButton) || TouchInput.wheelY < 0) {
        this._windowBackLog = new Window_BackLog();
        SoundManager.playOk();
        this.addChild(this._windowBackLog);
      }
      if (this._autoWait > 0) {
        this._autoWait--;
      } else {
        if (TouchInput.wheelY > 0) {
          $gameMessage.toggleAuto();
          this._autoWait = 20;
        }
      }
    };
    var _Scene_Message_updateMain = Scene_Map.prototype.updateMain;
    Scene_Map.prototype.updateMain = function () {
      if (this._windowBackLog) {
        return;
      }
      _Scene_Message_updateMain.call(this);
    };
    var _DataManager_extractSaveContents = DataManager.extractSaveContents;
    DataManager.extractSaveContents = function (contents) {
      _DataManager_extractSaveContents.call(this, contents);
      BackLog.$gameBackLog = contents.backlog || new Game_BackLog();
    };
    var _DataManager_makeSaveContents = DataManager.makeSaveContents;
    DataManager.makeSaveContents = function () {
      var contents = _DataManager_makeSaveContents.call(this);
      contents.backlog = BackLog.$gameBackLog;
      return contents;
    };
    BackLog.$gameBackLog = new Game_BackLog();
  })((BackLog = Nore.BackLog || (Nore.BackLog = {})));
})(Nore || (Nore = {}));