let menuDataStateArr = []; 
class MenuDataState { 
    constructor(setStateNo , setColorNo , set優先度) {
        this._No = setStateNo;     
        this._ColNo = setColorNo; 
        this._Yusen = set優先度; 
        this.PicNo = -1;
        this.Desc = "";
        this.PosX = 0;
        this.PosY = 0;
    }
}
let RentDeckNames = [
    "レンタルデッキα" , "レンタルデッキβ" , "レンタルデッキγ",
    "レンタルデッキε" , "レンタルデッキΖ" ,
]; 
let menuDataFlame = 0;
let menu装備No = -1;
Game_Interpreter.prototype.MenuDataView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    let setOpacity = 255;
    if (fadeInFlg) {
        menuDataFlame = 0;
        menuData_Mode = EnMenuDataMode.Top;
        setOpacity = 0;
    }
    if($gameSwitches.value(BtlStatic.SW_終了後HP回復)) {
        $gameActors._data[1]._hp = $gameActors._data[1].mhp;
    }
    befMenuDataDrawDeckNo = -1;
    menuDataStateArr = [];
    ViewSpriteArr_Reset();
    this.SetSprite(PNo_DBase, MenuUIPath + "Data/D_Base", 218, 194, setOpacity);
    D_Text_Cng_font = "Makinas"; 
    this.SpriteStr(PNo_NameTxt, "名前：ロマーシャ=ペイシェンス", 24, 252, 200, setOpacity);
    this.SpriteStr(PNo_SexTxt, "性別：female", 24, 698, 200, setOpacity);
    this.SetSprite(PN_LPGageBack, MenuUIPath + "Data/PN_LPGageBack", 487, 266, setOpacity);
    this.SetSprite(PN_LPGage, MenuUIPath + "Data/D_LPBar", 487, 266, setOpacity, Math.floor(($gameActors._data[1]._hp / $gameActors._data[1].mhp) * 100));
    let hpText = $gameActors._data[1]._hp;
    this.SpriteStr(PNo_LPTxt, hpText, 25, 817 - 195, 260, setOpacity);
    let mpText = $gameVariables.value(VN_MpBase);
    if ($gameActors._data[1].equips()[3] != null) {
        mpText += $gameActors._data[1].equips()[3].params[1]; //称号(防具)の最大MP// はドロー追加
    }
    //this.SpriteStr(PNo_CPTxt, mpText, 24, 649, 310 ,setOpacity);
    this.SetSprite(PNo_CPGage, MenuUIPath + "Data/D_MPBar", 494, 313, setOpacity, Math.floor((mpText / 7) * 100));
    let drawCardText = $gameVariables.value(VN_DrowCard);
    if ($gameActors._data[1].equips()[3] != null) {
        drawCardText += $gameActors._data[1].equips()[3].params[6]; //称号(防具)の敏捷はドロー追加
    }
    //this.SpriteStr(PNo_DrTxt, drawCardText, 24, 855, 310, setOpacity);
    if ($gameSwitches.value(SW_SijiView)) {
        this.SetSpriteC(PN_SijiView, MenuUIPath + "Data/SijiWin", 309, 450, setOpacity);
        this.SpriteStrC(PN_SijiTxt, $gameVariables.value(VN_Sijiritu) + "% ", 19, 350, 449, setOpacity);
    }
    let savePicPath = $gameActors.actor(1)._characterName.split('%')[0];
    this.PlaySpriteAnimeC(PNo_CAnime, MenuUIPath + "Save/" + savePicPath, 6, 10, 312, 343); 
    this.MenuMainData_DeckSelectBtnDraw(setOpacity);
    for (let i = 0; i <= $dataArmors.length - 1; i++) {
        if ($gameActors.actor(1).hasArmor($dataArmors[i + 1])) { 
            menu装備No = i + 1;
            this.SpriteStr(PNo_SyogTxt, "称号：" + $dataArmors[i + 1].name, 24, 257, 489, setOpacity);
        }
    }
    if ($gameSystem.Gob奴隷Mode == undefined) $gameSystem.Gob奴隷Mode = false;
    if (!$gameSystem.Gob奴隷Mode) {
        this.SetSprite(PN_DtSyogo, MenuUIPath + "Equip/E_SyogoBtn", 626, 481, setOpacity);
    }
    this.DrawMenuDataState(setOpacity);
    this.SetSpriteC(PNo_AllBtn, MenuUIPath + "Data/D_ALLBtn", 755, 711, setOpacity);
    //this.SetSpriteC(PNo_VirusBtn, MenuUIPath + "Data/PNo_VirusBtn", 835, 711, setOpacity); //ウィルス対策機能はオミット
    if ($gameVariables.value(VN_RentDeckCnt) > 1 && $gameSwitches.value(SW_RentalOK) && !$gameSwitches.value(SW_RentalOnlyFlg)) {
        this.SetSpriteC(PN_RentDeckCng, MenuUIPath + "Data/PN_RentDeckCng", 877, 466, setOpacity);
    }
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255 ,true,true);
    }
    D_Text_Cng_font = ""; 
}
RentalDeck選択許可戻し = function () {
    $gameSwitches.setValue(SW_RentalOK , true);
    $gameSwitches.setValue(SW_RentalOnlyFlg , false);
    $gameVariables.setValue(VN_RentDeckSelectNo ,1);
}
Game_Interpreter.prototype.DrawMenuDataState = function (setOpacity) {
    menuDataStateArr = [];
    let ijoTextSize = 23;
    let ijoSetX = 257;  
    let ijoSetY = 575; 
    let ijoSpaceY = 33; 
    for (let i = 0; i <= $gameActors._data[1]._states.length - 1; i++) { 
        let stateId = $gameActors._data[1]._states[i];
        if (MetaChecker($dataStates[stateId],"パッシブ") != ""){
            let colorNo = 0;
            if (MetaChecker($dataStates[stateId], "文字色") != ""){
                colorNo = Number(MetaChecker($dataStates[stateId], "文字色"));
            }
            let _優先度 = 0;
            if (MetaChecker($dataStates[stateId], "優先度") != "") {
                _優先度 = Number(MetaChecker($dataStates[stateId], "優先度"));
            }
            let Desc = "";
            if (MetaChecker($dataStates[stateId], "説明") != "") {
                Desc = Number(MetaChecker($dataStates[stateId], "説明"));
            }
            let addStateData = new MenuDataState(stateId, colorNo,_優先度);
            addStateData.Desc = Desc;
            menuDataStateArr.push(addStateData);
        }
    }
    if (menuDataStateArr.length > 0) {
        let sortArr = [];
        sortArr.push(menuDataStateArr[0]); 
        for (let i = 1; i <= menuDataStateArr.length - 1; i++) {
            let pushFlg = true; 
            for (let j = 0; j <= sortArr.length - 1; j++) {
                if (sortArr[j]._Yusen < menuDataStateArr[i]._Yusen){
                    sortArr.splice(j, 0, menuDataStateArr[i]); 
                    pushFlg = false;
                    break; 
                }
            }
            if (pushFlg) sortArr.push(menuDataStateArr[i]);
        }
        menuDataStateArr = sortArr.slice();
        for (let i = 0; i <= menuDataStateArr.length - 1; i++) {
            let stateName = $dataStates[menuDataStateArr[i]._No].name;
            let setText = "\\C[" + menuDataStateArr[i]._ColNo + "]" + stateName;
            let message3 = $dataStates[menuDataStateArr[i]._No].message3;
            if (message3 != undefined){
                if (message3 != "") setText += "（" + message3 + "）";
            }
            this.SpriteStr(PNo_JotaiTxt + i, setText, ijoTextSize, ijoSetX, ijoSetY + ijoSpaceY * i, setOpacity);
            menuDataStateArr[i].PicNo = PNo_JotaiTxt + i;
            menuDataStateArr[i].Desc = MetaChecker($dataStates[menuDataStateArr[i]._No] , "説明" , "");
            menuDataStateArr[i].PosX = ijoSetX;
            menuDataStateArr[i].PosY = ijoSetY + ijoSpaceY * i;
            if (i == 3) break; 
        }
        if (menuDataStateArr.length > 4){
            this.SpriteStr(PNo_JotaiTxt + 4, "他 " + (menuDataStateArr.length - 4) + " 項目", 18,
                ijoSetX + 400, ijoSetY + ijoSpaceY * 4, setOpacity);
        }
    } else {
        this.SpriteStr(PNo_JotaiTxt + 0, "正常", ijoTextSize, ijoSetX, ijoSetY + ijoSpaceY * 0, setOpacity);
        this.SpriteStr(PNo_JotaiTxt + 1, "", ijoTextSize, ijoSetX, ijoSetY + ijoSpaceY * 1, setOpacity);
        this.SpriteStr(PNo_JotaiTxt + 2, "", ijoTextSize, ijoSetX, ijoSetY + ijoSpaceY * 2, setOpacity);
        this.SpriteStr(PNo_JotaiTxt + 3, "", ijoTextSize, ijoSetX, ijoSetY + ijoSpaceY * 3, setOpacity);
    }
}
Game_Interpreter.prototype.MenuMainData_DeckSelectBtnDraw = function (_SetOpi) {
    var _mainBtnAddStr = "a";
    if ($gameSwitches.value(SW_RentalOnlyFlg)) {
        _mainBtnAddStr = "c"; $gameSystem.SelDeck = 2;
    }
    this.SetSprite(PNo_DeckBtn + 0, MenuUIPath + "Data/D_DeckBtn1_" + _mainBtnAddStr, 419 + 166 * 0, 399, _SetOpi);
    this.SetSprite(PNo_DeckBtn + 1, MenuUIPath + "Data/D_DeckBtn2_" + _mainBtnAddStr, 419 + 166 * 1, 399, _SetOpi);
    if ($gameSwitches.value(SW_RentalOK)) {
        this.SetSprite(PNo_DeckBtn + 2, MenuUIPath + "Data/D_DeckBtn3_a", 419 + 166 * 2, 399, _SetOpi);
    }
    this.SetSprite(PNo_DeckBtn + $gameSystem.SelDeck,
        MenuUIPath + "Data/D_DeckBtn" + ($gameSystem.SelDeck + 1) + "_b",
        419 + 166 * $gameSystem.SelDeck, 399, _SetOpi);
}
const EnMenuDataMode = {
    Top: 0,
    State: 1
}
let menuData_Mode = EnMenuDataMode.Top; 
let Equip_ExitFlg = false;
Game_Interpreter.prototype.MenuDataUpdate = function () {
    if (menuSyogoDataFlg) {
        this.MenuEquip_SyogoUpdate();
        Equip_ExitFlg = true;
        return;
    }
    if (Equip_ExitFlg) {
        Equip_ExitFlg = false;
        this.DelSpriteSpan(PNo_ESyogTxt + 1, PNo_ESyogTxt + 3); 
        return;
    }
    if (menuDataFlame == 1) this.MenuDataView();
    switch (menuData_Mode){
        case EnMenuDataMode.Top:    
            this.MainMenuData_TopUpdate();
            break;
        case EnMenuDataMode.State:  
            this.MainMenuData_StateUpdate();
    }
    menuDataFlame++;
}
let MainMenuData_TopUpdate_OffFlame = 0;
Game_Interpreter.prototype.MainMenuData_TopUpdate = function () {
    if (Menu_Data_VirusMode) { 
        this.Menu_Data_VirusMode_Update();
        return;
    }
    if (MainMenuData_TopUpdate_OffFlame > 0) {
        MainMenuData_TopUpdate_OffFlame--;
        return;
    }
    let ckPicArr = [PNo_AllBtn , PNo_VirusBtn , PN_RentDeckCng , PNo_SyogTxt,PN_DtSyogo,
        PNo_DeckBtn + 0, PNo_DeckBtn + 1, PNo_DeckBtn + 2];
    let overPicNo = overPointerSpCkArr(ckPicArr);
    this.DelSpriteSpan(PN_MnReric , PN_MnReric + 2);
    this.SpriteCngColorArr(ckPicArr); 
    switch (overPicNo) {
        case PNo_AllBtn: 
            this.SpriteCngColor(PNo_AllBtn, [100, 100, 100, 0])
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                menuData_Mode = EnMenuDataMode.State;
                Menu_EditLayer++;
                this.SpriteCngColor(PNo_AllBtn); 
                this.MainMenuData_StateView(true);
            }
            break;
        case PNo_VirusBtn:
            this.SpriteCngColor(PNo_VirusBtn, [100, 100, 100, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                this.Menu_Data_VirusMode_View();
                return;
            }
            break;
        case PN_RentDeckCng:
            this.SpriteCngColor(PN_RentDeckCng, [100, 100, 100, 0])
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                this.Menu_Data_RentDeckMode_View();
                Menu_EditLayer = 1; 
                return;
            }
            break;
        case PN_DtSyogo: 
            this.SpriteCngColor(PN_DtSyogo, [100, 100, 100, 0])
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                menuSyogoDataFlg = true;
                this.SetSprite(PN_SyogoStrBack, MenuUIPath + "Data/PN_SyogoStrBack", 0, 0);
                Menu_EditLayer = 1; 
                this.MenuEquip_SyogoView();
            }
            break;
        case PNo_SyogTxt: 
            let setX = 180; let setY = 387;
            let setTextArr = $dataArmors[menu装備No].description.split('\n');
            if (setTextArr.length > 1) {
                this.SetSprite(PN_MnReric, BtlPicPath + "PN_BCSetuWaku", setX, setY);
                setTextArr[1] = setTextArr[1].replace("<n>" , "\n");
                this.SpriteStr(PN_MnReric + 1, setTextArr[1], 22, setX + 13, setY + 15);
            }
            let rericNo = MetaChecker($dataArmors[menu装備No] , "Reric" , -1);
            if (rericNo != -1){
                let rericItemData = $dataItems[Number(rericNo)];
                this.SetSprite(PN_MnReric, BtlPicPath + "PN_BCSetuWaku", setX, setY);
                let ckDescriptionArr = rericItemData.description.split("\n");
                let iconNo = rericItemData.iconIndex;
                let drawText = " " + "\\I[" + iconNo + "] " + rericItemData.name;
                this.SpriteStr(PN_MnReric + 1, drawText, 22, setX + 13, setY + 15);
                for (let j = 0; j <= ckDescriptionArr.length - 1; j++) {
                    this.SpriteStr(PN_MnReric + 2 + j, ckDescriptionArr[j], 19, setX + 22, setY + 26 + (27 * (j + 1)));
                }
            }
            break;
    }
    switch (overPicNo) {
        case PNo_DeckBtn + 0: 
        case PNo_DeckBtn + 1:
        case PNo_DeckBtn + 2:
            if ($gameSwitches.value(SW_RentalOnlyFlg)) return;
            this.MenuData_簡易DeckViewDraw(overPicNo - PNo_DeckBtn);
            this.SpriteCngColor(overPicNo, [100, 100, 100, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                let picNo = overPicNo - PNo_DeckBtn;
                $gameSystem.SelDeck = picNo;
                $gameVariables.setValue(VN_UseDeckName , 0); 
                this.MenuMainData_DeckSelectBtnDraw(255); 
            }
            break;
        default:
            this.DelSpriteSpan(PN_SetuWaku, PN_T_Setu + 22);
            break;
    }
    let notDrawFlg = true;
    for (let i = 0; i <= menuDataStateArr.length - 1; i++) {
        let ckPicNo = menuDataStateArr[i].PicNo;
        let drawText = menuDataStateArr[i].Desc;
        if (drawText == "") continue;
        if (ckPicNo > 0) {
            let setX = menuDataStateArr[i].PosX - 62;
            let setY = menuDataStateArr[i].PosY - 89;
            if (overPointerSpCk(ckPicNo)) {
                notDrawFlg = false;
                this.SetSprite(PN_DataIjoWin , BtlPicPath + "BCard_SetuWin" , setX - 27 , setY - 19);
                this.SpriteStr(PN_DataIjoTxt, drawText, 20, setX, setY);
            }
        }
    }
    if (notDrawFlg) this.DelSpriteSpan(PN_DataIjoWin , PN_DataIjoTxt);
}
const VN_UseDeckName = 1095;
let VN_UseDeckName_NUpdateSc = Game_Interpreter.prototype.NUpdateSc;
Game_Interpreter.prototype.NUpdateSc = function () {
    VN_UseDeckName_NUpdateSc.call(this);
    if ($gameVariables.value(VN_UseDeckName) == 0) {
        switch ($gameSystem.SelDeck) {
            case 0: $gameVariables.setValue(VN_UseDeckName, "Deck-A"); break;
            case 1: $gameVariables.setValue(VN_UseDeckName, "Deck-B"); break;
            case 2: $gameVariables.setValue(VN_UseDeckName, "Rental"); break;
        }
    }
}
let befMenuDataDrawDeckNo = -1; 
Game_Interpreter.prototype.MenuData_簡易DeckViewDraw = function (deckNo) {
    if (befMenuDataDrawDeckNo != deckNo) { 
        befMenuDataDrawDeckNo = deckNo;
        this.DelSpriteSpan(PN_SetuWaku, PN_T_Setu + 22); 
    }
    let setX = 369 + 166 * deckNo;
    let setY = 120;
    this.SetSprite(PN_SetuWaku, MenuUIPath + "PN_SetuWaku", setX, setY);
    this.DeckCardIconDraw(PN_T_Setu , $gameSystem.DeckArr[deckNo] , setX, setY);
}
Game_Interpreter.prototype.EquipDeckIconDraw = function (underFlg) {
    var underFlg = typeof underFlg !== 'undefined' ? underFlg : false;
    let setX = 1123;
    let setY = 165;
    if (underFlg) {
        setX = 606;
        setY = 380;
    }
    this.SetSprite(PN_SetuWaku, MenuUIPath + "PN_EquipDeckWin", setX, setY);
    this.DeckCardIconDraw(PN_T_Setu , $gameSystem.DeckArr[$gameSystem.SelDeck] , setX, setY);
}
Game_Interpreter.prototype.EquipDeckIconDell = function () {
    this.DelSpriteSpan(PN_SetuWaku, PN_T_Setu + 10); 
}
Game_Interpreter.prototype.DeckCardIconDraw = function (setPicNo , setDeckNoArr , setPosX , setPosY , picFlg) {
    var picFlg = typeof picFlg !== 'undefined' ? picFlg : false;
    let deckNoArr = []; 
    let setX = setPosX;
    let setY = setPosY;
    for (let i = 0; i <= setDeckNoArr.length - 1; i++) {
        let newFlg = true;
        for (let j = 0; j <= deckNoArr.length - 1; j++) {
            if (deckNoArr[j]._No == setDeckNoArr[i]) {
                deckNoArr[j]._Cnt++;
                newFlg = false;
            }
        }
        if (newFlg) {
            deckNoArr.push(new DeckCardData(setDeckNoArr[i], 1));
        }
    }
    let setCardStr = "";
    let setNostr = "";
    let cardIconTexts = [];
    let noIconTexts = [];
    for (let i = 0; i <= deckNoArr.length - 1; i++) {
        setCardStr += "\\I[" + $dataWeapons[deckNoArr[i]._No].iconIndex + "] ";
        let _piconNo = deckNoArr[i]._Cnt;
        if (_piconNo >= 11)  _piconNo = 11;
        let SerIjoTc = _piconNo + Int1IcoNo - 1;
        setNostr += "\\I[" + SerIjoTc + "] ";
        if (i % 5 == 4) {
            cardIconTexts.push(setCardStr);
            noIconTexts.push(setNostr);
            setCardStr = "";
            setNostr = "";
        }
    }
    cardIconTexts.push(setCardStr);
    noIconTexts.push(setNostr);
    for (let i = 0; i <= cardIconTexts.length - 1; i++) {
        if (picFlg) {
            this.SetPicStr(setPicNo + i, cardIconTexts[i], 25, setX + 18, setY + 33 + (51 * i));
            this.SetPicStr(setPicNo + 5 + i, noIconTexts[i], 25, setX + 8, setY + 39 + (51 * i));
        } else {
            this.SpriteStr(setPicNo + i, cardIconTexts[i], 25, setX + 18, setY + 33 + (51 * i));
            this.SpriteStr(setPicNo + 5 + i, noIconTexts[i], 25, setX + 8, setY + 39 + (51 * i));
        }
    }
}
let menuDataStateArr2 = [];
let menuDataStateDelPicArr = [];
let menuDataStateBasePos = new Pos2D(244, 168); 
let menuDataStateScroll = new N_Scroll(MenuUIPath + "Data/D_IjoScBar", 444, PN_IjoScBar,
    menuDataStateBasePos._x + 557, menuDataStateBasePos._y + 61);
menuDataStateScroll.ViewCount = 12; 
Game_Interpreter.prototype.MainMenuData_StateView = function (fadeInFlg) {
    fadeInFlg = typeof fadeInFlg !== 'undefined' ? fadeInFlg : false;
    let setOpacity = 255;
    if (fadeInFlg) {
        setOpacity = 0;
        menuDataStateScroll.ZureNo = 0;
    }
    ViewSpriteArr_Reset();
    menuDataStateScroll.ItemCount = menuDataStateArr.length - 1;
    D_Text_Cng_font = "Makinas"; 
    this.SetSprite(PN_IjoBase, MenuUIPath + "Data/D_IjoBase", menuDataStateBasePos._x, menuDataStateBasePos._y, setOpacity);
    this.ScrollView(menuDataStateScroll, 255);
    this.SetSprite(PN_IjoClose, MenuUIPath + "Data/D_IjoClose",
        menuDataStateBasePos._x + 362, menuDataStateBasePos._y + 512, setOpacity);
    let stateTextSize = 23;
    let stateSpaceY = 34;
    menuDataStateArr2 = menuDataStateArr.slice();
    for (let i = 0; i <= menuDataStateArr2.length - 1; i++) {
        let zureNo = i + menuDataStateScroll.ZureNo;
        let stateNo = menuDataStateArr2[zureNo]._No;
        let stateName = $dataStates[stateNo].name;
        let setText = "\\C[" + menuDataStateArr2[zureNo]._ColNo + "]" + stateName;
        let message3 = $dataStates[stateNo].message3;
        menuDataStateArr2[zureNo].PicNo = PN_IjoTxt + i;
        menuDataStateArr2[zureNo].Desc = MetaChecker($dataStates[stateNo] , "説明" , "");
        menuDataStateArr2[zureNo].PosX = menuDataStateBasePos._x + 42;
        menuDataStateArr2[zureNo].PosY = menuDataStateBasePos._y + 67 + (stateSpaceY * i);
        if (message3 != "") setText += "（" + message3 + "）";
        this.SpriteStr(PN_IjoTxt + i, setText, stateTextSize,
            menuDataStateBasePos._x + 42, menuDataStateBasePos._y + 67 + (stateSpaceY * i), setOpacity);
        if (i == menuDataStateScroll.ViewCount) break; 
    }
    this.DelSprite(PN_IjoScTop);
    this.DelSprite(PN_IjoScBtm);
    if (menuDataStateScroll.ZureNo != 0) {
        this.SetSpriteC(PN_IjoScTop, MenuUIPath + "Data/D_IjoScTop",
            menuDataStateBasePos._x + 283, menuDataStateBasePos._y + 36, setOpacity);
    }
    if (menuDataStateArr2.length - 1 > menuDataStateScroll.ViewCount + menuDataStateScroll.ZureNo) {
        this.SetSpriteC(PN_IjoScBtm, MenuUIPath + "Data/D_IjoScBtm",
            menuDataStateBasePos._x + 283, menuDataStateBasePos._y + 524, setOpacity);
    }
    menuDataStateDelPicArr = ViewSpriteArr.slice(); 
    for (let i = 0; i <= menuDataStateScroll.ViewCount - 1; i++) {
        menuDataStateDelPicArr.push(PN_IjoTxt + i);
    }
    D_Text_Cng_font = ""; 
    for (let i = 0; i <= ViewSpriteArr.length - 1; i++) {
        this.MoveSprite(ViewSpriteArr[i], true, true, 10, 255, true, true);
    }
}
Game_Interpreter.prototype.MainMenuData_StateUpdate = function () {
    let ckPicArr = [PN_IjoClose, PN_IjoScTop, PN_IjoScBtm];
    let overPicNo = overPointerSpCkArr(ckPicArr);
    for (let i = 0; i <= ckPicArr.length - 1; i++) { this.SpriteCngColor(ckPicArr[i]); }
    if (overPicNo != -1) this.SpriteCngColor(overPicNo, [100, 100, 100, 0]);
    switch (overPicNo) {
        case PN_IjoClose:
            this.SpriteCngColor(PN_IjoClose, [100, 100, 100, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                menuData_Mode = EnMenuDataMode.Top;
                Menu_EditLayer--; 
                this.DelSpriteArr(menuDataStateDelPicArr);
                this.DelPict(PN_IjoScBar);
            }
            break;
        case PN_IjoScTop:
            this.SpriteCngColor(PN_IjoScTop, [100, 100, 100, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                this.MainMenuData_StateScrollUp();
            }
            break;
        case PN_IjoScBtm:
            this.SpriteCngColor(PN_IjoScBtm, [100, 100, 100, 0]);
            if (TouchInput.isTriggered()) {
                SoundManager.playOk(); 
                this.MainMenuData_StateScrollDown();
            }
            break;
    }
    let notDrawFlg = true;
    for (let i = 0; i <= menuDataStateArr2.length - 1; i++) {
        let ckPicNo = menuDataStateArr2[i].PicNo;
        let drawText = menuDataStateArr2[i].Desc;
        if (overPointerSpCk(ckPicNo) && drawText != "") {
            let setX = menuDataStateArr2[i].PosX - 62;
            let setY = menuDataStateArr2[i].PosY - 89;
            this.SetPict(PN_DataIjoWin , BtlPicPath + "BCard_SetuWin" , setX - 27 , setY - 19);
            this.SetPicStr(PN_DataIjoTxt, drawText, 20, setX, setY);
            notDrawFlg = false;
        }
    }
    if (notDrawFlg) {
        this.DelPictSpan(PN_DataIjoWin , PN_DataIjoTxt);
    }
    if (Input.isTriggered('menu') || TouchInput.isCancelled()) {
        this.DelSpriteArr(menuDataStateDelPicArr);
        this.DelPict(PN_IjoScBar);
        menuData_Mode = EnMenuDataMode.Top;
        this.DrawMenuDataState(255);
    }
    if (TouchInput.wheelY > 0) {
        this.MainMenuData_StateScrollDown();
    } else if (TouchInput.wheelY < 0) {
        this.MainMenuData_StateScrollUp();
    }
}
Game_Interpreter.prototype.MainMenuData_StateScrollUp = function ()
{
    if (menuDataStateScroll.ZureNo <= 0) return;
    menuDataStateScroll.ZureNo--;
    this.MainMenuData_StateView();
}
Game_Interpreter.prototype.MainMenuData_StateScrollDown = function () {
    if (menuDataStateScroll.ZureNo + menuDataStateScroll.ViewCount > menuDataStateArr.length) return;
    menuDataStateScroll.ZureNo++;
    this.MainMenuData_StateView();
}
let Menu_Data_RentDeckMode = false;
let Menu_Data_RentDeckPicArr = [];
let Menu_Data_RentDeckBefPicNo = -1;
Game_Interpreter.prototype.Menu_Data_RentDeckMode_View = function () {
    Menu_Data_RentDeckMode = true;
    MeneExitOkFlg = false;   
    Menu_Data_RentDeckPicArr = [];
    Menu_Data_RentDeckBefPicNo = -2;
    this.SetPict(PN_RentSelBase , MenuUIPath + "Data/PN_RentSelBase", 0, 0);
    this.Menu_Data_RentDeckMode_TextDraw(-1);
}
Game_Interpreter.prototype.Menu_Data_RentDeckMode_TextDraw = function (selectNo) {
    for (let i = 0; i < $gameVariables.value(VN_RentDeckCnt); i++) {
        let drawText = RentDeckNames[i];
        if ($gameVariables.value(VN_RentDeckSelectNo) == i + 1) {
            drawText = SCol.Yel + drawText;
        }
        else if (i == selectNo) {
            drawText = SCol.Ppr + drawText;
        }
        this.SetPicStr(PN_RentSelText + i , drawText , 26 , 292 , 203 + 45 * i);
        Menu_Data_RentDeckPicArr.push(PN_RentSelText + i);
    }
}
Game_Interpreter.prototype.Menu_Data_RentDeckMode_Update = function () {
    Menu_EditLayer = 2; 
    let picOverNo = overPointerCkArr(Menu_Data_RentDeckPicArr);
    if (picOverNo != -1) {
        picOverNo = picOverNo - PN_RentSelText;
        if (TouchInput.isTriggered()) {
            this.DelPictSpan(PN_RentSelText , PN_RentSelText + 7);
            $gameVariables.setValue(VN_RentDeckSelectNo , picOverNo + 1); 
            this.Menu_Data_RentDeckMode_TextDraw(Menu_Data_RentDeckBefPicNo);
            RentalDeckSetting();
            SoundManager.playOk(); 
            return;
        }
    }
    if (Menu_Data_RentDeckBefPicNo != picOverNo) { 
        Menu_Data_RentDeckBefPicNo = picOverNo; 
        this.Menu_Data_RentDeckMode_TextDraw(Menu_Data_RentDeckBefPicNo);
        SoundManager.playCursor(); 
        if (picOverNo == -1) {
            picOverNo = $gameVariables.value(VN_RentDeckSelectNo) - 1;
        }
        let resetArr = $Nupu_GameSetting.rentalDecks[picOverNo].deck.split(',');
        let deckArr = [];
        for (let i = 0; i < resetArr.length; i++) {
            deckArr.push(Number(resetArr[i]));
        }
        this.DelPictSpan(PN_RentSelDIcon , PN_RentSelDeckTxt);
        this.DeckCardIconDraw(PN_RentSelDIcon , deckArr , 688, 98 + 97 , true);
    }
    if (TouchInput.isCancelled()) {
        this.Menu_Data_RentDeckMode_Exit();
        return;
    }
}
Game_Interpreter.prototype.Menu_Data_RentDeckMode_Exit = function () {
    Menu_Data_RentDeckMode = false;
    MeneExitOkFlg = true;   
    this.DelPictSpan(PN_RentSelBase , PN_RentSelDeckTxt);
}
let Checkウィルス対策 = function (No) {
    return $gameSystem.AntiVirusNos.indexOf(No) != -1;
}
let Menu_Data_VirusMode_StartMenuLayer = -1;
let Menu_Data_VirusMode = false;
let ItmNo_ウィルス対策 = 286;
let Menu_Data_VirusMode_PicArr = [];
let Menu_Data_VirusMode_Initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () { 
    Menu_Data_VirusMode_Initialize.call(this);
    this.AntiVirusNos = []; 
};
Game_Interpreter.prototype.Menu_Data_VirusMode_View = function () {
    if ($gameSystem.AntiVirusNos == undefined) $gameSystem.AntiVirusNos = [];
    Menu_Data_VirusMode = true;
    Menu_EditLayer++;
    Menu_Data_VirusMode_StartMenuLayer = Menu_EditLayer;
    this.SetSprite(PNo_VirusBase, MenuUIPath + "Data/PNo_VirusBase", 0, 0);
    this.Menu_Data_VirusMode_Draw();
    $gameActors.actor(1).addParam(0, $gameSystem.AntiVirusNos.length * 10);
}
Game_Interpreter.prototype.Menu_Data_VirusMode_Draw = function () {
    var viewCount = 0;
    Menu_Data_VirusMode_PicArr = [];
    for (let i = 0; i < 12; i++) {
        Menu_Data_VirusMode_PicArr.push(PNo_VirusCk + i);
        Menu_Data_VirusMode_PicArr.push(PNo_VirusTxt + i);
        var item = $dataItems[ItmNo_ウィルス対策 + i]; 
        if ($gameParty.hasItem(item)) {
            var setPicName = "Data/PNo_VirusCk1";
            if ($gameSystem.AntiVirusNos.indexOf(i) != -1) setPicName = "Data/PNo_VirusCk2";
            this.SetSprite(PNo_VirusCk + i, MenuUIPath + setPicName, 386, 176 + viewCount * 45);
            this.SpriteStr( PNo_VirusTxt + i , item.name , 28 , 436 , 178 + viewCount * 45);
            viewCount++;
        }
    }
}
Game_Interpreter.prototype.Menu_Data_VirusMode_Update = function () {
    var overPicNo = overPointerSpCkArr(Menu_Data_VirusMode_PicArr);
    this.SpriteCngColorArr(Menu_Data_VirusMode_PicArr)
    if (overPicNo != -1) {
        if (PNo_VirusTxt <= overPicNo) overPicNo -= PNo_VirusTxt;
        else overPicNo -= PNo_VirusCk;
        console.log("overPicNo" + overPicNo);
        this.SpriteCngColor( PNo_VirusCk + overPicNo , [100,100,50,0]);
        this.SpriteCngColor( PNo_VirusTxt + overPicNo , [0,0,-100,0]);
        if (TouchInput.isTriggered()) {
            var index = $gameSystem.AntiVirusNos.indexOf(overPicNo);
            if (index != -1) $gameSystem.AntiVirusNos.splice(index , 1);
            else $gameSystem.AntiVirusNos.push(overPicNo);
            this.Menu_Data_VirusMode_Draw();
        }
    }
    if (Menu_EditLayer != Menu_Data_VirusMode_StartMenuLayer) {
        Menu_Data_VirusMode = false;
        this.DelSpriteSpan(PNo_VirusBase , PNo_VirusTxt + 11);
        Menu_Data_VirusMode_StartMenuLayer = -1;
        $gameActors.actor(1).addParam(0, $gameSystem.AntiVirusNos.length * -10);
        this.MenuDataView(false);
    }
}
