Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Errr....

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Posts
    197
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Points: 1,077, Level: 17
    Points: 1,077, Level: 17
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    3 months registeredThree Friends1000 Experience Points

    Errr....

    What the hell.

      Spoiler: Wuh 
    //;# MainWindow.tjs - KAG ƒƒCƒ“ƒEƒBƒ“ƒhƒE
    //;# Copyright (C)2001-2005, W.Dee and contributors ‰ü•ÏE”z•z‚ÍŽ*—R‚Å‚·
    //;<<'END_OF_TJS_SCRIPT';

    // ‚±‚̃XƒNƒŠƒvƒg‚Í—LŒø‚È perl5 ƒXƒNƒŠƒvƒg‚Å‚à‚ ‚é

    class KAGWindow extends Window
    {
    // KAG ‚̃EƒBƒ“ƒhƒE ƒNƒ‰ƒX
    // KAG ‚Ì“®ì‚̃ƒCƒ“‚È•”•ª‚Í‚±‚±‚É‹Lq‚µ‚Ä‚ ‚é

    // ˆÈ‰º‚Ì‚¤‚¿A/*C*/ ‚̂‚­•Ï”‚́A––’[‚Ì perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚Ä
    // Ž*“®“I‚Éžx‚ɃRƒs[‚³‚ê‚éƒR[ƒh‚ª¶¬‚³‚ê‚é•Ï”

    var scWidth = 640; // ‰æ–ʉ¡•
    var scHeight = 480; // ‰æ–ʏc•

    var aboutWidth = 320; // u‚±‚̃\ƒtƒg‚ɂ‚¢‚āvƒEƒBƒ“ƒhƒE‚̉¡•
    var aboutHeight = 200; // “¯c•

    var isFirstProcess = true; // ˆê”ԍŏ‰‚Ì process ‚̌Ăяo‚µ‚*‚Ç‚¤‚*

    var freeSaveDataMode = false; // žx‚ðƒƒjƒ…[ƒo[‚È‚Ç‚ÅŠÇ—‚¹‚¸‚ɁAŒÂ•Ê‚̃tƒ@ƒCƒ‹‚Æ‚µ‚ÄŠÇ—‚·‚é
    var saveThumbnail = false; // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶‚·‚é‚*‚Ç‚¤‚*
    var thumbnailWidth = 133; // ƒTƒ€ƒlƒCƒ‹‚̉¡•
    var thumbnailDepth = 8; // ƒTƒ€ƒlƒCƒ‹‚ÌBMPƒ‚[ƒhB8‚*24
    // ƒTƒ€ƒlƒCƒ‹‚Ì ƒtƒ‹ƒJƒ‰[‰»‚¨‚æ‚уTƒCƒYƒtƒŠ[‰»‚̃pƒbƒ`‚Í
    // ‚ä‚ñŽ‚*‚ç‚¢‚½‚¾‚«‚Ü‚µ‚½B
    // ‚±‚̏ê‚ðŽØ‚è‚Ä‚¨—ç\‚µã‚°‚Ü‚·B


    var snapshotLayer = void; // ‰æ‘œ‚̃XƒiƒbƒvƒVƒ‡ƒbƒg‚ðˆêŽž“I‚É•Û‘¶‚·‚郌ƒCƒ„
    var snapshotLockCount = 0; // ƒƒbƒNƒJƒEƒ“ƒg

    var lastSaveDataNameGlobal = ""; // ÅŒã‚É•Û‘¶‚µ‚½ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚ł̃tƒ@ƒCƒ‹–¼
    /*C*/var lastSaveDataName = ""; // ÅŒã‚É•Û‘¶‚µ‚½ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚ł̃tƒ@ƒCƒ‹–¼

    var saveDataLocation = "savedata"; // ƒZ[ƒuƒf[ƒ^•Û‘¶êŠ

    var saveDataID = "00000000-0000-0000-0000-000000000000"; // ƒZ[ƒuƒf[ƒ^‚Ì ID

    var readOnlyMode = false; // “ǂݍž‚ݐê—pƒ‚[ƒh(ƒf[ƒ^‚ðƒfƒBƒXƒN‚ɏ‘‚*‚È‚¢)
    var dataName = "data"; // ƒZ[ƒuƒf[ƒ^–¼
    var saveDataMode = ""; // ƒf[ƒ^•Û‘¶ƒ‚[ƒh( "c" ‚ň͆‰» )

    var recordHistoryOfStore = 0; // ’ʉߗš—ð‚ð‹L˜^‚·‚é‚*‚Ç‚¤‚*
    // 0 = Ž*“®“I‚É‚Í‹L˜^‚µ‚È‚¢ 1 = •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚²‚Æ
    // 2 = ‘I‘ðŽˆ ( @s ƒ^ƒO ) ‚²‚Æ
    var maxHistoryOfStore = 5; // ’ʉߋL˜^‚̍ő吔
    var historyOfStore = []; // ’ʉߗš—ðƒf[ƒ^
    var nextRecordHistory = false;
    // ŽŸ‚Ì•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹’ʉߎž‚ÉŒ»Ý‚̏î•ñ‚ð•Û‘¶‚·‚é‚*‚Ç‚¤‚*

    var stablePosibility = false;
    // žx‚ð•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹ŠÔ‚Å stable ‚É‚È‚é‰Â”\«‚ª‚ ‚é‚*‚Ç‚¤‚*

    var fullScreened = false; // Œ»Ýƒtƒ‹ƒXƒNƒŠ[ƒ“‚*‚Ç‚¤‚*

    var isMain = true; // ‚±‚ꂪƒƒCƒ“ƒEƒBƒ“ƒhƒE‚*‚Ç‚¤‚*

    var askOnClose = true; // I—¹Žž‚ɏI—¹‚·‚é‚*‚ðƒ†[ƒU‚É•·‚­‚*‚Ç‚¤‚*

    var helpFile = ""; // uƒwƒ‹ƒv > –ÚŽŸv‚ÅŠJ‚­ƒtƒ@ƒCƒ‹

    var quakeTimer; // quake —p‚̃^ƒCƒ}
    var defaultQuakeTimeInChUnit = false;
    /*C*/var quaking = false; // —h‚ê‚Ä‚¢‚é‚*
    /*C*/var quakeEndTick = 0; // —h‚ê‚ðI—¹‚³‚¹‚é tick
    /*C*/var quakeHorzMax = 0; // ‰¡U•
    /*C*/var quakeVertMax = 0; // cU•
    /*C*/var quakePhase = 0;

    var chDefaultAntialiased; // •¶Žš‚ɃAƒ“ƒ`ƒGƒCƒŠƒAƒX‚ð‚*‚¯‚é‚*‚Ç‚¤‚*
    var chDefaultFace; // •¶Žš‚̃fƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒg

    var initialMessageLayerVisible = true;

    var historyLayer; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„
    /*C*/var historyWriteEnabled = true; // ƒƒbƒZ[ƒWƒŒƒCƒ„‚É•¶Žš‚ðo—Í‚·‚é‚*
    /*C*/var historyEnabled = true; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦‰Â”\‚*
    var historyShowing = false; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦’†‚*
    var lastHistoryHiddenTick = 0; // ÅŒã‚É—š—ðƒŒƒCƒ„‚ª”ñ•\Ž¦‚É‚È‚Á‚½‚Æ‚«‚Ì tick

    /*C*/var numCharacterLayers = 0; // ‘OŒiƒŒƒCƒ„‚̐”
    /*C*/var numMessageLayers = 1; // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̐”
    var fore = %[]; // •\ƒŒƒCƒ„
    var back = %[]; // — ƒŒƒCƒ„

    var scPositionX = %[]; // —§‚¿ŠG‚Ì’†SÀ•W(X)

    var tempLayer = void; // ˆêŽž“I‚ȃŒƒCƒ„

    var lineBreak; // s‘Ò‚¿—pƒAƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„
    var pageBreak; // ƒy[ƒW‘Ò‚¿—pƒOƒŠƒt‚̃Aƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„
    var clickWaiting = false; // ƒNƒŠƒbƒN‘Ò‚¿‚*‚Ç‚¤‚*

    var mainConductor; // ƒƒCƒ“‚̃Rƒ“ƒ_ƒNƒ^
    var extraConductor; // —\”õ‚̃Rƒ“ƒ_ƒNƒ^
    var conductor; // Œ»Ý‚̃Rƒ“ƒ_ƒNƒ^
    var usingExtraConductor = false; // —\”õ‚̃Rƒ“ƒ_ƒNƒ^‚ðŽg—p’†‚*‚Ç‚¤‚*
    var onExtraConductorReturn; // extraConductor ‚*‚ç’ʏí‚̃Rƒ“ƒ_ƒNƒ^‚É–ß‚é‚Æ‚«‚É‚æ‚Ԋ֐”

    var tagHandlers; // ƒ^ƒO‚̃nƒ“ƒhƒ‰ŒQŽ«‘”z—ñ

    var saveMacros = true; // ƒ}ƒNƒ‚ðžx‚É•Û‘¶‚·‚é‚*‚Ç‚¤‚*

    var current; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„
    /*C*/var currentNum; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„”ԍ†
    /*C*/var currentPage; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̃y[ƒW(•\0/— 1)
    /*C*/var currentWithBack = false; // — ‰æ–Ê‚É‚à•¶Žš‚ð•`‰æ‚·‚é‚*‚Ç‚¤‚*

    var bgm; // BGM ƒIƒuƒWƒFƒNƒg

    var numSEBuffers = 1; // Œø‰Ê‰¹ƒoƒbƒtƒ@‚̐”
    var se = []; // Œø‰Ê‰¹ƒoƒbƒtƒ@ƒIƒuƒWƒFƒNƒg

    var numMovies = 1; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg”
    // var movie; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg
    var movies = []; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg

    var transCount; // Œ»Ýis’†‚̃gƒ‰ƒ“ƒWƒVƒ‡ƒ“‚̐”
    var moveCount; // Œ»Ýis’†‚ÌŽ*“®ˆÚ“®‚̐”

    var chSpeeds = %[
    fast: 10, // u‚‘¬v•¶Žš•\Ž¦ƒXƒs[ƒh
    normal: 30, // u•’ʁv•¶Žš•\Ž¦ƒXƒs[ƒh
    slow: 50, // u’x‚¢v•¶Žš•\Ž¦ƒXƒs[ƒh
    ];

    var userChSpeed = 30; // ƒ†[ƒU‚Ì‘I‚ñ‚¾•¶Žš•\Ž¦ƒXƒs[ƒh
    var userCh2ndSpeed = -1; // ƒ†[ƒU‚Ì‘I‚ñ‚¾ Šù“Ç•”•ª‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh
    var chNonStopToPageBreak = false; // ƒy[ƒW––‚܂ňê‹C‚ɓǂݐi‚Þ‚* ( l ƒ^ƒO‚𖳎‹‚·‚é‚* )
    var ch2ndNonStopToPageBreak = false; // Šù“Ç‚Ì•”•ª‚Ńy[ƒW––‚܂ňê‹C‚ɓǂݐi‚Þ‚*
    /*C*/var chUserMode = true; // •¶Žš•\Ž¦‘¬“x‚ÍŒ»Ýƒ†[ƒU‚Ì‘I‚ñ‚¾‚à‚Ì‚*
    /*C*/var chSpeed = 30; // Œ»Ý‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh
    /*C*/var actualChSpeed = chSpeed; // ŽÀÛ‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh

    /*C*/var beforeNoWaitActualChSpeed; // nowait ‚É“ü‚é‘O‚Ì actualChSpeed
    /*C*/var beforeNoWaitChUserMode; // nowait ‚É“ü‚é‘O‚Ì chUserMode

    /*C*/var clickSkipEnabled = true; // ƒNƒŠƒbƒNƒXƒLƒbƒv‚ª—LŒø‚*
    /*C*/var nextSkipEnabled = true; // ŽŸ‚Ì‘I‘ðŽˆ(/–¢“Ç)‚܂Ői‚Þ‚ª—LŒø‚*
    var skipMode = 0; // ƒXƒLƒbƒv‚̃‚[ƒh
    // 0=ƒXƒLƒbƒv‚È‚µ, 1=ƒNƒŠƒbƒN‘Ò‚¿‹L†‚Ü‚Å, 2=‰üƒy[ƒW‘Ò‚¿‹L†‚Ü‚Å, 3=ŽŸ‚Ì’âŽ~‚Ü‚Å
    // 4=‘‘—‚è
    var autoMode = false; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚*‚Ç‚¤‚*
    var autoModePageWait = 350; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒhŽž‚̉üƒy[ƒWŽž‚̃EƒFƒCƒg
    var autoModeLineWait = 50; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒhŽž‚̍sƒNƒŠƒbƒN‘Ò‚¿Žž‚̃EƒFƒCƒg
    // ã‚Ì“ñ‚‚́Aƒm[ƒEƒFƒCƒg‚É‚µ‚½‚¢ê‡‚Í 0 ‚Å‚Í‚È‚­‚Ä -4 ‚ðŽw’è‚·‚邱‚Æ

    var skipKeyRepressed = false; // return ‚ ‚é‚¢‚Í space ƒL[ ( f ƒL[‚È‚Ç‚Å‚Í‚È‚¢ )
    // ‚ª‰Ÿ‚³‚ê‚é‚Æ true ‚É‚È‚é ( ƒXƒLƒbƒv‰ðœŽž‚É false

    var autoModePageWaits = %[
    fast: 400, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu’Z‚¢v
    faster: 700, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu‚â‚â’Z‚¢v
    medium: 1000, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu•’ʁv
    slower: 1300, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu‚â‚â’x‚¢v
    slow: 2000, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu’x‚¢v
    ];

    var autoModeLineWaits = %[
    fast: 180, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu’Z‚¢v
    faster: 240, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu‚â‚â’Z‚¢v
    medium: 300, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu•’ʁv
    slower: 360, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu‚â‚â’x‚¢v
    slow: 500, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu’x‚¢v
    ];

    /*C*/var canCancelSkipByClick = true; // ƒNƒŠƒbƒN‚É‚æ‚èƒXƒLƒbƒvó‘Ԃ̃Lƒƒƒ“ƒZƒ‹‚ª‚Å‚«‚é‚*

    /*C*/var autoWCEnabled = false; // Ž*“®ƒEƒFƒCƒg‚ª—LŒø‚*‚Ç‚¤‚*
    /*C*/var autoWCChars = ""; // Ž*“®ƒEƒFƒCƒg‚ð‚*‚¯‚镶Žš
    var autoWCWaits = []; // Ž*“®ƒEƒFƒCƒg‚̃EƒFƒCƒg

    var timeOrigin; // resetWait ‚Őݒ肳‚ꂽŽžŠÔŒ´“_
    var lastWaitTime; // wait mode=until ‚ÅŽÀÛ‚É‘Ò‚Á‚½ŽžŠÔ

    var stableHandlers = []; // ƒVƒXƒeƒ€‚ªˆÀ’è(ƒNƒŠƒbƒN‘Ò‚¿/’âŽ~)‚µ‚½‚Æ‚«‚ɌĂ΂ê‚é
    var runHandlers = []; // ƒVƒXƒeƒ€‚ª‘–‚èŽn‚ß‚½‚Æ‚«‚ɌĂ΂ê‚é
    var inStable = true; // ˆÀ’肵‚Ä‚¢‚é‚Æ‚«(‘–s’†‚Å‚È‚¢‚Æ‚«) true
    var inSleep = false; // s ƒ^ƒO‚Å’âŽ~‚µ‚Ä‚¢‚é‚Æ‚« true

    var updateBeforeCh = 0; // •¶Žš‚ð•`‰æ‚·‚é‘O‚É‚¢‚Á‚½‚ñ‰æ–Ê•`‰æ‚É“ü‚é‚*‚Ç‚¤‚*‚̃JƒEƒ“ƒg

    var messageLayerHiding = false; // ƒ†[ƒU‚É‚æ‚胁ƒbƒZ[ƒWƒŒƒCƒ„‚ª‰B‚³‚ê‚Ä‚¢‚é‚*

    /*C*/var rightClickEnabled = true; // ‰EƒNƒŠƒbƒN‚ª—LŒø‚*
    /*C*/var rightClickCall = false; // ‰EƒNƒŠƒbƒN‚Å“Á’è‚̃‹[ƒ`ƒ“‚ðŒÄ‚Ô‚*
    /*C*/var rightClickJump = false; // ‰EƒNƒŠƒbƒN‚*‚Å“Á’è‚̃‰ƒxƒ‹‚ɃWƒƒƒ“ƒv‚·‚é‚*
    /*C*/var rightClickTarget = ""; // ‰EƒNƒŠƒbƒN‚ł̌Ăяo‚µæ
    /*C*/var rightClickStorage = ""; // ‰EƒNƒŠƒbƒN‚ł̌Ăяo‚µæ
    /*C*/var rightClickName = "default"; // ‰EƒNƒŠƒbƒN‚̃ƒjƒ…[•\Ž¦–¼
    /*C*/var rightClickCurrentMenuName = ""; // ‰EƒNƒŠƒbƒN‚̃ƒjƒ…[‚ÉŒ»ÝÝ’肳‚ê‚Ä‚¢‚é–¼‘O
    var rightClickDefaultName = ""; // ‰EƒNƒŠƒbƒN‚̃fƒtƒHƒ‹ƒg‚̃ƒjƒ…[•\Ž¦–¼

    /*C*/var lastClickGlyphVisible; // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚ɃNƒŠƒbƒN‘Ò‚¿‹L†‚ª‰ÂŽ‹‚¾‚Á‚½‚*‚Ç‚¤‚*
    var lastClickGlyphMessagePage;
    // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚̃NƒŠƒbƒN‘Ò‚¿‹L†‚Ì•\Ž¦‚³‚ê‚Ä‚¢‚郁ƒbƒZ[ƒWƒŒƒCƒ„‚̃y[ƒW
    var lastClickGlyphMessageNum; // V ”ԍ†
    var lastClickGlyphWhich; // V "page" ‚* "line" ‚*
    var inSleepBeforeExtraConductor; // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚ª inSleep ‚¾‚Á‚½‚*

    // ’ʏí‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorDefault = crArrow; // ’ʏí‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorPointed = crHandPoint; // ƒ{ƒ^ƒ“AƒŠƒ“ƒN“™‚ðƒ|ƒCƒ“ƒg‚µ‚½Žž‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorWaitingClick = crArrow; // ƒNƒŠƒbƒN‘Ò‚¿‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorDraggable = crSizeAll; // ƒhƒ‰ƒbƒO‰Â”\‚ȏꏊ—p‚̃}ƒEƒXƒJ[ƒ\ƒ‹

    /*C*/var startAnchorEnabled = false; // uÅ‰‚É–ß‚év‚ªŽg—p‰Â”\‚*‚Ç‚¤‚*

    /*C*/var storeEnabled = true; // ƒ†[ƒU‚ªužx‚ð‚Í‚³‚ށvƒƒjƒ…[‚ɃAƒNƒZƒX‰Â”\‚*‚Ç‚¤‚*
    /*C*/var restoreEnabled = true; // ƒ†[ƒU‚ªužx‚ð‚½‚Ç‚évƒƒjƒ…[‚ɃAƒNƒZƒX‰Â”\‚*‚Ç‚¤‚*
    var storeLabelPassed = false; // •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚ð’ʉ߂µ‚½‚*‚Ç‚¤‚*
    /*C*/var currentLabel = ""; // Œ»Ý‚̃‰ƒxƒ‹
    /*C*/var currentPageName = ""; // Œ»Ý‚̃y[ƒW–¼
    var currentRecordName = ""; // Œ»Ý‚Ì‹L˜^–¼ ( trail_ƒXƒgƒŒ[ƒW_ƒ‰ƒxƒ‹ )
    var autoRecordPageShowing = false; // ƒ‰ƒxƒ‹’ʉߋL˜^‚ð‚·‚é‚*

    var numBookMarks = 10; // ƒƒjƒ…[‚É—pˆÓ‚·‚éžx‚̃Tƒuƒƒjƒ…[€–ڂ̐”
    var showBookMarkDate = false; // ƒƒjƒ…[‚Éžx‚ð‚Í‚³‚ñ‚¾“ú•tŽž‚ð•\Ž¦‚·‚é‚*

    var bookMarkNames = []; // ƒƒjƒ…[‚ɐݒ肳‚ê‚Ä‚¢‚éžx‚Ì–¼‘O
    var bookMarkDates = []; // žx‚Ì“ú•t
    var bookMarkProtectedStates = []; // žx‚ª•ÛŒì‚³‚ê‚Ä‚¢‚é‚*‚̏î•ñ

    var showFixedPitchOnlyInFontSelector = false; // ƒtƒHƒ“ƒg‘I‘ð‚ŌŒèƒsƒbƒgƒtƒHƒ“ƒg‚Ì‚Ý‚ð•\Ž¦‚·‚é‚*

    var flags = %[]; // ƒtƒ‰ƒO(ƒ†[ƒU)
    var pflags = %[]; // u•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹v‚ð’ʉ߂µ‚½Žž“_‚ł̃tƒ‰ƒO(ƒ†[ƒU)
    var pcflags = %[]; // V (ƒRƒA)
    var sflags = %[]; // ƒVƒXƒeƒ€•Ï”—̈æ(ƒ†[ƒU)
    var scflags = %[]; // ƒVƒXƒeƒ€•Ï”—̈æ(ƒRƒA)
    var tflags = %[]; // ˆêŽžƒtƒ‰ƒO

    var tempBookMarks = []; // ˆêŽž“I‚É•Û‘¶‚µ‚½žx

    var clickCount = 0; // ¶ƒNƒŠƒbƒNƒJƒEƒ“ƒg
    var lastMouseDownX; // ÅŒã‚ɃNƒŠƒbƒN‚³‚ꂽ X À•W
    var lastMouseDownY; // ÅŒã‚ɃNƒŠƒbƒN‚³‚ꂽ Y À•W

    var mouseKeyEnabledCount = 0; // ƒ}ƒEƒXƒL[‚ª—LŒø‚*‚Ç‚¤‚*

    var kagPlugins = []; // KAG ƒvƒ‰ƒOƒCƒ“

    var keyDownHook = []; // ƒL[‚ª‰Ÿ‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨
    var leftClickHook = []; // ‰EƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨
    var rightClickHook = []; // ¶ƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨

    var padKeyMap; // ƒpƒbƒhƒ{ƒ^ƒ“ -> ƒnƒ“ƒhƒ‰(ƒL[ƒR[ƒh)BƒRƒ“ƒXƒgƒ‰ƒNƒ^“à‚Őݒè
    var padKeyMapReverse; // ƒL[ƒR[ƒh -> ƒpƒbƒhƒ{ƒ^ƒ“BƒRƒ“ƒXƒgƒ‰ƒNƒ^“à‚Őݒè


    var holdPeriodEventQueue = []; // •Û—¯‚É‚³‚ꂽƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒgƒLƒ…[
    var isLeavePeriodEvent = false; // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð•Û—¯‚É‚·‚é‚*‚Ç‚¤‚*
    var isWaitPeriodEvent = false; // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿ó‘Ô‚*‚Ç‚¤‚*
    var waitedPeriodEventStorageName = void; // ƒsƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿‚ðƒR[ƒ‹‚µ‚½ƒXƒgƒŒ[ƒW–¼

    //------------------------------------------------------ ƒRƒ“ƒXƒgƒ‰ƒNƒ^ --

    function KAGWindow(ismain = true, width = 0, height = 0)
    {
    // ƒRƒ“ƒXƒgƒ‰ƒNƒ^
    // ˆø” : ismain : ƒƒCƒ“ƒEƒBƒ“ƒhƒE‚Æ‚µ‚č쐬‚³‚ê‚é‚Ì‚*‚Ç‚¤‚*
    super.Window(); // eƒNƒ‰ƒX‚̃Rƒ“ƒXƒgƒ‰ƒNƒ^‚ðŒÄ‚Ô

    // ƒRƒ“ƒtƒBƒMƒ…ƒŒ[ƒVƒ‡ƒ“
    isMain = ismain;
    if(ismain)
    {
    (KAGWindow_config incontextof this)();
    (KAGWindow_config_override incontextof this)()
    if typeof global.KAGWindow_config_override != "undefined";
    }

    userChSpeed = chSpeed = actualChSpeed = chSpeeds.normal;
    autoModePageWait = autoModePageWaits.medium;
    autoModeLineWait = autoModeLineWaits.medium;

    askOnClose = false if !ismain;

    // saveDataLocation ‚ªƒtƒ‹ƒpƒX‚Å‚È‚¢‚悤‚È‚ç‚Î System.exePath ‚ð
    // •t‚¯‰Á‚¦‚é
    if(saveDataLocation.indexOf(":") == -1)
    saveDataLocation = System.exePath + saveDataLocation;

    // ƒƒjƒ…[ƒAƒCƒeƒ€‚̍쐬
    if(ismain) (KAGWindow_createMenus incontextof this)();
    if(typeof this.rightClickMenuItem != "undefined")
    rightClickDefaultName = rightClickCurrentMenuName = rightClickMenuItem.caption;

    if(typeof this.autoModeMediumMenuItem != "undefined")
    autoModeMediumMenuItem.checked = true;
    if(typeof this.windowedMenuItem != "undefined")
    windowedMenuItem.checked = true;
    if(typeof this.chNormalMenuItem != "undefined")
    chNormalMenuItem.checked = true;
    if(typeof this.ch2ndNoChangeMenuItem != "undefined")
    ch2ndNoChangeMenuItem.checked = true;

    if(ismain) (Menu_visible_config incontextof this)();

    createBookMarkSubMenus();

    // ƒEƒBƒ“ƒhƒEŠOŒ*‚Ì’²®
    if(ismain)
    {
    borderStyle = bsSingle;
    innerSunken = true;
    }
    else
    {
    borderStyle = bsDialog;
    innerSunken = false;
    }
    showScrollBars = false;
    if(ismain) caption = System.title;

    // ƒVƒXƒeƒ€ƒ^ƒCƒgƒ‹‚ðƒLƒƒƒvƒVƒ‡ƒ“‚Æ“¯‚¶‚É
    if(ismain) System.title = caption;

    // ƒEƒBƒ“ƒhƒEƒTƒCƒY‚Ì’²®
    if(width != 0 && height != 0)
    {
    // —^‚¦‚ç‚ꂽƒTƒCƒY‚ð“K—p
    scWidth = width;
    scHeight = height;
    }
    setInnerSize(scWidth, scHeight);

    // quake —pƒ^ƒCƒ}‚̍쐬
    quakeTimer = new Timer(onQuakeTimerInterval, '');
    add(quakeTimer);
    quakeTimer.interval = 50;

    // ”wŒiƒŒƒCƒ„‚̍쐬
    fore.messages = [];
    back.messages = [];
    fore.layers = [];
    back.layers = [];
    fore.base = new BaseLayer(this, null, "•\-”wŒi");
    add(fore.base);
    fore.base.setImageSize(scWidth, scHeight);
    fore.base.setSizeToImageSize();
    back.base = new BaseLayer(this, fore.base, "— -”wŒi");
    add(back.base);
    back.base.setImageSize(scWidth, scHeight);
    back.base.setSizeToImageSize();
    fore.base.setCompLayer(back.base);
    back.base.setCompLayer(fore.base);
    fore.base.freeImage();
    back.base.freeImage();

    fore.base.setDefaultCursor(cursorDefault);
    back.base.setDefaultCursor(cursorDefault);

    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̍쐬
    historyLayer = new HistoryLayer(this, fore.base);
    add(historyLayer);

    // ‘OŒiƒŒƒCƒ„‚̍쐬
    allocateCharacterLayers(numCharacterLayers);

    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̍쐬
    allocateMessageLayers(numMessageLayers, false);
    current = fore.messages[0];
    currentNum = 0;
    currentPage = 0;
    currentWithBack = false;
    if(initialMessageLayerVisible)
    {
    fore.messages[0].visible = true;
    back.messages[0].visible = true;
    }

    chDefaultAntialiased = fore.messages[0].defaultAntialiased;
    // •¶Žš‚ɃAƒ“ƒ`ƒGƒCƒŠƒAƒX‚ð‚*‚¯‚é‚*‚Ç‚¤‚*
    chDefaultFace = fore.messages[0].userFace;
    // •¶Žš‚̃fƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒg

    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;

    // s‘Ò‚¿/ƒy[ƒW‘Ò‚¿ƒAƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„‚̍쐬
    lineBreak = new ClickGlyphLayer(this, fore.base);
    add(lineBreak);
    lineBreak.name = "sƒNƒŠƒbƒN‘Ò‚¿‹L†";
    pageBreak = new ClickGlyphLayer(this, fore.base);
    add(pageBreak);
    pageBreak.name = "ƒy[ƒW––ƒNƒŠƒbƒN‘Ò‚¿‹L†";

    // ƒ^ƒOƒnƒ“ƒhƒ‰/ƒRƒ“ƒ_ƒNƒ^‚ðì¬
    tagHandlers = getHandlers();
    mainConductor = new Conductor(this, tagHandlers);
    add(mainConductor);
    conductor = mainConductor;
    extraConductor = new Conductor(this, tagHandlers);
    add(extraConductor);

    // BGM ƒIƒuƒWƒFƒNƒg‚ðì¬
    bgm = new BGM(this);
    add(bgm);

    // Œø‰Ê‰¹ƒIƒuƒWƒFƒNƒg‚ðì¬
    for(var i = 0; i < numSEBuffers; i++)
    add(se[i] = new SESoundBuffer(this, i));

    // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg‚ðì¬
    if(ismain)
    {
    for( var i = 0; i < numMovies; i++)
    add(movies[i] = new Movie(this,i));
    }

    // ƒfƒtƒHƒ‹ƒg‚̃nƒ“ƒhƒ‰‚ð’ljÁ
    stableHandlers.add(defaultStableHandler);
    runHandlers.add(defaultRunHandler);

    // ƒVƒXƒeƒ€•Ï”‚̓ǂݍž‚Ý
    if(ismain) loadSystemVariables();

    // ƒVƒXƒeƒ€•Ï”‚𔽉f
    if(ismain)
    {
    setSystemStateFromSystemVariables();
    setBookMarkMenuCaptions();
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    clearMessageLayers(false);

    // ƒEƒBƒ“ƒhƒEˆÊ’u‚Ì’²ß
    if(this.width + this.left > System.desktopLeft + System.desktopWidth)
    left = ((System.desktopWidth - this.width) >>1) + System.desktopLeft;
    if(this.height + this.top > System.desktopTop + System.desktopHeight)
    top = ((System.desktopHeight - this.height) >>1) + System.desktopTop;

    // ƒpƒbƒhƒ{ƒ^ƒ“ƒnƒ“ƒhƒ‰‚̍쐬
    createPadKeyMap();


    // ƒEƒBƒ“ƒhƒE‚ð•\Ž¦
    if(ismain) visible = true;

    // ‰æ–ʃTƒCƒY‚ªƒEƒBƒ“ƒhƒEƒTƒCƒY‚æ‚è‚à¬‚³‚¢ê‡‚Í
    // ƒtƒ‹ƒXƒNƒŠ[ƒ“‚É‚µ‚Ä‚Ý‚é
    if(ismain)
    {
    if(System.screenWidth <= scWidth && System.screenHeight <= scHeight)
    onFullScreenMenuItemClick(this);
    }

    // ‘O‰ñ‹N“®Žž‚Ƀtƒ‹ƒXƒNƒŠ[ƒ“‚¾‚Á‚½ê‡‚̓tƒ‹ƒXƒNƒŠ[ƒ“‚É‚µ‚Ä‚Ý‚é
    if(ismain)
    {
    if(scflags.fullScreen !== void && +scflags.fullScreen)
    onFullScreenMenuItemClick(this);
    }

    // ‚¢‚Á‚½‚ñƒVƒXƒeƒ€•Ï”‚ð‘‚«o‚·
    if(ismain) saveSystemVariables();
    }

    //------------------------------------------------------------- finalize --

    function finalize()
    {
    // finalize ƒƒ\ƒbƒh

    // ƒvƒ‰ƒOƒCƒ“‚Ì–³Œø‰»
    for(var i = 0; i < kagPlugins.count; i++) invalidate kagPlugins[i];

    // ‘OŒiAƒƒbƒZ[ƒWƒŒƒCƒ„‚𖳌ø‰»
    for(var i = 0; i< fore.layers.count; i++) invalidate fore.layers[i];
    for(var i = 0; i< back.layers.count; i++) invalidate back.layers[i];
    for(var i = 0; i< fore.messages.count; i++) invalidate fore.messages[i];
    for(var i = 0; i< back.messages.count; i++) invalidate back.messages[i];

    // snapshotLayer ‚𖳌ø‰»
    invalidate snapshotLayer if snapshotLayer !== void;

    // tempLayer ‚𖳌ø‰»
    invalidate tempLayer if tempLayer !== void;

    // ƒX[ƒp[ƒNƒ‰ƒX‚Ì finalize ‚ðŒÄ‚Ô
    super.finalize(...);
    }

    //-------------------------------------------------- onCloseQuery/close --

    function onCloseQuery()
    {
    saveSystemVariables();
    if(!askOnClose) { super.onCloseQuery(true); return; }
    super.onCloseQuery(askYesNo("Quit the GameH"));
    }

    function close()
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    saveSystemVariables();
    super.close(...);
    }

    function shutdown()
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚邪AI—¹Šm”F‚ðs‚í‚È‚¢
    // ‚±‚̃ƒ\ƒbƒh“à‚Å close ‚ð‚·‚é‚ƁA—lX‚È
    // ƒIƒuƒWƒFƒNƒg‚ª–³Œø‰»‚³‚ê‚Ä‚µ‚Ü‚¢A‚±‚Ì
    // ŠÖ”‚*‚ç–ß‚Á‚½æ‚ŃGƒ‰[‚ª”­¶‚·‚éB
    // ‚»‚Ì‚½‚߁A‚¢‚Á‚½‚ñ AsyncTrigger ‚ð‰î‚µ‚āA
    // ‘S‚Ẵƒ\ƒbƒh‚*‚ç‹A‚Á‚½‚ ‚ƂɃVƒƒƒbƒgƒ_ƒEƒ“
    // ˆ—‚ðs‚¤B
    global.shutdownTrigger =
    new AsyncTrigger(handleShutdown, '');
    global.shutdownTrigger.cached = true;
    global.shutdownTrigger.trigger();
    if(conductor.status == conductor.mRun)
    conductor.interrupt();
    // ƒRƒ“ƒ_ƒNƒ^‚ª‘–s’†‚ÌŽž‚Í
    // ƒRƒ“ƒ_ƒNƒ^‚É’†’f‚ð“`‚¦‚é
    }

    function handleShutdown()
    {
    // shutdown() ‚*‚ç‚̃Vƒƒƒbƒgƒ_ƒEƒ“—v‹‚ð
    // ŽÀÛ‚ɏˆ—‚·‚郁ƒ\ƒbƒh
    var askOnClose_save = askOnClose;
    askOnClose = false;
    close();
    if(this isvalid) askOnClose = askOnClose_save;
    }

    function closeByScript(elm)
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    // ‚¿‚å‚Á‚Æ–Ê“|‚­‚³‚¢‚Æ‚ð‚â‚Á‚Ä‚¢‚é‚Ì‚Í
    // shutdown ‚Æ“¯‚¶——R
    // u‚¢‚¢‚¦v‚ª‘I‘ð‚³‚ê‚ăEƒBƒ“ƒhƒE‚ª•Â‚¶‚È‚*‚Á‚½ê‡‚Í
    // 'not_closed' ƒgƒŠƒK‚ª”­s‚³‚êAŽÀs‚͍ĊJ‚·‚éB
    var askOnClose_save = askOnClose;
    if(elm.ask !== void && !(+elm.ask)) askOnClose = false;
    global.shutdownTrigger =
    new AsyncTrigger(handleCloseByScript, '');
    global.shutdownTrigger.cached = true;
    global.shutdownTrigger.trigger();

    // closeByScript ‚́A‚±‚̃nƒ“ƒhƒ‰‚ªI‚í‚Á‚½’¼Œã‚É
    // uI—¹‚µ‚Ü‚·‚*Hv‚̃_ƒCƒAƒƒO‚ð•\Ž¦‚·‚éB
    // I—¹‚·‚éê‡‚Í‚»‚̂܂܏I—¹‚·‚éB
    // I—¹‚µ‚È‚¢ê‡‚Í 'not_closed' ƒgƒŠƒK‚ª”­s‚³‚êA
    // ŽÀs‚ÍŒp‘±‚·‚éB
    conductor.wait(%[
    not_closed : askOnClose_save
    ? (function
    {
    // ŽÀÛ‚É‚±‚ꂪŒÄ‚΂ê‚邱‚Æ‚Í‚È‚¢‚ªAˆê‰ž
    askOnClose = true;
    } incontextof this)
    : (function
    {
    } incontextof this)
    ]);
    }

    function handleCloseByScript()
    {
    // shutdown() ‚*‚ç‚̃Vƒƒƒbƒgƒ_ƒEƒ“—v‹‚ð
    // ŽÀÛ‚ɏˆ—‚·‚郁ƒ\ƒbƒh
    close();
    if(this isvalid) // ‚¢‚¢‚¦ ‚ª‘I‘ð‚³‚ê‚½ê‡
    conductor.trigger('not_closed');
    }

    //------------------------------------------------------ ƒvƒ‰ƒOƒCƒ“ˆ— --

    function forEachEventHook(method, func, arg)
    {
    // ‚·‚ׂẴvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚Ì method ‚É‚½‚¢‚µ‚Ä
    // func ‚ðŽÀs‚·‚é
    // func ‚̈ø”‚É‚ÍŠe—v‘f‚Æ arg ‚ª“n‚³‚ê‚é
    if(kagPlugins.count)
    {
    var array = [];
    array.assign(kagPlugins); // ‚¢‚Á‚½‚ñƒRƒs[‚µAƒRƒs[‚µ‚½•¨‚ɑ΂µ‚ÄŽÀs‚·‚é
    var arraycount = array.count;
    for(var i =0; i<arraycount; i++)
    {
    var obj = array[i];
    if(typeof obj[method] != "undefined")
    func(obj[method], arg);
    }
    }
    }

    function addPlugin(plugin)
    {
    // ƒvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚ð’ljÁ
    kagPlugins.add(plugin);
    }

    function removePlugin(plugin)
    {
    // ƒvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚ðíœ
    kagPlugins.remove(plugin);
    }

    //---------------------------------------------------------- ƒtƒbƒNˆ— --

    function callHook(array, arg1, arg2, arg3)
    {
    if(array.count)
    {
    var processed = false;
    var newarray = [];
    newarray.assign(array);
    var arraycount = newarray.count;
    for(var i = 0; i < arraycount; i++)
    {
    var func = newarray[i];
    var ret = func(arg1, arg2, arg3);
    processed = processed || ret;
    }
    return processed;
    }
    else
    {
    return false;
    }
    }

    //------------------------------------------ ƒpƒbƒh‚̃L[ƒ}ƒbƒsƒ“ƒOì¬ --

    function createPadKeyMap()
    {
    // ƒpƒbƒh“ü—Í‚Æ‚»‚ê‚ɑΉž‚·‚é“®ì‚̃}ƒbƒsƒ“ƒOB
    // •W€‚ł͏\ŽšƒL[‚̓L[ƒ{[ƒh‚̃J[ƒ\ƒ‹ƒL[‚Ƀ}ƒbƒsƒ“ƒOA
    // ƒ{ƒ^ƒ“1 ‚Í ReturnAƒ{ƒ^ƒ“2 ‚Í ESCAƒ{ƒ^ƒ“3 ‚Í ƒƒbƒZ[ƒW—š—ð‚Ì•\Ž¦
    // ‚Ƀ}ƒbƒsƒ“ƒO‚³‚ê‚éB
    // ŠÖ”‚ðŽw’肵‚½ê‡‚̓{ƒ^ƒ“‚ð‰Ÿ‚µ‚½‚Æ‚«‚É‚Í‚»‚̊֐”‚ªŒÄ‚΂ê‚éB

    padKeyMap = %[
    VK_PADLEFT => VK_LEFT,
    VK_PADRIGHT => VK_RIGHT,
    VK_PADUP => VK_UP,
    VK_PADDOWN => VK_DOWN,
    VK_PAD1 => VK_RETURN,
    VK_PAD2 => VK_ESCAPE,
    VK_PAD3 =>
    function(ev) {
    showHistoryByKey(this);
    },
    ];

    // padKeyMapReverse ‚ðì¬
    padKeyMapReverse = %[];
    var ar = [];
    ar.assign(padKeyMap);
    for(var i = 0; i < ar.count; i += 2)
    {
    if(typeof(ar[i+1]) != "Object")
    {
    padKeyMapReverse[ar[i+1]] = ar[i];
    }
    }
    }

    function getKeyState(key)
    {
    // System.getKeyState ŠÖ”‚Æ“¯“™‚¾‚ªAƒpƒbƒh‚̃L[‚ÉŠÖ‚µ‚Ä‚à
    // ”½‰ž‚ð•Ô‚·
    var sg = System.getKeyState;
    var state = sg(key);
    if(state) return true;
    var pad_key = padKeyMapReverse[key];
    if(pad_key !== void)
    {
    // ƒL[ƒR[ƒh -> ƒpƒbƒh‚̃L[ƒR[ƒh‚Ì•ÏŠ·‚ªŒ*‚‚*‚Á‚½
    return sg(pad_key);
    }
    return false;
    }

    //-------------------------------------------------------------- action --

    function action(ev)
    {
    if(ev.type == 'onKeyDown' && ev.target === this)
    {
    // ƒpƒbƒh“ü—͂ɑΉž‚·‚鏈—
    var handler = padKeyMap[ev.key];
    if(handler !== void)
    {
    // ƒnƒ“ƒhƒ‰‚ªŒ*‚‚*‚Á‚½
    if(typeof(handler) == "Object")
    {
    // ƒnƒ“ƒhƒ‰‚͊֐”
    (handler incontextof this)(ev);
    }
    else
    {
    // ƒnƒ“ƒhƒ‰‚̓L[ƒR[ƒh
    postInputEvent('onKeyDown', %[key: handler]);
    postInputEvent('onKeyUp', %[key: handler]);
    }
    }
    }
    }

    //------------------------------------------------------ tempLayer ŠÖ˜A --

    property temporaryLayer
    {
    // ƒ[ƒNƒGƒŠƒA‚Æ‚µ‚Ĉꎞ“I‚ÉŽg—p‚Å‚«‚郌ƒCƒ„‚ð•Ô‚·
    getter()
    {
    if(tempLayer === void)
    {
    tempLayer = new KAGLayer(this, primaryLayer);
    tempLayer.name = "ˆêŽžƒ[ƒNƒŒƒCƒ„";
    }
    return tempLayer;
    }
    }

    //------------------------------------------------ ƒƒjƒ…[ƒAƒCƒeƒ€ŠÖ˜A --

    function onExitMenuItemClick(sender)
    {
    close();
    }

    function onRightClickMenuItemClick(sender)
    {
    onPrimaryRightClick(); // ‰EƒNƒŠƒbƒN‚Ì“®ì
    }

    function onShowHistoryMenuItemClick(sender)
    {
    if(historyLayer.visible) hideHistory(); else showHistory();
    }

    function onSkipToNextStopMenuItemClick(sender)
    {
    skipToStop();
    }

    function onAutoModeMenuItemClick(sender)
    {
    if(autoMode) cancelAutoMode(); else enterAutoMode();
    }

    function onAutoModeWaitMenuClick(sender)
    {
    sender.checked = true;
    autoModePageWait = sender.wait;
    autoModeLineWait = sender.lwait;
    }

    function onBackStartMenuItemClick(sender)
    {
    goBackHistory();
    }

    function onGoToStartMenuItemClick(sender)
    {
    goToStartWithAsk();
    }

    function onChSpeedMenuItemClick(sender)
    {
    sender.checked = true;
    userChSpeed = sender.speed;
    setUserSpeed();
    saveSystemVariables();
    }

    function onChNonStopToPageBreakItemClick(sender)
    {
    chNonStopToPageBreak = ! chNonStopToPageBreak;
    if(typeof this.chNonStopToPageBreakItem != "undefined")
    chNonStopToPageBreakItem.checked = chNonStopToPageBreak;
    saveSystemVariables();
    }

    function onCh2ndNonStopToPageBreakItemClick(sender)
    {
    ch2ndNonStopToPageBreak = ! ch2ndNonStopToPageBreak;
    if(typeof this.ch2ndNonStopToPageBreakItem != "undefined")
    ch2ndNonStopToPageBreakItem.checked = ch2ndNonStopToPageBreak;
    saveSystemVariables();
    }

    function onCh2ndSpeedMenuItemClick(sender)
    {
    sender.checked = true;
    userCh2ndSpeed = sender.speed;
    setUserSpeed();
    saveSystemVariables();
    }

    function onChAntialiasMenuItemClick(sender)
    {
    chDefaultAntialiased = !chDefaultAntialiased;
    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;
    setMessageLayerUserFont();
    saveSystemVariables();
    }

    function onChChangeFontMenuItem(sender)
    {
    selectFont();
    saveSystemVariables();
    }

    function onRestoreMenuClick(sender)
    {
    if(!freeSaveDataMode) return;
    loadBookMarkFromFileWithAsk();
    }

    function onStoreMenuClick(sender)
    {
    if(!freeSaveDataMode) return;
    saveBookMarkToFileWithAsk();
    }

    function onWindowedMenuItemClick(sender)
    {
    if(fullScreened)
    {
    try
    {
    fullScreen = false;
    }
    catch(e)
    {
    Debug.notice("ƒEƒBƒ“ƒhƒEƒ‚[ƒh‚Ɉڍs‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½ : " + e.message);
    }
    fullScreened = fullScreen;
    if(fullScreened)
    fullScreenMenuItem.checked = true;
    else
    windowedMenuItem.checked = true;
    }
    saveSystemVariables();
    }

    function onFullScreenMenuItemClick(sender)
    {
    if(!fullScreened)
    {
    try
    {
    fullScreen = true;
    }
    catch(e)
    {
    Debug.notice("ƒtƒ‹ƒXƒNƒŠ[ƒ“ƒ‚[ƒh‚Ɉڍs‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½ : " + e.message);
    }
    fullScreened = fullScreen;
    if(fullScreened)
    fullScreenMenuItem.checked = true;
    else
    windowedMenuItem.checked = true;
    }
    saveSystemVariables();
    }

    function onHelpIndexMenuItemClick(sender)
    {
    // ƒwƒ‹ƒvƒtƒ@ƒCƒ‹‚ðŠJ‚­
    System.shellExecute(Storages.getLocalName(System.exePath) + helpFile);
    }

    function onHelpAboutMenuItemClick(sender)
    {
    // u‚±‚̃\ƒtƒg‚ɂ‚¢‚āvƒEƒBƒ“ƒhƒE‚ð•\Ž¦
    var win = new global.KAGWindow(false, aboutWidth, aboutHeight);
    win.setPos(left + ((width - win.width)>>1), top + ((height - win.height)>>1));
    win.process('about.ks' ,,, true); // about.ks ‚ð immediate ‚Å•\Ž¦
    win.showModal(); // ƒ‚[ƒh•t‚«‚Å•\Ž¦
    invalidate win;
    }

    function onReloadScenarioMenuItemClick(sender)
    {
    saveBookMark(1000, false);
    loadBookMark(1000);
    }

    function onShowConsoleMenuItemClick(sender)
    {
    Debug.console.visible = true;
    }

    function onShowContollerMenuItemClick(sender)
    {
    Debug.controller.visible = true;
    }

    function internalSetMenuAccessibleAll(menu, state)
    {
    // autoEnable ‚ª true ‚Ì‚·‚ׂẴƒjƒ…[€–Ú‚Ì accessible ‚É’l state ‚ð
    // Ý’è‚·‚é
    if(typeof menu.autoEnable != "undefined" && menu.autoEnable)
    menu.accessible = state;
    if(typeof menu.stopRecur == "undefined" || !menu.stopRecur)
    {
    var children = menu.children;
    for(var i = children.count -1; i >= 0; i--)
    internalSetMenuAccessibleAll(children[i], state); // Ä‹A
    }
    }

    function canStore()
    {
    return storeEnabled && storeLabelPassed;
    }

    function canRestore()
    {
    return restoreEnabled;
    }

    function setMenuAccessibleAll()
    {
    // ƒƒjƒ…[€–Ú‚ÌŽg—p‰Â/•s‰Â‚ðÝ’è‚·‚é

    // autoEnable ‚ª true ‚Ì‚·‚ׂẴƒjƒ…[€–Ú‚Ì accessible ‚Ì
    // ’l‚ðÝ’è‚·‚é
    var notmodal = !historyLayer.visible && !messageLayerHiding;
    var state = inStable && notmodal;
    internalSetMenuAccessibleAll(menu, state);

    // ‚»‚Ì‘¼‚̃ƒjƒ…[‚ÌŽg—p‰Â/•s‰Â
    if(typeof this.skipToNextStopMenuItem != "undefined")
    skipToNextStopMenuItem.enabled = state && !inSleep && nextSkipEnabled;

    if(typeof this.rightClickMenuItem != "undefined")
    rightClickMenuItem.enabled = inStable && !historyLayer.visible;

    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.enabled = inStable && !messageLayerHiding &&
    historyEnabled;

    if(typeof this.autoModeMenuItem != "undefined")
    autoModeMenuItem.enabled = notmodal;

    if(typeof this.goBackMenuItem != "undefined")
    goBackMenuItem.enabled = state && isHistoryOfStoreAlive();

    if(typeof this.goToStartMenuItem != "undefined")
    goToStartMenuItem.enabled = state && startAnchorEnabled;

    if(typeof this.storeMenu != "undefined")
    {
    var st = state && canStore();
    var children = storeMenu.children;
    if(freeSaveDataMode) storeMenu.enabled = st;
    for(var i = children.count - 1; i >= 0; i--)
    {
    var obj = children[i];
    obj.enabled = obj.orgEnabled && st;
    }
    }

    if(typeof this.restoreMenu != "undefined")
    {
    var st = state && canRestore();
    var children = restoreMenu.children;
    if(freeSaveDataMode) restoreMenu.enabled = st;
    for(var i = children.count - 1; i >= 0; i--)
    {
    var obj = children[i];
    obj.enabled = obj.orgEnabled && st;
    }
    }
    }

    //----------------------------------------------- ƒ}ƒEƒXƒL[‚ð—LŒø‚É‚·‚é --

    function enableMouseKey()
    {
    // ƒ}ƒEƒXƒL[‚ð—LŒø‚É‚·‚é
    if(mouseKeyEnabledCount == 0)
    {
    useMouseKey = true;
    mouseCursorState = mcsVisible;
    }
    mouseKeyEnabledCount++; // ŽQÆƒJƒEƒ“ƒ^•ûŽ®
    }

    function disableMouseKey()
    {
    // ƒ}ƒEƒXƒL[‚𖳌ø‚É‚·‚é
    mouseKeyEnabledCount --;
    if(mouseKeyEnabledCount == 0) useMouseKey = false;
    }

    //----------------------------------------------------- ƒVƒXƒeƒ€•Ï”ŠÖ˜A --

    function loadSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚̓ǂݍž‚Ý
    try
    {
    var fn = saveDataLocation + "/" + dataName +
    "sc.ksd";
    if(Storages.isExistentStorage(fn))
    {
    scflags = Scripts.evalStorage(fn);
    scflags = %[] if scflags === void;
    }
    else
    {
    scflags = %[];
    }

    var fn = saveDataLocation + "/" + dataName +
    "su.ksd";
    if(Storages.isExistentStorage(fn))
    {
    sflags = Scripts.evalStorage(fn);
    sflags = %[] if sflags === void;
    }
    else
    {
    sflags = %[];
    }
    }
    catch(e)
    {
    throw new Exception("ƒVƒXƒeƒ€•Ï”ƒf[ƒ^‚ð“ǂݍž‚ß‚È‚¢‚*A"
    "‚ ‚é‚¢‚̓VƒXƒeƒ€•Ï”ƒf[ƒ^‚ª‰ó‚ê‚Ä‚¢‚Ü‚·(" + e.message + ")");
    }
    }

    function setSystemStateFromSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚ÉŠî‚¢‚ăVƒXƒeƒ€‚ðÝ’è
    // (ƒtƒ‹ƒXƒNƒŠ[ƒ“ŠÖ˜A‚ð‚Ì‚¼‚­)
    if(scflags.autoModePageWait !== void)
    {
    if(typeof this.autoModeWaitMenu !== "undefined")
    {
    var children = autoModeWaitMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.wait !== "undefined" && item.wait == scflags.autoModePageWait)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    if(scflags.userChSpeed !== void)
    {
    if(typeof this.chSpeedMenu !== "undefined")
    {
    var children = chSpeedMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.speed !== "undefined" && item.speed == scflags.userChSpeed)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    if(scflags.userCh2ndSpeed !== void)
    {
    if(typeof this.chSpeedMenu !== "undefined")
    {
    var children = ch2ndSpeedMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.speed !== "undefined" && item.speed == scflags.userCh2ndSpeed)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    lastSaveDataNameGlobal = scflags.lastSaveDataNameGlobal if scflags.lastSaveDataNameGlobal !== void;

    bookMarkNames = scflags.bookMarkNames if scflags.bookMarkNames !== void;
    bookMarkDates = scflags.bookMarkDates if scflags.bookMarkDates !== void;
    bookMarkProtectedStates = scflags.bookMarkProtectedStates if scflags.bookMarkProtectedStates !== void;

    autoModePageWait = scflags.autoModePageWait if scflags.autoModePageWait !== void;
    autoModeLineWait = scflags.autoModeLineWait if scflags.autoModeLineWait !== void;
    userChSpeed = scflags.userChSpeed if scflags.userChSpeed !== void;
    userCh2ndSpeed = scflags.userCh2ndSpeed if scflags.userCh2ndSpeed !== void;

    setUserSpeed();

    chNonStopToPageBreak = scflags.chNonStopToPageBreak if scflags.chNonStopToPageBreak !== void;
    if(typeof this.chNonStopToPageBreakItem != "undefined")
    chNonStopToPageBreakItem.checked = chNonStopToPageBreak;

    ch2ndNonStopToPageBreak = scflags.ch2ndNonStopToPageBreak if scflags.ch2ndNonStopToPageBreak !== void;
    if(typeof this.ch2ndNonStopToPageBreakItem != "undefined")
    ch2ndNonStopToPageBreakItem.checked = ch2ndNonStopToPageBreak;

    chDefaultAntialiased = scflags.chDefaultAntialiased if scflags.chDefaultAntialiased !== void;
    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;
    chDefaultFace = scflags.chDefaultFace if scflags.chDefaultFace !== void;

    setMessageLayerUserFont();

    bgm.restoreSystemState(scflags);

    for(var i = 0; i<numSEBuffers; i++)
    {
    se[i].restoreSystemState(scflags);
    }
    }

    function clearSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚̃NƒŠƒA
    (Dictionary.clear incontextof sflags)();
    }

    function saveSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚Ì•Û‘¶
    if(!isMain) return;

    // ƒvƒ‰ƒOƒCƒ“‚ðŒÄ‚Ô
    forEachEventHook('onSaveSystemVariables',
    function(handler, f) { handler(); } incontextof this);

    // ƒtƒ‹ƒXƒNƒŠ[ƒ“
    scflags.fullScreen = fullScreened;

    // •¶Žš•\Ž¦‘¬“x
    scflags.autoModePageWait = autoModePageWait;
    scflags.autoModeLineWait = autoModeLineWait;
    scflags.userChSpeed = userChSpeed;
    scflags.userCh2ndSpeed = userCh2ndSpeed;
    scflags.chDefaultAntialiased = chDefaultAntialiased;
    scflags.chDefaultFace = chDefaultFace;
    scflags.chNonStopToPageBreak = chNonStopToPageBreak;
    scflags.ch2ndNonStopToPageBreak = ch2ndNonStopToPageBreak;

    // ƒuƒbƒNƒ}[ƒN–¼
    scflags.bookMarkNames = bookMarkNames; // (ƒRƒs[‚Å‚Í‚È‚­‚Ä)ŽQÆ‚ŏ\•ª
    scflags.bookMarkDates = bookMarkDates;
    scflags.bookMarkProtectedStates = bookMarkProtectedStates;

    scflags.lastSaveDataNameGlobal = lastSaveDataNameGlobal;

    // ƒtƒ@ƒCƒ‹‚ɏ‘‚«ž‚Þ
    if(!readOnlyMode)
    {
    var fn = saveDataLocation + "/" + dataName +
    "sc.ksd";
    (Dictionary.saveStruct incontextof scflags)(fn, saveDataMode);

    var fn = saveDataLocation + "/" + dataName +
    "su.ksd";
    (Dictionary.saveStruct incontextof sflags)(fn, saveDataMode);
    }
    }

    //------------------------------------------------------- ƒQ[ƒ€•Ï”ŠÖ˜A --

    function internalStoreFlags(f)
    {
    // f ‚ÉŒ»Ý‚̏ó‘Ô‚ð‹L˜^‚·‚é

    // KAGWindow ‚ÉŠÖ‚·‚é‚à‚Ì
    (Dictionary.clear incontextof f)(); // ƒNƒŠƒA
    // ‚±‚±‚Ì [start_store_vars] ‚*‚ç [end_store_vars] ‚ň͂܂ꂽ•”•ª‚Í
    // ––’[‚Ì perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚é‚̂ŁA‚±‚̃}[ƒN‚ðÁ‚µ‚½‚è
    // ‚±‚̃}[ƒN‚ÌŠÔ‚ð•ÒW‚µ‚½‚肵‚È‚¢‚±‚ƁB
    // [start_store_vars]
    f.lastSaveDataName = lastSaveDataName;
    f.quaking = quaking;
    f.quakeEndTick = quakeEndTick;
    f.quakeHorzMax = quakeHorzMax;
    f.quakeVertMax = quakeVertMax;
    f.quakePhase = quakePhase;
    f.historyWriteEnabled = historyWriteEnabled;
    f.historyEnabled = historyEnabled;
    f.numCharacterLayers = numCharacterLayers;
    f.numMessageLayers = numMessageLayers;
    f.currentNum = currentNum;
    f.currentPage = currentPage;
    f.currentWithBack = currentWithBack;
    f.chUserMode = chUserMode;
    f.chSpeed = chSpeed;
    f.actualChSpeed = actualChSpeed;
    f.beforeNoWaitActualChSpeed = beforeNoWaitActualChSpeed;
    f.beforeNoWaitChUserMode = beforeNoWaitChUserMode;
    f.clickSkipEnabled = clickSkipEnabled;
    f.nextSkipEnabled = nextSkipEnabled;
    f.canCancelSkipByClick = canCancelSkipByClick;
    f.autoWCEnabled = autoWCEnabled;
    f.autoWCChars = autoWCChars;
    f.rightClickEnabled = rightClickEnabled;
    f.rightClickCall = rightClickCall;
    f.rightClickJump = rightClickJump;
    f.rightClickTarget = rightClickTarget;
    f.rightClickStorage = rightClickStorage;
    f.rightClickName = rightClickName;
    f.rightClickCurrentMenuName = rightClickCurrentMenuName;
    f.lastClickGlyphVisible = lastClickGlyphVisible;
    f.cursorDefault = cursorDefault;
    f.cursorPointed = cursorPointed;
    f.cursorWaitingClick = cursorWaitingClick;
    f.cursorDraggable = cursorDraggable;
    f.startAnchorEnabled = startAnchorEnabled;
    f.storeEnabled = storeEnabled;
    f.restoreEnabled = restoreEnabled;
    f.currentLabel = currentLabel;
    f.currentPageName = currentPageName;
    // [end_store_vars]

    // perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚È‚¢‚à‚́A‚¢‚­‚‚*B
    // Ž*“®ƒEƒFƒCƒg
    f.autoWCWaits = [];
    f.autoWCWaits.assign(autoWCWaits); // Ž*“®ƒEƒFƒCƒg‚̃EƒFƒCƒg

    // bgm
    f.bgm = bgm.store();

    // Œø‰Ê‰¹
    f.se = [];
    for(var i = 0; i<numSEBuffers; i++)
    {
    f.se[i] = se[i].store();
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„
    f.foreMessageLayers = [];
    f.backMessageLayers = [];
    for(var i = 0; i < numMessageLayers; i++)
    {
    f.foreMessageLayers[i] = fore.messages[i].store();
    f.backMessageLayers[i] = back.messages[i].store();
    }

    // ‘OŒiƒŒƒCƒ„
    f.foreCharacterLayers = [];
    f.backCharacterLayers = [];
    for(var i = 0; i < numCharacterLayers; i++)
    {
    f.foreCharacterLayers[i] = fore.layers[i].store();
    f.backCharacterLayers[i] = back.layers[i].store();
    }

    // ”wŒiƒŒƒCƒ„
    f.foreBaseLayer = fore.base.store();
    f.backBaseLayer = back.base.store();

    // ƒEƒBƒ“ƒhƒEƒLƒƒƒvƒVƒ‡ƒ“
    f.caption = caption;

    // ƒRƒ“ƒ_ƒNƒ^
    f.mainConductor = mainConductor.store();
    if(!saveMacros) f.mainConductor.macros = void;
    // ƒ}ƒNƒî•ñ‚ð void ‚ŏ㏑‚«‚·‚é‚Æžx’†‚̃}ƒNƒî•ñ‚Í–³Œø‚É‚È‚é

    // ƒƒbƒZ[ƒW—š—ð
    if(historyLayer.storeState)
    {
    f.historyData = historyLayer.save();
    }

    // ƒ€[ƒr[
    if( isMain )
    {
    f.movies = [];
    for( var i = 0; i < numMovies; i++)
    f.movies[i] = movies[i].store();
    }

    // storeHook
    forEachEventHook('onStore',
    function(handler, f) { handler(f.flags, f.options); } incontextof this,
    %[flags:f, options:void]);
    }

    function storeFlags()
    {
    // pcflags, pflags ‚É’l‚ð‘‚«ž‚Þ

    // flags -> pflags
    (Dictionary.assignStruct incontextof pflags)(flags);

    internalStoreFlags(pcflags);
    }

    function internalRestoreFlags(f, clear = true, elm = void)
    {
    // f ‚*‚çî•ñ‚ð“ǂݏo‚·
    // clear ‚ª true ‚È‚ç‚΃ƒbƒZ[ƒWƒŒƒCƒ„‚ðƒNƒŠƒA‚·‚é
    // se, bgm ‚ª‚»‚ꂼ‚ê true ‚È‚ç‚΂»‚̏î•ñ‚à”½‰f‚³‚¹‚é
    // backlay ‚ª true ‚̏ꍇ‚́A•\‰æ–ʂɃ[ƒh‚·‚ׂ«‚à‚Ì‚ð— ‰æ–ʂɃ[ƒh‚·‚é

    // KAGWindow ‚ÉŠÖ‚·‚é‚à‚Ì
    // ‚±‚±‚Ì [start_restore_vars] ‚*‚ç [end_restore_vars] ‚ň͂܂ꂽ•”•ª‚Í
    // (—ª)
    // [start_restore_vars]
    lastSaveDataName = f.lastSaveDataName if f.lastSaveDataName !== void;
    quaking = f.quaking if f.quaking !== void;
    quakeEndTick = f.quakeEndTick if f.quakeEndTick !== void;
    quakeHorzMax = f.quakeHorzMax if f.quakeHorzMax !== void;
    quakeVertMax = f.quakeVertMax if f.quakeVertMax !== void;
    quakePhase = f.quakePhase if f.quakePhase !== void;
    historyWriteEnabled = f.historyWriteEnabled if f.historyWriteEnabled !== void;
    historyEnabled = f.historyEnabled if f.historyEnabled !== void;
    numCharacterLayers = f.numCharacterLayers if f.numCharacterLayers !== void;
    numMessageLayers = f.numMessageLayers if f.numMessageLayers !== void;
    currentNum = f.currentNum if f.currentNum !== void;
    currentPage = f.currentPage if f.currentPage !== void;
    currentWithBack = f.currentWithBack if f.currentWithBack !== void;
    chUserMode = f.chUserMode if f.chUserMode !== void;
    chSpeed = f.chSpeed if f.chSpeed !== void;
    actualChSpeed = f.actualChSpeed if f.actualChSpeed !== void;
    beforeNoWaitActualChSpeed = f.beforeNoWaitActualChSpeed if f.beforeNoWaitActualChSpeed !== void;
    beforeNoWaitChUserMode = f.beforeNoWaitChUserMode if f.beforeNoWaitChUserMode !== void;
    clickSkipEnabled = f.clickSkipEnabled if f.clickSkipEnabled !== void;
    nextSkipEnabled = f.nextSkipEnabled if f.nextSkipEnabled !== void;
    canCancelSkipByClick = f.canCancelSkipByClick if f.canCancelSkipByClick !== void;
    autoWCEnabled = f.autoWCEnabled if f.autoWCEnabled !== void;
    autoWCChars = f.autoWCChars if f.autoWCChars !== void;
    rightClickEnabled = f.rightClickEnabled if f.rightClickEnabled !== void;
    rightClickCall = f.rightClickCall if f.rightClickCall !== void;
    rightClickJump = f.rightClickJump if f.rightClickJump !== void;
    rightClickTarget = f.rightClickTarget if f.rightClickTarget !== void;
    rightClickStorage = f.rightClickStorage if f.rightClickStorage !== void;
    rightClickName = f.rightClickName if f.rightClickName !== void;
    rightClickCurrentMenuName = f.rightClickCurrentMenuName if f.rightClickCurrentMenuName !== void;
    lastClickGlyphVisible = f.lastClickGlyphVisible if f.lastClickGlyphVisible !== void;
    cursorDefault = f.cursorDefault if f.cursorDefault !== void;
    cursorPointed = f.cursorPointed if f.cursorPointed !== void;
    cursorWaitingClick = f.cursorWaitingClick if f.cursorWaitingClick !== void;
    cursorDraggable = f.cursorDraggable if f.cursorDraggable !== void;
    startAnchorEnabled = f.startAnchorEnabled if f.startAnchorEnabled !== void;
    storeEnabled = f.storeEnabled if f.storeEnabled !== void;
    restoreEnabled = f.restoreEnabled if f.restoreEnabled !== void;
    currentLabel = f.currentLabel if f.currentLabel !== void;
    currentPageName = f.currentPageName if f.currentPageName !== void;
    // [end_restore_vars]

    // perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚È‚¢‚à‚́A‚¢‚­‚‚*B

    // Ž*“®ƒEƒFƒCƒg
    autoWCWaits.assign(f.autoWCWaits) if f.autoWCWaits !== void;

    // ƒ€[ƒr[
    if( isMain )
    {
    for( var i = 0; i < numMovies; i++)
    movies[i].restore(f.movies[i]);
    }

    // ”wŒiƒŒƒCƒ„
    var backlay = elm != void && elm.backlay != void && +elm.backlay;
    if(backlay)
    {
    back.base.restore(f.foreBaseLayer);
    }
    else
    {
    fore.base.restore(f.foreBaseLayer);
    back.base.restore(f.backBaseLayer);
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„
    allocateMessageLayers(numMessageLayers);
    if(backlay)
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    back.messages[i].restore(f.foreMessageLayers[i]);
    }
    }
    else
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    fore.messages[i].restore(f.foreMessageLayers[i]);
    back.messages[i].restore(f.backMessageLayers[i]);
    }
    }

    if(clear)
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    fore.messages[i].clear();
    back.messages[i].clear();
    }
    if(historyLayer.storeState)
    {
    historyLayer.load(f.historyData);
    }
    else
    {
    if(historyWriteEnabled)
    {
    if(historyLayer.everypage)
    historyLayer.repage();
    else
    historyLayer.reline(), historyLayer.reline();
    }
    historyLayer.clearAction();
    }
    }

    // ‘OŒiƒŒƒCƒ„
    allocateCharacterLayers(numCharacterLayers);
    if(backlay)
    {
    for(var i = 0; i < numCharacterLayers; i++)
    {
    back.layers[i].restore(f.foreCharacterLayers[i]);
    }
    }
    else
    {
    for(var i = 0; i < numCharacterLayers; i++)
    {
    fore.layers[i].restore(f.foreCharacterLayers[i]);
    back.layers[i].restore(f.backCharacterLayers[i]);
    }
    }

    // quake ŠÖ˜A
    restoreQuake();

    // bgm
    if(elm === void || elm.bgm === void || +elm.bgm)
    {
    bgm.restore(f.bgm);
    }

    // Œø‰Ê‰¹
    if(elm === void || elm.se === void || +elm.se)
    {
    for(var i = 0; i<numSEBuffers; i++)
    {
    se[i].restore(f.se[i]);
    }
    }

    // ƒEƒBƒ“ƒhƒEƒLƒƒƒvƒVƒ‡ƒ“
    caption = f.caption;
    System.title = caption;

    // current ‚̐ݒ肵’¼‚µ
    current = (currentPage?back:fore).messages[currentNum];

    // ‰EƒNƒŠƒbƒNƒƒjƒ…[–¼
    if(typeof this.rightClickMenuItem != "undefined")
    rightClickMenuItem.caption = rightClickCurrentMenuName;

    // restoreHook
    forEachEventHook('onRestore',
    function(handler, f) { handler(f.flags, f.clear, f.options); } incontextof this,
    %[flags:f, clear:clear, options:elm]);

    }

    function restoreFlags()
    {
    // pcflags, pflags ‚*‚çî•ñ‚ð“ǂݏo‚·

    // ƒ[ƒhŽžAƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒgî•ñ‚ðƒNƒŠƒA‚·‚é
    purgeMoviePeriod();

    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚Ì”jŠü
    freeSnapshot();

    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“AŽ*“®ˆÚ“®‚Ì’âŽ~
    stopAllTransitions();
    stopAllMoves();

    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ð‰B‚·
    hideClickGlyphs();

    // ƒƒbƒZ[ƒW—š—ð‚ð‰B‚·
    hideHistory();

    // ƒXƒLƒbƒv‚̃Lƒƒƒ“ƒZƒ‹
    cancelSkip();

    // pflags -> flags
    (Dictionary.assignStruct incontextof flags)(pflags);

    // žxŠÇ—ŠÖ˜A
    storeLabelPassed = true;
    nextRecordHistory = false;
    stablePosibility = false;

    // ƒRƒ“ƒ_ƒNƒ^
    currentRecordName = "";
    mainConductor.restore(pcflags.mainConductor);
    extraConductor.clear();
    setConductorToMain();

    // “ǂݍž‚Ý
    internalRestoreFlags(pcflags);

    // ƒƒjƒ…[ŠÖ˜A
    setMenuAccessibleAll();

    // ŽÀsŠJŽn
    processGo();
    }

    function clearVariables()
    {
    // ƒQ[ƒ€•Ï”‚̃NƒŠƒA
    (Dictionary.clear incontextof flags)();
    }

    //--------------------------------------------------------- ’ʉߋL˜^ŠÇ— --

    function pushHistoryOfStore()
    {
    // ’ʉߋL˜^‚ðs‚¤
    // pflags, pcflags ‚ɏî•ñ‚ðŠi”[‚µ‚½Œã‚ɌĂԂ±‚Æ

    if(nextRecordHistory)
    {
    if(stablePosibility)
    {
    // stablePosibility ‚ª false ‚̏ꍇ‚́A
    // ‚»‚±‚̃‰ƒxƒ‹‚ŒʉߋL˜^‚ðs‚Á‚Ä‚à
    // ‚»‚±‚æ‚è‚à‘O‚É–ß‚é‚·‚ׂª‚È‚¢‚̂ŒʉߋL˜^‚ð‚µ‚È‚¢

    // Ž«‘”z—ñ‚ðì¬
    var dic = %[];

    // user ‚Æ core ‚ð‹L˜^
    dic.user = %[];
    (Dictionary.assignStruct incontextof dic.user)(pflags);
    dic.core = %[];
    (Dictionary.assignStruct incontextof dic.core)(pcflags);

    // dic ‚ð historyOfStore ‚̐擪‚É‘}“ü
    historyOfStore.insert(0, dic);

    // ‚͂ݏo‚½•ª‚ðíœ
    if(historyOfStore.count > maxHistoryOfStore)
    historyOfStore.count = maxHistoryOfStore;
    }

    nextRecordHistory = false;
    }
    }

    function setToRecordHistory()
    {
    // ŽŸ‚́u•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹v’ʉߎž‚É
    // ’ʉߋL˜^‚ðs‚¤‚悤‚ɐݒ肷‚é
    // ( ‚½‚¾‚µA‚»‚Ì‚Æ‚«‚É‹L˜^‚³‚ê‚é‚̂́AŒ»Ý‚̏ó‘Ô )
    nextRecordHistory = true;
    }

    function isHistoryOfStoreAlive()
    {
    // ’ʉߋL˜^‚ª—˜—p‰Â”\‚*‚Ç‚¤‚*‚ð•Ô‚·
    return historyOfStore.count;
    }

    function goBackHistory(ask = true)
    {
    // ’ʉߋL˜^‚ð‚½‚Ç‚èA–ß‚é

    if(!isHistoryOfStoreAlive())
    return false;

    var result;
    if(ask)
    {
    var prompt = "u"+ historyOfStore[0].core.currentPageName + "v‚Ü‚Å–ß‚è‚Ü‚·‚*?";
    result = askYesNo(prompt);
    }
    else
    {
    result = true;
    }

    if(result)
    {
    // user ‚Æ core ‚ð pflags, pcflags ‚É–ß‚·
    (Dictionary.assignStruct incontextof pflags)(historyOfStore[0].user);
    (Dictionary.assignStruct incontextof pcflags)(historyOfStore[0].core);

    // ‹L˜^‚̐擪‚ðíœ‚·‚é
    historyOfStore.erase(0);

    // ƒf[ƒ^‚ðŒ³‚ÉAžx‚ð‚½‚Ç‚é“®ì‚ð‚·‚é
    restoreFlags();

    return true;
    }
    return false;
    }

    //--------------------------------------------------------------- žxŠÇ— --

    function createBookMarkSubMenus()
    {
    // užx‚ð‚½‚Ç‚évužx‚ð‚Í‚³‚ށvˆÈ‰º‚ɃTƒuƒƒjƒ…[€–Ú‚ð’ljÁ
    if(freeSaveDataMode) return; // ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚Å‚Í‚È‚É‚à‚µ‚È‚¢
    if(typeof this.storeMenu !== "undefined" && storeMenu.visible)
    {
    for(var i = 0; i<numBookMarks; i++)
    {
    var item;
    storeMenu.add(item = new KAGMenuItem(this, string i, 0, onBookMarkStore,
    false));
    item.bmNum = i;
    item.orgEnabled = false;
    }
    }
    if(typeof this.restoreMenu !== "undefined" && restoreMenu.visible)
    {
    for(var i = 0; i<numBookMarks; i++)
    {
    var item;
    restoreMenu.add(item = new KAGMenuItem(this, string i, 0, onBookMarkRestore,
    false));
    item.bmNum = i;
    item.orgEnabled = false;
    }
    }
    }

    function setBookMarkMenuCaptions()
    {
    // užx‚ð‚½‚Ç‚évužx‚ð‚Í‚³‚ށvˆÈ‰º‚̃Tƒuƒƒjƒ…[‚É
    // ƒLƒƒƒvƒVƒ‡ƒ“‚ðÝ’è

    // žx‚ð‹²‚Þ
    if(typeof this.storeMenu !== "undefined")
    {
    var children = storeMenu.children;
    for(var i = children.count - 1; i >= 0; i--)
    {
    if(bookMarkDates[i] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    {
    // žx‚ª‘¶Ý‚·‚é
    var caption;
    if(showBookMarkDate) caption = bookMarkDates[i] + " ";
    caption += bookMarkNames[i];
    var item = children[i];
    item.caption = caption;
    item.enabled = false;
    item.orgEnabled = !bookMarkProtectedStates[i];
    }
    else
    {
    // žx‚ª‘¶Ý‚µ‚È‚¢
    var item = children[i];
    item.caption = "(None)";
    item.enabled = false;
    item.orgEnabled = !bookMarkProtectedStates[i];
    }
    }
    }

    // žx‚ð‚½‚Ç‚é
    if(typeof this.restoreMenu !== "undefined")
    {
    var children = restoreMenu.children;
    for(var i = children.count - 1; i >= 0; i--)
    {
    if(bookMarkDates[i] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    {
    // žx‚ª‘¶Ý‚·‚é
    var caption;
    if(showBookMarkDate) caption = bookMarkDates[i] + " ";
    caption += bookMarkNames[i];
    var item = restoreMenu.children[i];
    item.caption = caption;
    item.enabled = false;
    item.orgEnabled = true;
    }
    else
    {
    var item = restoreMenu.children[i];
    item.caption = "(None)";
    item.enabled = false;
    item.orgEnabled = false;
    }
    }
    }
    setMenuAccessibleAll();
    }

    function setBookMarkProtectedState(num, s)
    {
    // n ”Ô‚Ìžx‚Ì•ÛŒìƒtƒ‰ƒO‚ðÝ’è‚·‚é
    // s = true ‚È‚ç‚Ξx‚ɏ‘‚«ž‚Ý•ÛŒì‚ð‚·‚é
    bookMarkProtectedStates[num] = s;
    setBookMarkMenuCaptions();
    }

    function onBookMarkStore(sender)
    {
    // žx‚ð‚Í‚³‚Þƒƒjƒ…[‚ª‘I‘ð‚³‚ê‚½
    // if(!sender.parent.accessEnabled) return;
    saveBookMarkWithAsk(sender.bmNum);
    }

    function onBookMarkRestore(sender)
    {
    // žx‚ð‚½‚Ç‚éƒƒjƒ…[‚ª‘I‘ð‚³‚ê‚½
    // if(!sender.parent.accessEnabled) return;
    loadBookMarkWithAsk(sender.bmNum);
    }

    function getBookMarkPageName(num)
    {
    // žx”ԍ† num ‚̃uƒbƒNƒ}[ƒN–¼‚𓾂é
    if(bookMarkDates[num] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    return bookMarkNames[num];
    return "(None)";
    }

    function getBookMarkDate(num)
    {
    // žx”ԍ† num ‚Ì“ú•t‚𓾂é
    return bookMarkDates[num];
    }

    function getBookMarkFileNameAtNum(num)
    {
    if(num >= 999) // 999 ”Ԉȍ~‚Í“ÁŽê‚ȃf[ƒ^‚É—p‚¢‚é‚Ì‚Å
    return saveDataLocation + "/" + dataName + num + ".ksd";
    else
    return saveDataLocation + "/" + dataName + num + (saveThumbnail?".bmp":".kdt");
    }

    function lockSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚ðƒƒbƒN‚·‚é
    // ‰‚߂ăXƒiƒbƒvƒVƒ‡ƒbƒg‚ªƒƒbƒN‚³‚ꂽŽž“_‚ł̉æ–Ê‚ð•Û‘¶‚·‚é
    if(snapshotLockCount == 0)
    {
    if(snapshotLayer === void)
    snapshotLayer = new Layer(this, primaryLayer);
    snapshotLayer.setImageSize(scWidth, scHeight);
    snapshotLayer.face = dfAlpha;
    snapshotLayer.piledCopy(0, 0, kag.fore.base, 0, 0, scWidth, scHeight);
    }
    snapshotLockCount ++;
    }

    function unlockSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚̃ƒbƒN‚ð‰ðœ‚·‚é
    if(snapshotLockCount == 0)
    throw new Exception("snapshotLockCount ‚ªƒAƒ“ƒ_[ƒtƒ[‚µ‚Ü‚µ‚½");
    snapshotLockCount --;
    if(snapshotLockCount == 0)
    {
    if(snapshotLayer !== void)
    invalidate snapshotLayer, snapshotLayer = void;
    }
    }

    function calcThumbnailSize()
    {
    // ƒTƒ€ƒlƒCƒ‹‚̃TƒCƒY‚ðŒvŽZ‚·‚é
    // ‰¡•‚Í 133 ‚É
    var ratio = scHeight / scWidth;
    var w = thumbnailWidth;
    var h = (int)(w * ratio);

    // ƒTƒ€ƒlƒCƒ‹—pƒrƒbƒgƒ}ƒbƒv‚̃TƒCƒY‚ðŒvŽZ
    // ƒTƒ€ƒlƒCƒ‹—p‰æ‘œ‚Í 256 F BMP ‚Ü‚½‚Í 24bit ƒtƒ‹ƒJƒ‰[ BMP
    var size;
    if (thumbnailDepth == 8)
    size = ((((w - 1) >> 2) + 1) << 2) * h + 1024 + 54;
    else
    size = (((w * 3 + 3) >> 2) << 2) * h + 54;

    return %[width : w, height : h, size : size];
    }

    function freeSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚ð‹­§“I‚É”jŠü‚µAsnapshotLockCount ‚ð 0 ‚ɐݒ肷‚é
    snapshotLockCount = 0;
    if(snapshotLayer !== void)
    invalidate snapshotLayer, snapshotLayer = void;
    }

    function saveBookMarkToFile(fn, savehist = true)
    {
    // ƒtƒ@ƒCƒ‹ fn ‚Éžx‚ð•Û‘¶‚·‚é
    if(readOnlyMode) return false;
    pcflags.storeTime = (new Date()).getTime(); // “ú•t‚ð•Û‘¶

    // ƒZ[ƒuƒf[ƒ^‚ð‚Ü‚Æ‚ß‚é
    var data = %[];
    data.id = saveDataID;
    data.core = pcflags;
    data.user = pflags;
    if(savehist) data.history = historyOfStore;

    if(saveThumbnail)
    {
    // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶
    lockSnapshot();
    try
    {
    // ƒTƒ€ƒlƒCƒ‹‚̃TƒCƒY‚܂ŏk¬
    var size = calcThumbnailSize();
    var tmp = new Layer(this, primaryLayer);
    try
    {
    tmp.setImageSize(size.width, size.height);
    tmp.face = dfAlpha;
    tmp.stretchCopy(0, 0, size.width, size.height, snapshotLayer,
    0, 0, snapshotLayer.imageWidth, snapshotLayer.imageHeight, stLinear);
    /*
    // ƒTƒ€ƒlƒCƒ‹‰æ‘œ‚ðƒZƒsƒA’²‚É‚µ‚Ä•Û‘¶‚·‚éê‡‚̓Rƒƒ“ƒgƒAƒEƒg‚ð‰ðœ
    tmp.doGrayScale();
    tmp.adjustGamma(
    1.3, 0, 255, // R gamma, floor, ceil
    1.0, 0, 255, // G gamma, floor, ceil
    0.8, 0, 255); // B gamma, floor, ceil
    */
    try
    {
    // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶
    tmp.saveLayerImage(fn, "bmp" + thumbnailDepth);

    // ƒf[ƒ^‚ð•Û‘¶
    var mode = saveDataMode;
    mode += "o" + size.size; // ƒ‚[ƒh•¶Žš—ñ‚É ‘‚«ž‚݃IƒtƒZƒbƒg‚ðŽw’è
    (Dictionary.saveStruct incontextof data)(fn, mode);
    }
    catch(e)
    {
    invalidate tmp;
    unlockSnapshot();
    System.inform("File Does not Exist (Can't Open FileA"
    "Overwriting Locked)");
    return false;
    }
    }
    catch(e)
    {
    invalidate tmp;
    throw e;
    }
    invalidate tmp;
    }
    catch(e)
    {
    unlockSnapshot();
    throw e;
    }
    unlockSnapshot();
    }
    else
    {
    // ’ʏí‚̃tƒ@ƒCƒ‹‚É•Û‘¶
    try
    {
    (Dictionary.saveStruct incontextof data)(fn, saveDataMode);
    }
    catch(e)
    {
    System.inform("File Does Not Exist (Can't Open FileA"
    "Overwriting Locked)");
    return false;
    }
    }

    return true;
    }

    function saveBookMark(num, savehist = true)
    {
    // žx”ԍ† num ‚Éžx‚ð•Û‘¶‚·‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[num]) return false;

    var ret = saveBookMarkToFile(getBookMarkFileNameAtNum(num), savehist);
    if(ret)
    {
    // ƒƒjƒ…[ / bookMarkNames / bookMarkDates ‚ðXV
    getBookMarkInfoFromData(pcflags, num);
    }
    return ret;
    }

    function getBookMarkInfoFromData(dic, num)
    {
    // Ž«‘”z—ñ dic ‚*‚çžx‚̃y[ƒW–¼‚Æ“ú•t‚ð“ǂݏo‚µA
    // bookMarkDates[num] ‚â bookMarkNames[num] ‚ɐݒ肷‚é
    if(num < numBookMarks)
    {
    bookMarkNames[num] = dic.currentPageName;
    var date = new Date();
    date.setTime(dic.storeTime);
    date = "%04d/%02d/%02d %02d:%02d".sprintf(
    date.getYear(), date.getMonth() + 1, date.getDate(),
    date.getHours(), date.getMinutes() );
    bookMarkDates[num] = date;
    setBookMarkMenuCaptions();
    saveSystemVariables();
    }
    }

    function loadBookMarkFromFile(fn, loaduser = true)
    {
    // ƒtƒ@ƒCƒ‹ fn ‚*‚çžx‚ð“ǂݍž‚Þ
    // loaduser ‚ª false ‚ÌŽž‚Í user ‚ð“ǂݍž‚Ü‚È‚¢
    try
    {
    if(!Storages.isExistentStorage(fn)) return false; //ƒtƒ@ƒCƒ‹‚ª‚È‚¢

    var data;

    var modestr;

    if(saveThumbnail)
    {
    // Žw’èƒIƒtƒZƒbƒg‚*‚çƒf[ƒ^‚ð“ǂݍž‚Þ
    modestr += "o" + calcThumbnailSize().size;
    }

    data = Scripts.evalStorage(fn, modestr);

    if(data.id != saveDataID)
    {
    System.inform("Try to Load Other System Data", "Error");
    return false;
    }

    pcflags = data.core;
    pcflags = %[] if pcflags === void;
    if(loaduser)
    {
    pflags = data.user;
    pflags = %[] if pflags === void;
    }
    else
    {
    (Dictionary.assignStruct incontextof pflags)(flags);
    }
    historyOfStore = data.history;
    historyOfStore = [] if historyOfStore === void;
    }
    catch(e)
    {
    System.inform("Save cannot be read, the save"
    "May be corrupted or have another form"
    "(" + e.message + ")", "Error");
    return false;
    }

    restoreFlags();
    return true;
    }

    function loadBookMark(num, loaduser = true)
    {
    // žx”ԍ† num ‚*‚çƒf[ƒ^‚ð“ǂݏo‚·
    return loadBookMarkFromFile(getBookMarkFileNameAtNum(num), loaduser);
    }

    function saveBookMarkWithAsk(num)
    {
    // žx”ԍ† num ‚Éžx‚ðÝ’è‚·‚é
    // ‚»‚Ì‚Æ‚«AÝ’è‚·‚é‚*‚Ç‚¤‚*‚ð‚½‚¸‚Ë‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[num]) return false;
    var prompt = "OverWrite Save ";
    if(num < numBookMarks) prompt += (num + 1);
    if(bookMarkDates[num] != "") // bookMarkDates ‚ª‹ó•¶Žš‚̏ꍇ‚Ížx‚Í‘¶Ý‚µ‚È‚¢
    prompt += "u" + bookMarkNames[num] + "v";
    prompt += "and replace withu"+ pcflags.currentPageName + "v?";
    var result = askYesNo(prompt);
    if(result) return saveBookMark(num);
    return false;
    }

    function loadBookMarkWithAsk(num)
    {
    // žx”ԍ† num ‚*‚çžx‚ð“ǂݏo‚·
    // ‚»‚Ì‚Æ‚«A“ǂݏo‚·‚*‚Ç‚¤‚*‚ð‚½‚¸‚Ë‚é
    if(num < numBookMarks && bookMarkDates[num] == "") // bookMarkDates ‚ª‹ó•¶Žš‚̏ꍇ‚Ížx‚Í‘¶Ý‚µ‚È‚¢
    return false;
    var prompt = "Load Save ";
    if(num < numBookMarks) prompt += (num + 1);
    prompt += "u"+ bookMarkNames[num] + "v?";
    var result = askYesNo(prompt);
    if(result) return loadBookMark(num);
    return false;
    }

    function saveBookMarkToFileWithAsk()
    {
    // ”CˆÓ‚̃tƒ@ƒCƒ‹‚Éžx‚ð•Û‘¶‚·‚é
    // currentPageName ‚ðƒtƒ@ƒCƒ‹–¼‚Æ‚µ‚Ä“K‡‚·‚é‚悤‚É
    // •ÏŒ`‚·‚é
    var invalid = "\\/:,;*?\"<>!.";
    var valid = "^FCG–Hhƒ„ID";

    var initialname = saveDataLocation + "/";
    var through = false;
    var orgname = currentPageName;

    if(lastSaveDataNameGlobal != "")
    {
    try
    {
    initialname = Storages.extractStoragePath(lastSaveDataNameGlobal);
    }
    catch(e)
    {
    initialname = saveDataLocation + "/";
    }
    }

    if(orgname == "")
    {
    // žx‚ÌŒ*o‚µ‚ª‚È‚¢‚Ì‚Å
    if(lastSaveDataName == "")
    orgname = System.title; // System.title ‚ð‘ã‚í‚è‚ÉŽg‚¤
    else
    initialname = lastSaveDataName, through = true;
    }

    if(!through)
    {
    var length = orgname.length;
    for(var i = 0; i < length; i++)
    {
    var ch = orgname[i];
    var ind = invalid.indexOf(ch);
    if(ind != -1)
    initialname += valid[ind];
    else if(#ch >= 32)
    initialname += ch;
    }
    }

    // •Û‘¶‚·‚éƒtƒ@ƒCƒ‹–¼‚𓾂é
    var selectdata = %[
    title:"žx‚ð‚Í‚³‚Þ",
    filter: [saveThumbnail ?
    "ƒTƒ€ƒlƒCƒ‹‰æ‘œ•t‚«žxƒf[ƒ^(*.bmp)|*.bmp" :
    "žxƒf[ƒ^(*.kdt)|*.kdt"],
    filterIndex : 1,
    name : initialname,
    initialDir : "",
    defaultExt : saveThumbnail?"bmp":"kdt",
    save : true,
    ];
    if(Storages.selectFile(selectdata))
    {
    // •Û‘¶
    saveBookMarkToFile(lastSaveDataName = lastSaveDataNameGlobal = selectdata.name);
    lastSaveDataName = Storages.chopStorageExt(lastSaveDataName);
    }
    }

    function loadBookMarkFromFileWithAsk()
    {
    // ”CˆÓ‚̃tƒ@ƒCƒ‹‚*‚çžx‚ð“ǂݍž‚Þ
    var initialdir = "";
    if(lastSaveDataNameGlobal == "")
    initialdir = saveDataLocation + "/";

    var selectdata = %[
    title:"žx‚ð‚½‚Ç‚é",
    filter: [saveThumbnail ?
    "ƒTƒ€ƒlƒCƒ‹‰æ‘œ•t‚«žxƒf[ƒ^(*.bmp)|*.bmp" :
    "žxƒf[ƒ^(*.kdt)|*.kdt"],
    filterIndex : 1,
    name : lastSaveDataNameGlobal,
    initialDir : initialdir,
    defaultExt : saveThumbnail?"bmp":"kdt",
    save : false,
    ];
    if(Storages.selectFile(selectdata))
    {
    loadBookMarkFromFile(lastSaveDataName = lastSaveDataNameGlobal = selectdata.name);
    lastSaveDataName = Storages.chopStorageExt(lastSaveDataName);
    }
    }


    function copyBookMark(from, to)
    {
    // žx”ԍ† from ‚*‚çžx”ԍ† to ‚Éžx‚ðƒRƒs[‚·‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[to]) return;

    var fn = getBookMarkFileNameAtNum(from);

    if(!Storages.isExistentStorage(fn)) return; //ƒtƒ@ƒCƒ‹‚ª‚È‚¢

    var data = Scripts.evalStorage(fn);

    fn = getBookMarkFileNameAtNum(to);

    (Dictionary.saveStruct incontextof data)(fn, saveDataMode);
    getBookMarkInfoFromData(data.core, to);
    }

    function eraseBookMark(num)
    {
    // žx‚ðÁ‚·
    // num < numBookMarks ‚ÌŽž‚É‚µ‚*“®ì‚µ‚È‚¢‚悤‚É‚È‚Á‚½‚Ì‚Å’ˆÓ
    if(num < numBookMarks)
    {
    if(!bookMarkProtectedStates[num])
    {
    bookMarkDates[num] = "";
    setBookMarkMenuCaptions();
    }
    }
    }

    function tempDisableStore(elm)
    {
    // žx‚ðˆêŽž“I‚É•Û‘¶•s‰Â”\‚É‚·‚é
    storeEnabled = true;
    if(elm.store === void)
    storeLabelPassed = false;
    else
    storeLabelPassed = !(+elm.store);
    if(elm.restore == void)
    restoreEnabled = true;
    else
    restoreEnabled = !(+elm.restore);
    setMenuAccessibleAll();
    }

    function setStoreEnabled(enabled)
    {
    // žxƒƒjƒ…[‚Ì—LŒø/–³Œø‚̐ݒè
    storeEnabled = enabled;
    restoreEnabled = enabled;
    setMenuAccessibleAll();
    }

    function setStartAnchorEnabled(enabled)
    {
    // uÅ‰‚É–ß‚év‚Ì—LŒø/–³Œø‚̐ݒè
    startAnchorEnabled = enabled;
    if(enabled) saveBookMark(999, false); // 999 ”Ô‚É•Û‘¶
    setMenuAccessibleAll();
    }

    function goToStart()
    {
    // Å‰‚É–ß‚é
    if(!startAnchorEnabled) return;
    loadBookMark(999, false); // žx‚ð“ǂݍž‚Þ
    }

    function goToStartWithAsk()
    {
    // Å‰‚É–ß‚é(Šm”F‚ ‚è)
    var result = askYesNo("Return to Title?");
    if(result) goToStart();
    }

    function tempSave(num)
    {
    // tempBookMarks[num] ‚ÉŒ»Ý‚̏ó‘Ô‚ð•Û‘¶‚·‚é
    tempBookMarks[num] = %[];
    internalStoreFlags(tempBookMarks[num]);
    }

    function tempLoad(num, elm)
    {
    // tempBookMarks[num] ‚*‚çó‘Ô‚ð“ǂݍž‚Þ
    internalRestoreFlags(tempBookMarks[num], false, elm);
    }

    function restoreBookMark(num, ask = true)
    {
    // KAG 2.x ŒÝŠ·—p
    if(ask)
    return loadBookMarkWithAsk(num);
    else
    return loadBookMark(num);
    }

    function storeBookMark(num, ask = true)
    {
    // KAG 2.x ŒÝŠ·—p
    if(ask)
    return saveBookMarkWithAsk(num);
    else
    return saveBookMark(num);
    }

    //------------------------------------------------- –¢“Ç/Šù“Ç/ƒ‰ƒxƒ‹‹L˜^ --

    function setRecordLabel(storage, label)
    {
    // Œ»Ý‚̃‰ƒxƒ‹‚ðÝ’è‚·‚é
    if(autoRecordPageShowing)
    {
    if(label != '')
    {
    if(label[0] == '*') label = label.substring(1);
    if(label[1] == '-') return; // ƒ[ƒJƒ‹ƒ‰ƒxƒ‹
    }
    currentRecordName = 'trail_' + Storages.chopStorageExt(
    Storages.extractStorageName(storage)) + '_' + label;
    }
    }

    function incRecordLabel(count)
    {
    // sflags[currentRecordName]++
    if(autoRecordPageShowing)
    {
    if(currentRecordName != "")
    {
    if(count)
    {
    if(sflags[currentRecordName] === void)
    sflags[currentRecordName] = 0;
    sflags[currentRecordName]++;
    }
    currentRecordName = "";
    }
    }
    }

    //------------------------------------------- ƒVƒXƒeƒ€‘S‘Ì‚ÉŠÖŒW‚·‚é‚à‚Ì --

    function setTitle(title)
    {
    // ƒ^ƒCƒgƒ‹‚ðÝ’è
    if(isMain) System.title = title;
    caption = title;
    }

    function setCursor(elm)
    {
    // ƒ}ƒEƒXƒJ[ƒ\ƒ‹‚̐ݒè
    var conv = function(variable, value)
    {
    if(value !== void)
    {
    if(!(typeof value == "String" &&
    (value.indexOf('.cur')!=-1 || value.indexOf('.ani')!=-1) ))
    value = +value;
    this[variable] = value;
    }
    } incontextof this;

    conv('cursorDefault', elm['default']);
    conv('cursorPointed', elm.pointed);
    conv('cursorWaitingClick', elm.click);
    conv('cursorDraggable', elm.draggable);
    fore.base.setDefaultCursor(cursorDefault);
    back.base.setDefaultCursor(cursorDefault);
    }

    //---------------------------------------------------- ƒgƒŠƒKŠÇ—(TJS—p) --

    function waitTrigger(elm)
    {
    // elm.name ‚ÅŽ¦‚³‚ꂽƒgƒŠƒK‚ð‘Ò‚Â
    if((elm.canskip !== void && +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    if(elm.onskip !== void) Scripts.eval(elm.onskip);
    return 0; // ‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function(arg)
    {
    if(arg !== void) Scripts.eval(arg);
    } incontextof this,
    click_arg : elm.onskip,
    elm.name => function
    {
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    elm.name => function
    {
    } incontextof this
    ]);
    }
    return -2;
    }

    function trigger(name)
    {
    // name ‚ÅŽ¦‚µ‚½ƒgƒŠƒK‚ð”­“®‚·‚é
    conductor.trigger(name);
    }

    //------------------------------------------------------- ƒƒbƒZ[ƒW—š—ð --

    function showHistory()
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦‚·‚é
    historyLayer.parent = fore.base; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̐e‚àÄÝ’è
    historyLayer.absolute = 2000000;
    historyLayer.dispInit();
    historyShowing = true;
    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.checked = true;
    setMenuAccessibleAll();
    }

    function hideHistory()
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð”ñ•\Ž¦‚É‚·‚é
    historyLayer.dispUninit();
    historyShowing = false;
    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.checked = false;
    setMenuAccessibleAll();
    lastHistoryHiddenTick = System.getTickCount();
    conductor.trigger('history'); // 'history' ‚ð‘—‚é
    }

    function setHistoryOptions(elm)
    {
    // elm ‚*‚烁ƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    historyWriteEnabled = +elm.output if elm.output !== void;
    historyEnabled = +elm.enabled if elm.enabled !== void;
    if(elm.enabled !== void && !historyEnabled)
    historyLayer.clearAction();
    historyLayer.setOptions(elm); // ‚»‚Ì‘¼‚̃IƒvƒVƒ‡ƒ“
    setMenuAccessibleAll();
    }

    function showHistoryByScenario(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚ðƒVƒiƒŠƒI’†‚*‚ç•\Ž¦‚³‚¹‚é
    showHistory();
    conductor.wait(%[ // ƒRƒ“ƒ_ƒNƒ^‚ð‘Ò‚¿‚É
    history : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    return -2; // break
    }

    //-------------------------------------------------------------- process --

    function process(file, label, countpage = true, immediate = false)
    {
    // Žw’èƒtƒ@ƒCƒ‹AŽw’胉ƒxƒ‹‚*‚çŽÀs‚ðŠJŽn‚·‚é
    if(!usingExtraConductor) incRecordLabel(countpage);
    setUserSpeed();

    if(file != '')
    {
    // ƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Ý
    conductor.loadScenario(file);
    }

    if(label != '')
    {
    // ƒ‰ƒxƒ‹‚Ɉړ®‚·‚é
    conductor.goToLabel(label);
    }

    if(isFirstProcess)
    {
    storeFlags(); // ˆê”ԍŏ‰‚̏ó‘Ô‚ðƒXƒgƒA
    isFirstProcess = false;
    }


    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    inSleep = false;
    notifyRun();
    if(conductor.status != conductor.mRun) conductor.run(immediate); // ŽÀsŠJŽn
    }

    function processGo()
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ðŒ»ÝˆÊ’u‚*‚çŽÀsŠJŽn‚³‚¹‚é
    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    inSleep = false;
    notifyRun();
    conductor.run(false); // ŽÀsŠJŽn
    }

    function processCall(file, label)
    {
    // Žw’èƒtƒ@ƒCƒ‹AŽw’胉ƒxƒ‹‚ðŒÄ‚Ô
    // incRecordLabel(); ‚͌Ă΂Ȃ¢‚Ì‚Å’ˆÓ

    if(file != '')
    {
    // ƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Ý
    conductor.loadScenario(file);
    }

    inSleep = false;
    notifyRun();
    conductor.callLabel(label); // ŽÀsŠJŽn
    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    if(conductor.status != conductor.mRun) conductor.run();
    }

    //------------------------------------------------- ƒRƒ“ƒ_ƒNƒ^‚̃Cƒxƒ“ƒg --

    function onConductorScenarioLoad(name)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªV‚µ‚¢ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Þ‘O‚É‚æ‚΂ê‚éB
    // name ‚͓ǂݍž‚à‚¤‚Æ‚µ‚½ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹B
    // –ß‚è’l‚É•¶Žš—ñ‚ð•Ô‚·‚ƁA‚»‚ê‚ðƒVƒiƒŠƒI‚Æ‚µ‚Ä
    // ƒtƒ@ƒCƒ‹‚Ì‘ã‚í‚è‚ÉŽg‚¤‚悤‚É‚È‚é‚̂ŁA‚±‚±‚ɃtƒBƒ‹ƒ^‚ð‘‚­‚±
    // ‚Æ‚ª‚Å‚«‚éB
    // true ‚ð•Ô‚·‚ƒʏí‚̃VƒiƒŠƒIƒtƒ@ƒCƒ‹“ǂݍž‚Ý‚Æ‚È‚éB
    return true;
    }


    function onConductorScenarioLoaded(name)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªV‚µ‚¢ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹‚ð“ǂݍž‚ñ‚¾
    // if(!usingExtraConductor) incRecordLabel(true);
    return true;
    }

    function onConductorLabel(label, page)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªƒ‰ƒxƒ‹‚ð’ʉ߂µ‚½
    if(!usingExtraConductor)
    {
    incRecordLabel(true);
    setRecordLabel(conductor.curStorage, label);
    }
    setUserSpeed();
    if(!usingExtraConductor)
    {
    if(!getCurrentRead() && skipMode != 4)
    cancelSkip(); // –¢“ǂȂ̂ŃXƒLƒbƒv‚ð’âŽ~
    currentLabel = label;
    }
    if(page !== void && page !== '')
    {
    if(page[0] == '&') page = Scripts.eval((page.substring(1)));
    currentPageName = page;
    }
    if(page !== void)
    {
    pushHistoryOfStore();
    stablePosibility = false;
    dm(conductor.curStorage + " : ƒ‰ƒxƒ‹/ƒy[ƒW : " + label + "/" + currentPageName);
    if(usingExtraConductor) throw new Exception("‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ““à/extraCondutor"
    "ƒTƒuƒ‹[ƒ`ƒ““à‚Å‚Í•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚ð‹Lq‚Å‚«‚Ü‚¹‚ñ");
    storeFlags(), storeLabelPassed = true, setMenuAccessibleAll();
    if(recordHistoryOfStore == 1) // 1 : •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚²‚Æ
    setToRecordHistory();
    }
    return true;
    }

    function onConductorJump(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚Å jump ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage === void || +elm.countpage);
    return true;
    }

    function onConductorCall(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª call ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage !== void && +elm.countpage);
    return true;
    }

    function onConductorReturn(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª return ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage === void || +elm.countpage);
    if(conductor === extraConductor)
    {
    // extraConductor ƒTƒuƒ‹[ƒ`ƒ“—p‚̃Rƒ“ƒ_ƒNƒ^‚*‚çŒÄ‚΂ê‚Ä‚¢‚é
    if(conductor.callStackDepth == 1)
    {
    // ‚‚܂èAÅI‚Ì return ‚ªŽÀs‚³‚ꂽ‚ÆŒ¾‚¤‚±‚Æ
    dm("extraConductor ƒTƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚è‚Ü‚· ...");
    var run;
    if(elm.storage !== void || elm.target !== void) run = true; else run = false;
    returnExtraConductor(run);
    if(elm.storage !== void) conductor.loadScenario(elm.storage);
    if(elm.target !== void) conductor.goToLabel(elm.target);
    setRecordLabel(conductor.curStorage, currentLabel = conductor.curLabel);
    if(run)
    {
    notifyRun();
    conductor.run();
    }
    isLeavePeriodEvent = false;
    if(elm.storage !== void || elm.target !== void)
    { // return‚ÅŒ³‚̈ʒuˆÈŠO‚ɖ߂鎞‚̓sƒŠƒIƒhƒCƒxƒ“ƒg‚ðƒNƒŠƒA‚·‚éB
    holdPeriodEventQueue.clear();
    isWaitPeriodEvent = false;
    }
    if( isWaitPeriodEvent == true )
    { // [wp]‚ŃsƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿‚ð‚µ‚Ä‚¢‚鎞‚̂݁AƒgƒŠƒK[‚·‚é
    fireMoviePeriodFromQueue();
    }
    return false; // return ‚ÍŽÀs‚µ‚È‚¢
    }
    }
    return true;
    }
    function purgeMoviePeriod()
    {
    isLeavePeriodEvent = false;
    holdPeriodEventQueue.clear();
    isWaitPeriodEvent = false;
    waitedPeriodEventStorageName = void;
    }
    function fireMoviePeriodFromQueue()
    {
    var retVal = false;
    if( holdPeriodEventQueue.count > 0 )
    {
    if( waitedPeriodEventStorageName == conductor.curStorage && conductor == mainConductor )
    {
    for( var i = 0; i < holdPeriodEventQueue.count; i++ )
    {
    conductor.trigger( holdPeriodEventQueue[i] );
    retVal = true;
    }
    }
    holdPeriodEventQueue.clear();
    }
    return retVal;
    }

    function onConductorAfterReturn()
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª return ƒ^ƒO‚ðŽÀs‚µ‚½Œã
    if(!usingExtraConductor)
    {
    setRecordLabel(conductor.curStorage, currentLabel = conductor.curLabel);
    }
    setUserSpeed();
    if(!usingExtraConductor)
    {
    if(!getCurrentRead() && skipMode != 4)
    cancelSkip(); // –¢“ǂȂ̂ŃXƒLƒbƒv‚ð’âŽ~
    }
    }


    function onConductorScript(script, scriptname, lineofs)
    {
    // iscript ƒ^ƒO
    try
    {
    Scripts.exec(script, scriptname, lineofs);
    }
    catch(e)
    {
    throw new Exception(scriptname + " ‚Ì s " + lineofs + " ‚*‚çŽn‚Ü‚é"
    " iscript ƒuƒƒbƒN‚ŃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B"
    "\n( Ú×‚̓Rƒ“ƒ\[ƒ‹‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢ )\n" + e.message);
    }
    return true;
    }

    function onConductorUnknownTag(tagname, elm)
    {
    // •s–¾‚ȃ^ƒO‚ª‚ ‚Á‚½ê‡
    throw new Exception("ƒ^ƒO/ƒ}ƒNƒ \"" + tagname + "\" ‚Í‘¶Ý‚µ‚Ü‚¹‚ñ");
    return 0; // ‚±‚Ì–ß‚è’l‚́AŠeƒ^ƒOƒnƒ“ƒhƒ‰‚ª•Ô‚·•¨‚Æ‚¨‚È‚¶
    }

    //----------------------------------------------------------- stable/run --

    function notifyStable()
    {
    // ƒVƒXƒeƒ€‚ªˆÀ’è(ƒNƒŠƒbƒN‘Ò‚¿/’âŽ~)‚µ‚½‚Æ‚«‚ɁAƒnƒ“ƒhƒ‰‚ðŒÄ‚Ô
    if(!inStable)
    {
    inStable = true;
    var handlers = stableHandlers;
    for(var i = handlers.count-1; i>=0; i--)
    handlers[i]();

    // stableHook
    forEachEventHook('onStableStateChanged',
    function(handler, f) { handler(f.stable); } incontextof this,
    %[stable:true]);
    }
    }

    function notifyRun()
    {
    // ƒVƒXƒeƒ€‚ª‘–‚èŽn‚ß‚½‚Æ‚«‚ɁAƒnƒ“ƒhƒ‰‚ðŒÄ‚Ô
    if(inStable)
    {
    inStable = false;
    var handlers = runHandlers;
    for(var i = handlers.count-1; i>=0; i--)
    handlers[i]();

    // runHook
    forEachEventHook('onStableStateChanged',
    function(handler, f) { handler(f.stable); } incontextof this,
    %[stable:false]);

    if(autoMode) hideMouseCursor();
    }
    }

    function defaultStableHandler()
    {
    // ƒfƒtƒHƒ‹ƒg‚Ì stable ƒnƒ“ƒhƒ‰
    setMenuAccessibleAll();
    }

    function defaultRunHandler()
    {
    // ƒfƒtƒHƒ‹ƒg‚Ì run ƒnƒ“ƒhƒ‰
    hideHistory();
    hideClickGlyphs();
    showMessageLayerByUser();
    setMenuAccessibleAll();
    }

    //----------------------------------------------------------- •¶Žš—ñ“ü—Í --

    var inputTemp;
    function inputString(elm)
    {
    // •¶Žš—ñ‚ð“ü—Í‚·‚é
    var name = elm.name;
    var initial = Scripts.eval(name);
    var res = System.inputString(elm.title, elm.prompt, initial);
    if(res !== void)
    {
    // name ‚É res ‚ð‘ã“ü‚·‚é
    inputTemp = res;
    Scripts.eval(("(" + name + ") = kag.inputTemp"));
    }
    }

    //-------------------------------------------------- extraConductor ˆ— --

    function callExtraConductor(storage, label, onreturn)
    {
    // extraConductor ‚ðŽg‚Á‚ăTƒuƒ‹[ƒ`ƒ“‚ðŒÄ‚яo‚·
    onExtraConductorReturn = onreturn;
    inSleepBeforeExtraConductor = inSleep; // inSleep •Û‘¶
    storeMessageLayerSelProcessLock(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì storeSelProcessLock ‚ðŒÄ‚Ô
    conductor = extraConductor; // ƒRƒ“ƒ_ƒNƒ^‚ðØ‚è‘Ö‚¦‚é
    (Dictionary.assign incontextof extraConductor.macros)(mainConductor.macros);
    // ƒ}ƒNƒ‚̓Rƒs[
    usingExtraConductor = true;
    if(storage == '')
    {
    // ƒXƒgƒŒ[ƒWŽw’肪‚È‚¢‚Ì‚ÅŒ»Ý‚̃XƒgƒŒ[ƒW‚ð“ǂݍž‚Ü‚¹‚é
    storage = mainConductor.curStorage;
    }

    // ŒÄ‚яo‚·
    conductor.clearCallStack();
    processCall(storage, label);
    }

    function returnExtraConductor(run)
    {
    // extraConductor ‚̃Tƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚é
    // run ‚ª true ‚̏ꍇ‚Í ‘Ò‹@ó‘Ô‚Ì•œ‹A‚͍s‚í‚È‚¢

    conductor.sleep(); // ’âŽ~
    conductor.interrupt();
    // interrupt ‚Í ƒRƒ“ƒ_ƒNƒ^‚̃Cƒxƒ“ƒg“à‚ŃRƒ“ƒ_ƒNƒ^‚ÌŽÀs‚ð
    // ’âŽ~‚³‚¹‚邽‚߂̃ƒ\ƒbƒh
    conductor = mainConductor; // ƒRƒ“ƒ_ƒNƒ^‚ðØ‚è‘Ö‚¦
    (Dictionary.assign incontextof mainConductor.macros)(extraConductor.macros);
    // ƒ}ƒNƒ‚̓Rƒs[
    usingExtraConductor = false;
    if(!run)
    { restoreClickGlyphState(); // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚Ì•œ‹A
    inSleep = inSleepBeforeExtraConductor; // inSleep •œ‹A
    notifyStable();
    }
    restoreMessageLayerSelProcessLock(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì restoreSelProcessLock ‚ðŒÄ‚Ô
    setMenuAccessibleAll();
    cancelSkip();

    if(onExtraConductorReturn !== void) onExtraConductorReturn();
    }

    //------------------------------------------------------- ‰EƒNƒŠƒbƒNˆ— --

    function setRightClickOptions(elm)
    {
    // ‰EƒNƒŠƒbƒN‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    rightClickEnabled = +elm.enabled if elm.enabled !== void;
    if(elm.call !== void)
    {
    rightClickCall = +elm.call;
    if(rightClickCall) rightClickJump = false;
    }
    if(elm.jump !== void)
    {
    rightClickJump = +elm.jump;
    if(rightClickJump) rightClickCall = false;
    }
    rightClickTarget = elm.target if elm.target !== void;
    rightClickStorage = elm.storage if elm.storage !== void;
    if(elm.name !== void)
    {
    if(typeof this.rightClickMenuItem != "undefined")
    {
    rightClickName = elm.name;
    if(rightClickName == "default")
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    else
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickName;
    }
    }
    }

    function callRightClickSubRoutine()
    {
    isLeavePeriodEvent = true;

    // ‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚ðŒÄ‚Ô
    if(typeof this.rightClickMenuItem != "undefined")
    {
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    }

    callExtraConductor(rightClickStorage, rightClickTarget, restoreFromRightClick);

    lockMessageLayerSelProcess(); // ‘I‘ðŽˆƒƒbƒN
    }

    function restoreFromRightClick()
    {
    // ‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚*‚甲‚¯‚é‚Æ‚«‚ɌĂ΂ê‚é
    if(typeof this.rightClickMenuItem != "undefined")
    {
    if(rightClickName == "default")
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    else
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickName;
    }
    }

    function setConductorToMain()
    {
    // restore ‚ÌŽž‚ɌĂ΂êAƒRƒ“ƒ_ƒNƒ^‚ð main ‚ɐ؂è‘Ö‚¦‚é
    if(usingExtraConductor)
    {
    extraConductor.sleep();
    extraConductor.interrupt();
    conductor= mainConductor;
    usingExtraConductor = false;
    }
    }

    function jumpToRightClickTarget()
    {
    process(rightClickStorage, rightClickTarget);
    }

    function onPrimaryRightClick()
    {
    // ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ʼnEƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂ΂ê‚é
    if(!callHook(rightClickHook))
    {
    if(getKeyState(VK_LBUTTON))
    {
    enterAutoMode();
    return;
    }
    if(!rightClickEnabled) return;
    if(inStable)
    {
    if(rightClickJump)
    jumpToRightClickTarget();
    else if(rightClickCall && conductor == mainConductor)
    callRightClickSubRoutine();
    else
    switchMessageLayerHiddenByUser();
    }
    setMenuAccessibleAll();
    }
    }

    //------------------------------------------------------- ‘OŒiƒŒƒCƒ„ˆ— --

    function allocateCharacterLayers(num)
    {
    // ‘OŒiƒŒƒCƒ„”‚ð num ‚ɐݒ肷‚é
    if(fore.layers.count > num)
    {
    // ƒŒƒCƒ„‚ªŒ¸‚é
    for(var i = num; i<fore.layers.count; i++)
    {
    invalidate fore.layers[i];
    invalidate back.layers[i];
    }
    fore.layers.count = num;
    back.layers.count = num;
    }
    else if(fore.layers.count < num)
    {
    // ƒŒƒCƒ„‚ª‘‚¦‚é
    for(var i = fore.layers.count; i<num; i++)
    {
    fore.layers[i] = new CharacterLayer(this, fore.base, "•\‘OŒiƒŒƒCƒ„" + i, i);
    back.layers[i] = new CharacterLayer(this, back.base, "— ‘OŒiƒŒƒCƒ„" + i, i);
    fore.layers[i].setCompLayer(back.layers[i]);
    back.layers[i].setCompLayer(fore.layers[i]);
    }
    reorderLayers();
    }
    numCharacterLayers = num;
    }

    //------------------------------------------------- ƒƒbƒZ[ƒWƒŒƒCƒ„ˆ— --

    function allocateMessageLayers(num, setdefaultfont = true)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„”‚ð num ‚ɐݒ肷‚é
    if(fore.messages.count > num)
    {
    // ƒŒƒCƒ„‚ªŒ¸‚é
    for(var i = num; i<fore.messages.count; i++)
    {
    if(current == fore.messages[i] || current == back.messages[i])
    current = fore.messages[0], currentNum = 0, currentPage = 0;
    invalidate fore.messages[i];
    invalidate back.messages[i];
    }
    fore.messages.count = num;
    back.messages.count = num;
    }
    else if(fore.messages.count < num)
    {
    // ƒŒƒCƒ„‚ª‘‚¦‚é
    for(var i = fore.messages.count; i<num; i++)
    {
    fore.messages[i] = new MessageLayer(this, fore.base, "•\ƒƒbƒZ[ƒWƒŒƒCƒ„" + i, i, true);
    back.messages[i] = new MessageLayer(this, back.base, "— ƒƒbƒZ[ƒWƒŒƒCƒ„" + i, i, true);
    fore.messages[i].setCompLayer(back.messages[i]);
    back.messages[i].setCompLayer(fore.messages[i]);
    fore.messages[i].clear();
    back.messages[i].clear();
    }
    reorderLayers();
    if(setdefaultfont) setMessageLayerUserFont();
    }
    numMessageLayers = num;
    }

    function setCurrentMessageLayer(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ðÝ’è
    var page = getMessageLayerPageFromElm(elm);
    var num = getMessageLayerNumberFromElm(elm);
    currentNum = num;
    currentPage = page;
    if(page) current = back.messages[num]; else current = fore.messages[num];
    currentWithBack = +elm.withback if elm.withback !== void;
    }

    function setMessageLayerPosition(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̈ʒuA‘®«‚ðÝ’è
    var layer = getMessageLayerObjectFromElm(elm);
    elm.setPosition(elm);
    }

    function clearMessageLayers(resetcurrent)
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    // ct ƒ^ƒO‚*‚çŒÄ‚΂ê‚é
    // resetcurrent ‚ª true ‚̏ꍇ‚ÍŒ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ð
    // •\0‚ɐݒ肷‚é

    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].clear();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].clear();
    if(resetcurrent)
    {
    currentNum = 0;
    currentPage = 0;
    current = fore.messages[0];
    currentWithBack = false;
    }
    }

    function lockMessageLayerSelProcess()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚É ‘I‘ð‚Æprocess‚ð‹ÖŽ~‚³‚¹‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(true);
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(true);
    }

    function unlockMessageLayerSelProcess()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì‘I‘ð‚ð‹–‰Â‚·‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(false);
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(false);
    }

    function setMessageLayerUserFont()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì defaultAntialiased ‚Æ
    // userFace ‚ðÝ’è‚·‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--)
    messages[i].defaultAntialiased = chDefaultAntialiased,
    messages[i].userFace = chDefaultFace;
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--)
    messages[i].defaultAntialiased = chDefaultAntialiased,
    messages[i].userFace = chDefaultFace;
    }

    function storeMessageLayerSelProcessLock()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì storeSelProcessLock ‚ðŒÄ‚яo‚·
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].storeSelProcessLock();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].storeSelProcessLock();
    }

    function restoreMessageLayerSelProcessLock()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì restoreSelProcessLock ‚ðŒÄ‚яo‚·
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].restoreSelProcessLock();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].restoreSelProcessLock();
    }

    function setMessageLayerHiddenState(b)
    {
    var layers;
    layers = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].setHiddenStateByUser(b);
    layers = fore.layers;
    for(var i = layers.count-1; i >= 0; i--) layers[i].setHiddenStateByUser(b);

    // ƒvƒ‰ƒOƒCƒ“‚ðŒÄ‚Ô
    forEachEventHook('onMessageHiddenStateChanged',
    function(handler, f) { handler(f.hidden); } incontextof this,
    %[hidden:b]);
    }

    function hideMessageLayerByUser()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ðˆêŽž“I‚ɉB‚·
    if(messageLayerHiding) return;
    setMessageLayerHiddenState(true);
    if(typeof this.rightClickMenuItem !== "undefined")
    rightClickMenuItem.checked = true;
    messageLayerHiding = true;
    fore.base.cursor = cursorWaitingClick;
    setMenuAccessibleAll();
    }

    function showMessageLayerByUser()
    {
    // ˆêŽž“I‚ɉB‚³‚ê‚Ä‚¢‚½ƒƒbƒZ[ƒWƒŒƒCƒ„‚ðŒ³‚É–ß‚·
    if(!messageLayerHiding) return;
    setMessageLayerHiddenState(false);
    if(typeof this.rightClickMenuItem !== "undefined")
    rightClickMenuItem.checked = false;
    messageLayerHiding = false;
    conductor.trigger('message'); // 'message' ‚ð‘—‚é
    if(clickWaiting)
    fore.base.cursor = cursorWaitingClick;
    else
    fore.base.cursor = cursorDefault;
    setMenuAccessibleAll();
    }

    function switchMessageLayerHiddenByUser()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì”ñ•\Ž¦/•\Ž¦‚ðØ‚è‘Ö‚¦‚é
    if(messageLayerHiding) showMessageLayerByUser(); else hideMessageLayerByUser();
    }

    function hideMessageLayerByScenario(elm)
    {
    // ƒVƒiƒŠƒI‚*‚烁ƒbƒZ[ƒW‚ðˆêŽž“I‚ɉB‚·
    hideMessageLayerByUser();
    conductor.wait(%[ // ƒRƒ“ƒ_ƒNƒ^‚ð‘Ò‚¿‚É
    message : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    return -2; // break
    }

    function selectFont()
    {
    // ƒtƒHƒ“ƒg‚ð‘I‘ð‚·‚é
    fore.base.font.face = chDefaultFace;
    fore.base.font.height = -20;
    var flags = fsfSameCharSet | fsfNoVertical | fsfTrueTypeOnly | fsfUseFontFace;
    if(showFixedPitchOnlyInFontSelector) flags |= fsfFixedPitch;
    if(fore.base.font.doUserSelect(flags, "ƒtƒHƒ“ƒg‚Ì‘I‘ð",
    "ƒtƒHƒ“ƒg‚ð‘I‘ð‚µ‚Ä‚­‚¾‚³‚¢", "ABCDEFGHI‚ ‚¢‚¤‚¦‚¨ˆŸˆÝ‰FŠGŒä"))
    {
    chDefaultFace = fore.base.font.face;
    setMessageLayerUserFont();
    }
    }

    function mapPrerenderedFont(storage)
    {
    // ƒŒƒ“ƒ_ƒŠƒ“ƒOÏ‚݃tƒHƒ“ƒg‚ðŒ»Ý‚Ì‘€ì‘Ώۂ̃ŒƒCƒ„‚É‘I‘ð
    // ‚³‚ê‚Ä‚¢‚éƒtƒHƒ“ƒg‚Ƀ}ƒbƒsƒ“ƒO‚·‚é
    current.decideSizeChange();
    current.lineLayer.font.mapPrerenderedFont(storage);
    }

    //------------------------------------------------- ƒŒƒCƒ„‚𐳂µ‚¢‡˜‚É --

    function reorderLayers()
    {
    // ƒŒƒCƒ„‚𐳂µ‚¢‡˜‚É•À‚Ñ‘Ö‚¦‚é
    var index = 1000;
    for(var i = 0; i<fore.layers.count; i++)
    {
    fore.layers[i].absolute = index;
    back.layers[i].absolute = index;
    index += 1000;
    }
    index = 1000000;
    for(var i = 0; i<fore.messages.count; i++)
    {
    fore.messages[i].absolute = index;
    back.messages[i].absolute = index;
    index += 1000;
    }

    historyLayer.absolute = 2000000;

    }

    //--------------------------------------------- ‘®«->ƒŒƒCƒ„ƒIƒuƒWƒFƒNƒg --

    function getLayerFromElm(elm, prefix = '')
    {
    // elm ‚ÉŽw’肳‚ê‚Ä‚¢‚é page ‚Æ layer ‘®«‚*‚çAŠY“–‚·‚é
    // ƒIƒuƒWƒFƒNƒg‚ð•Ô‚·
    // prefix ‚ɂ́A‘®«–¼‚Ì‘O‚ɂ‚¯‚éƒvƒŒƒtƒBƒNƒX‚ðŽw’è‚·‚é
    var base;
    if(elm[prefix + 'page'] == 'back') base = back; else base = fore;
    var layer = elm[prefix + 'layer'];
    if(layer == 'base') return base.base; // ”wŒi
    if(layer[0] == 'm')
    {
    // message? ( ? = ”’l )
    // ‚±‚±‚Å‚Í‚ ‚܂茵–§‚ɃGƒ‰[ƒ`ƒFƒbƒN‚Í‚µ‚È‚¢
    if(layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }
    return base.layers[+layer];
    }

    function getLayerPageFromElm(elm, backlay)
    {
    // getLayerFromElm ‚ÆŽ—‚Ä‚¢‚邪Apage ‘®«‚Ü‚Å‚Í‚Ý‚È‚¢B
    // backlay ‚ª true ‚Ì‚Æ‚«‚Í— Afalse ‚ÌŽž‚Í•\‚̃ŒƒCƒ„‚ð•Ô‚·B
    // elm.layer ‚ª void ‚ÌŽž‚Í”wŒiƒŒƒCƒ„‚ð‹A‚·
    var base = backlay?back:fore;
    var layer = elm.layer;
    if(layer === void || layer == 'base') return base.base; // ”wŒi
    if(layer[0] == 'm')
    {
    if(layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }
    return base.layers[+layer];
    }

    function getMessageLayerPageFromElm(elm)
    {
    // elm ‚*‚çŠY“–‚·‚é•\/— ‰æ–ʂ̃ƒbƒZ[ƒWƒŒƒCƒ„”z—ñ‚ð•Ô‚·
    if(elm.page == 'back') return 1; else return 0;
    }

    function getMessageLayerNumberFromElm(elm)
    {
    // elm ‚Ì layer ‘®«‚ÌŽ¦‚·ƒƒbƒZ[ƒWƒŒƒCƒ„”ԍ†‚ð•Ô‚·
    var layer = elm.layer;
    if(layer === void || layer == 'message') return currentNum;
    return +layer.substr(7);
    }

    function getMessageLayerObjectFromElm(elm)
    {
    // elm ‚Ì layer ‘®«‚ÌŽ¦‚·ƒƒbƒZ[ƒWƒŒƒCƒ„‚ð•Ô‚·
    var page = elm.page;
    var layer = elm.layer;
    if(page === void && layer === void) return current;
    var base;
    if(page == 'back') base = back; else base = fore;
    if(layer === void || layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }

    function getMessageLayerObjectFromPageAndNumber(page, num)
    {
    return (page?back:fore).messages[num];
    }

    //----------------------------------------------------- ƒŒƒCƒ„ƒRƒs[ŠÖ˜A --

    function backupLayer(elm, toback)
    {
    // ƒŒƒCƒ„‚Ì•\*¨— ŠÔ‚̃Rƒs[‚ðs‚¤
    // toback = true ‚̏ꍇ‚Í•\¨— Afalse ‚̏ꍇ‚Í— ¨•\
    if(elm.layer !== void)
    {
    // ƒŒƒCƒ„Žw’肪‚ ‚é
    getLayerPageFromElm(elm, toback).assignComp(); // ‘΂̃ŒƒCƒ„‚Ì“à—e‚ðƒRƒs[
    }
    else
    {
    // ƒŒƒCƒ„Žw’肪–³‚¢‚Ì‚Å‘S•”‚̃ŒƒCƒ„‚ðƒRƒs[
    var base = toback ? back:fore;
    base.base.assignComp();
    var layers = base.layers, messages = base.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].assignComp();
    for(var i = messages.count-1; i >= 0; i--) messages[i].assignComp();

    forEachEventHook('onCopyLayer',
    function(handler, f) { handler(f.toback); } incontextof this,
    %[toback:toback]);
    }
    }

    function copyLayer(elm)
    {
    // elm ‚ɏ]‚Á‚Ä“¯Ží‚̃ŒƒCƒ„ŠÔ‚̃Rƒs[‚ðs‚¤
    var src = getLayerFromElm(elm, 'src');
    var dest = getLayerFromElm(elm, 'dest');
    dest.assign(src);
    }

    //--------------------------------------------------- ƒAƒjƒ[ƒVƒ‡ƒ“ŠÖ˜A --

    function onAnimationStopped(name, segment)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚ª’âŽ~‚µ‚½
    conductor.trigger('anim:' + name + ':' + segment);
    }

    function waitAnimation(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‚ð‚Ü‚Â
    var layer = getLayerFromElm(elm);
    var seg = +elm.seg;
    if(!layer.canWaitAnimStop(seg)) return 0; // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‚ð‘Ò‚Â
    conductor.wait(%[
    'anim:' + layer.name + ':' + seg => function
    {
    } incontextof this
    ]);
    return -2;
    }

    //--------------------------------------------------- ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ŠÖ˜A --

    function onLayerTransitionCompleted(layer, dest, src)
    {
    // ƒŒƒCƒ„‚Ńgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ªI—¹‚µ‚½‚Æ‚«‚ɌĂ΂ê‚é
    conductor.trigger('trans'); // 'trans' ‚ð‘—‚é
    }

    function waitTransition(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Â
    if(transCount == 0) return 0; // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Ä‚È‚¢
    if((elm.canskip === void || +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    stopAllTransitions();
    return 0; // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚³‚¹‚Ä‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    updateBeforeCh = 1;
    stopAllTransitions(); // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚Í’âŽ~
    } incontextof this,
    trans : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    trans : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    return -2;
    }

    function stopAllTransitions()
    {
    // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚³‚¹‚é
    var layers, messages;
    fore.base.stopTransition();
    layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopTransition();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopTransition();
    back.base.stopTransition();
    layers = back.layers, messages = back.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopTransition();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopTransition();
    transCount = 0; // ˆê‰ž
    }

    function callExchangeInfo()
    {
    // ‚·‚ׂĂ̔wŒiƒŒƒCƒ„‚ð‚Ì‚¼‚­•\ƒŒƒCƒ„‚ɑ΂µ‚Ä
    // exchangeInfo ‚ðŒÄ‚Ô
    var layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].exchangeInfo();
    for(var i = messages.count-1; i >= 0; i--) messages[i].exchangeInfo();
    }

    function callAssignTransSrc()
    {
    // ‚·‚ׂĂ̔wŒiƒŒƒCƒ„‚ð‚Ì‚¼‚­•\ƒŒƒCƒ„‚ɑ΂µ‚Ä
    // assignTransSrc ‚ðŒÄ‚Ô
    var layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].assignTransSrc();
    for(var i = messages.count-1; i >= 0; i--) messages[i].assignTransSrc();
    forEachEventHook('onCopyLayer',
    function(handler, f) { handler(f.toback); } incontextof this,
    %[toback:false]);
    }

    function exchangeForeBack()
    {
    // ƒŒƒCƒ„‚Ì— ‚Æ•\‚ðŽæ‚è‘Ö‚¦‚é
    var tmp = fore;
    fore = back;
    back = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    forEachEventHook('onExchangeForeBack',
    function(handler, f) { handler(); } incontextof this);
    }

    function swapBaseLayer()
    {
    // ”wŒiƒŒƒCƒ„‚Ì‚Ý‚ðŽæ‚è‘Ö‚¦‚é
    var tmp = fore.base;
    fore.base = back.base;
    back.base = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    }

    function swapCharacterLayer(id)
    {
    // ‘OŒiƒŒƒCƒ„‚Ì•\‚Æ— ‚ðŽæ‚è‘Ö‚¦‚é
    var fl = fore.layers, bl = back.layers;
    var tmp = fl[id];
    fl[id] = bl[id];
    bl[id] = tmp;
    }

    function swapMessageLayer(id)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì•\‚Æ— ‚ðŽæ‚è‘Ö‚¦‚é
    var fl = fore.messages, bl = back.messages;
    var tmp = fl[id];
    fl[id] = bl[id];
    bl[id] = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    }

    //--------------------------------------------------------- Ž*“®ˆÚ“®ŠÖ˜A --

    function onLayerMoveStop()
    {
    // ƒŒƒCƒ„‚ÌŽ*“®ˆÚ“®‚ªI—¹‚µ‚½
    conductor.trigger('move');
    }

    function waitMove(elm)
    {
    // Ž*“®ˆÚ“®‚ð‘Ò‚Â
    if(moveCount == 0) return 0; // Ž*“®ˆÚ“®‚ð‘Ò‚Ä‚È‚¢
    if((elm.canskip === void || +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    stopAllMoves();
    return 0; // Ž*“®ˆÚ“®‚ð’âŽ~‚³‚¹‚Ä‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    updateBeforeCh = 1;
    stopAllMoves(); // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚Í’âŽ~
    } incontextof this,
    move : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    move : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    return -2;
    }

    function stopAllMoves()
    {
    // ‚·‚ׂĂ̎*“®ˆÚ“®‚ð’âŽ~‚³‚¹‚é
    var layers, messages;
    fore.base.stopMove();
    back.base.stopMove();
    layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopMove();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopMove();
    layers = back.layers, messages = back.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopMove();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopMove();
    moveCount = 0; // ˆê‰ž
    }

    //------------------------------------------------ ƒfƒBƒŒƒC/ƒXƒLƒbƒvŠÖ˜A --

    function setDelay(elm)
    {
    // delay ƒ^ƒO‚̏ˆ—
    var speed = elm.speed;
    if(speed == 'nowait')
    {
    chSpeed = 0;
    chUserMode = false;
    }
    else if(speed == 'user')
    {
    chUserMode = true;
    setUserSpeed();
    }
    else
    {
    chSpeed = +speed;
    chUserMode = false;
    }
    if(!skipMode) actualChSpeed = chSpeed;
    }

    function getCurrentRead()
    {
    // Œ»Ý‚̃VƒiƒŠƒI•”•ª‚ªŠù“Ç‚*‚Ç‚¤‚*‚ð”»’è‚·‚é
    return autoRecordPageShowing && currentRecordName != "" &&
    +sflags[currentRecordName] || !autoRecordPageShowing;
    }

    function setUserSpeed()
    {
    // ƒ†[ƒU‚Ì‘I‘ð‚µ‚½•¶Žš•\Ž¦ƒXƒs[ƒh‚ðÝ’è
    // ‚±‚̊֐”‚ð“Ç‚ñ‚¾Žž“_‚Å‚·‚Å‚É userChSpeed ‚É‚Í
    // ‚ ‚½‚炵‚¢’l‚ªÝ’肳‚ê‚Ä‚¢‚é‚Æ‚Ý‚È‚·B
    // ‚ ‚é‚¢‚́Aƒ‰ƒxƒ‹‚²‚ƂɁA‚»‚Ì‹æˆæ‚ªŠù“Ç‚*–¢“Ç‚*‚Å
    // •\Ž¦ƒXƒs[ƒh‚ð•Ï‚¦‚é–Ú“I‚ŌĂ΂ê‚é
    if(chUserMode)
    {
    if(getCurrentRead())
    chSpeed = userCh2ndSpeed==-1?userChSpeed:userCh2ndSpeed; // Šù“Ç
    else
    chSpeed = userChSpeed; // Т҂
    }
    if(!skipMode) actualChSpeed = chSpeed;
    }

    function skipToClick()
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚܂ŃXƒLƒbƒv
    skipMode = 1;
    actualChSpeed = 0;
    }

    function skipToPage()
    {
    // ‰üƒy[ƒW‘Ò‚¿‹L†‚܂ŃXƒLƒbƒv
    skipMode = 2;
    actualChSpeed = 0;
    }

    function skipToStop()
    {
    // ŽŸ‚Ì’âŽ~‚܂ŃXƒLƒbƒv
    onPrimaryClick(); // ƒNƒŠƒbƒN‚Ì“®ì‚ðƒGƒ~ƒ…ƒŒ[ƒg‚·‚é
    skipMode = 3;
    actualChSpeed = 0;
    }

    function skipToStop2()
    {
    // ŽŸ‚Ì’âŽ~‚܂ŃXƒLƒbƒv(‘‘—‚胂[ƒh)
    onPrimaryClick();
    skipMode = 4;
    actualChSpeed = 0;
    }

    function cancelSkip()
    {
    // ƒXƒLƒbƒv“®ì‚ðƒLƒƒƒ“ƒZƒ‹
    skipMode = 0;
    skipKeyRepressed = false;
    actualChSpeed = chSpeed;
    }

    function enterNoWait()
    {
    // nowait ƒ^ƒO‚̏ˆ—
    beforeNoWaitActualChSpeed = actualChSpeed;
    beforeNoWaitChUserMode = chUserMode;
    actualChSpeed = 0;
    }

    function leaveNoWait()
    {
    // endnowait ƒ^ƒO‚̏ˆ—
    actualChSpeed = beforeNoWaitActualChSpeed;
    chUserMode = beforeNoWaitChUserMode;
    }

    function setAutoWait(elm)
    {
    // Ž*“®ƒEƒFƒCƒg‚ðÝ’è‚·‚é
    autoWCEnabled = +elm.enabled if elm.enabled !== void;
    autoWCChars = elm.ch if elm.ch !== void;
    autoWCWaits = [].split(",", elm.time) if elm.time !== void;
    }

    function cancelAutoMode()
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̃Lƒƒƒ“ƒZƒ‹
    if(autoMode)
    {
    autoMode = false;
    if(typeof this.autoModeMenuItem !== "undefined")
    autoModeMenuItem.checked = false;
    var t = conductor.lastTagName;
    if(t == 'p'){
    showPageBreak();
    }
    else if(t == 'l'){
    showLineBreak(%[canskip: false]);
    }
    }
    }

    function enterAutoMode()
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚É“ü‚é
    if(typeof this.autoModeMenuItem !== "undefined")
    autoModeMenuItem.checked = true;
    if(inStable)
    onPrimaryClick();
    autoMode = true;
    }

    //--------------------------------------------------------- ƒEƒFƒCƒgŠÖ˜A --

    function resetWait()
    {
    // ŽžŠÔŒ´“_‚̃ŠƒZƒbƒg
    timeOrigin = System.getTickCount();
    }

    function waitTime(waittime, canskip)
    {
    // waittime •ª‘Ò‚Â
    if(waittime == 0) return 0;
    if(canskip)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚Í‚È‚É‚à‚¹‚¸‚É•Ô‚é
    }
    conductor.waitWithTimeOut(%[
    click : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    timeout : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ], waittime);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.waitWithTimeOut(%[
    timeout : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ], waittime);
    }
    return -2; // break

    }

    function doWait(elm)
    {
    // wait ƒ^ƒO‚̏ˆ—
    var waittime;
    if(elm.mode == 'until')
    {
    // until ƒ‚[ƒh
    waittime = timeOrigin + +elm.time - System.getTickCount();
    if(waittime < 0) { lastWaitTime = 0; return 0; } // ‚·‚Å‚ÉŽžŠÔ‚ªŒo‰ß‚µ‚Ä‚¢‚é
    lastWaitTime = waittime;
    if(waittime < 6) return 0; // ‚ ‚Ü‚è‚É‘Ò‚¿ŽžŠÔ‚ª’Z‚¢‚Ì‚Å‘Ò‚½‚È‚¢
    }
    else
    {
    waittime = +elm.time;
    }
    return waitTime(waittime, (elm.canskip === void || +elm.canskip) && clickSkipEnabled);
    }

    function doWaitCh(elm)
    {
    // +elm.time ‚̃JƒEƒ“ƒg•ªA‘Ò‚Â
    var t = elm.time;
    return waitTime(actualChSpeed * (t === void ? 1 : +t),
    (elm.canskip === void || +elm.canskip) && clickSkipEnabled);
    }

    //------------------------------------------------------------ quakeŠÖ˜A --

    function doQuake(elm)
    {
    // elm ‚ɏ]‚Á‚Ä quake ‚ðŠJŽn
    if(elm.time !== void)
    {
    if(defaultQuakeTimeInChUnit)
    {
    if(elm.timemode == 'ms')
    quakeEndTick = System.getTickCount() + +elm.time;
    else
    quakeEndTick = System.getTickCount() + +elm.time * chSpeed;
    }
    else
    {
    if(elm.timemode == 'delay')
    quakeEndTick = System.getTickCount() + +elm.time * chSpeed;
    else
    quakeEndTick = System.getTickCount() + +elm.time;
    }
    }
    else
    {
    quakeEndTick = -1;
    }

    if(elm.hmax !== void) quakeHorzMax = +elm.hmax; else quakeHorzMax = 10;
    if(elm.vmax !== void) quakeVertMax = +elm.vmax; else quakeVertMax = 10;

    quakeTimer.enabled = true;
    quaking = true;
    }

    function restoreQuake()
    {
    // restore ‚*‚çŒÄ‚΂êAžx‚ð•Û‘¶‚µ‚½‚Æ‚«‚É—h‚ê‚Ä‚¢‚½ê‡‚Í—h‚ç‚·
    if(quaking && quakeEndTick == -1)
    quakeTimer.enabled =true;
    }

    function stopQuake()
    {
    // —h‚ê‚ð’âŽ~
    setLayerPos(0, 0);
    quakeTimer.enabled = false;
    quaking = false;
    conductor.trigger('quake');
    }

    function onQuakeTimerInterval()
    {
    // quakeTimer ‚É‚æ‚èŒÄ‚΂ê‚é
    if(quakeEndTick != -1 && System.getTickCount() > quakeEndTick) { stopQuake(); return; }
    if(historyShowing)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„•\Ž¦’†‚Í‚³‚·‚ª‚É—h‚ê‚Ä‚¢‚ç‚ê‚È‚¢
    setLayerPos(0, 0);
    return;
    }
    var x, y;
    if(quakeHorzMax == quakeVertMax)
    {
    // ‚¾‚¢‚½‚¢“¯‚¶
    x = int(Math.random() * quakeHorzMax - quakeHorzMax);
    y = int(Math.random() * quakeVertMax - quakeVertMax);
    }
    else if(quakeHorzMax < quakeVertMax)
    {
    // c—h‚ê
    x = int(Math.random() * quakeHorzMax - quakeHorzMax);
    y = int((quakePhase ? Math.random() : -Math.random()) * quakeVertMax);
    }
    else
    {
    // ‰¡—h‚ê
    x = int((quakePhase ? Math.random() : -Math.random()) * quakeHorzMax);
    y = int(Math.random() * quakeVertMax - quakeVertMax);
    }
    quakePhase = !quakePhase;
    setLayerPos(x, y);
    }

    function waitQuake(elm)
    {
    // —h‚ꂪI—¹‚·‚é‚Ü‚Å‚Ü‚Â
    if(!quaking || quakeEndTick == -1) return 0; // —h‚ê‚Ä‚¢‚È‚¯‚ê‚Α҂½‚È‚¢
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    stopQuake();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚Í—h‚ê‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    stopQuake(); // —h‚ê‚Í’âŽ~‚·‚é
    } incontextof this,

    quake : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    quake : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    //------------------------------------------------------------- ƒNƒŠƒbƒN --

    function onPrimaryClick()
    {
    // ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ŁuƒNƒŠƒbƒN‚Ì“®ìv‚ª‚È‚É‚àƒtƒBƒ‹ƒ^ƒŠƒ“ƒO‚³‚ê‚È‚*‚Á‚½
    // ‚Æ‚«Aƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚*‚çŒÄ‚΂ê‚éB
    clickCount ++;
    if(!callHook(leftClickHook))
    {
    if(messageLayerHiding)
    {
    showMessageLayerByUser(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ð•\Ž¦‚·‚é
    }
    else
    {
    var st = conductor.status;
    var runst = conductor.mRun;
    var stopst = conductor.mStop;

    if(st != stopst && autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    cancelAutoMode();
    }
    else if(st != stopst && canCancelSkipByClick && skipMode && skipMode != 4)
    {
    // ƒNƒŠƒbƒN‚É‚æ‚éƒXƒLƒbƒv‚Ì‰ðœ‚ª‰Â”\
    cancelSkip();
    }
    else
    {
    // ‚±‚ÌŽž“_‚ŃtƒBƒ‹ƒ^ƒŠƒ“ƒO‚³‚ê‚È‚¢ƒƒbƒZ[ƒW‚Í‘Ò‚¿ó‘Ԃ̃NƒŠƒA‚È‚Ì‚Å
    // conductor ‚É 'click' ‚ð‘—‚è‰ðœ‚ð“`‚¦‚éB

    if(!conductor.trigger('click')) // ‘Ò‚¿ó‘Ô‚Å‚È‚¢ê‡‚Í’P‚É–³Ž‹‚³‚ê‚é
    {
    // ƒnƒ“ƒhƒ‰‚ªŒ*‚‚*‚ç‚È‚¢‚ȂǁAˆ—‚³‚ê‚È‚*‚Á‚½ê‡
    if(st == runst && clickSkipEnabled && skipMode == 0)
    {
    // ƒNƒŠƒbƒN‚É‚æ‚éƒXƒLƒbƒv‚ª‰Â”\
    skipToClick();
    }
    }
    }
    }
    }
    }

    function onPrimaryClickByKey()
    {
    // ƒL[‚ª‰Ÿ‚³‚ꂽ‚Æ‚«ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ðƒNƒŠƒbƒN‚µ‚½‚Ì‚Æ
    // “¯‚¶“®ì‚ð‚·‚é‚ªA‚³‚ç‚Ɉꎞ“I‚Ƀ}ƒEƒXƒJ[ƒ\ƒ‹‚ð‰B‚·
    onPrimaryClick();
    hideMouseCursor();
    }

    function waitClick(elm)
    {
    // ƒNƒŠƒbƒN‚ð‘Ò‚Â
    conductor.wait(%[
    click : function
    {
    } incontextof this]);
    return -2;
    }

    function onMouseDown(x, y)
    {
    lastMouseDownX = x;
    lastMouseDownY = y;
    super.onMouseDown(...);
    }

    //------------------------------------------------------- ƒL[ƒ{[ƒh‘€ì --

    function processKeys(key, shift)
    {
    if(checkProceedingKey(key, shift)) return;

    if(key == #'F')
    {
    // ŽŸ‚Ì‘I‘ðŽˆ/–¢“ǂ܂Ői‚Þ
    skipToNextStopByKey();
    return;
    }

    if(key == #'B')
    {
    // ‘O‚É–ß‚é
    goBackByKey();
    return;
    }

    if(key == #'A')
    {
    // Ž*“®“I‚ɓǂݐi‚ß‚é
    switchAutoModeByKey();
    return;
    }

    if(freeSaveDataMode)
    {
    if(key == #'S')
    {
    // žx‚ð‚Í‚³‚Þ
    if(typeof this.storeMenu != "undefined" && storeMenu.enabled)
    storeMenu.click();
    return;
    }

    if(key == #'L')
    {
    // žx‚ð‚½‚Ç‚é
    if(typeof this.restoreMenu != "undefined" && restoreMenu.enabled)
    restoreMenu.click();
    return;
    }
    }

    if(key == #'R' || (key == VK_UP && (shift & ssShift)))
    {
    // ƒƒbƒZ[ƒW—š—ð‚ð•\Ž¦
    showHistoryByKey();
    return;
    }

    if(key == VK_ESCAPE)
    {
    // ƒƒbƒZ[ƒW‚ðÁ‚·
    if(typeof this.rightClickMenuItem != "undefined" &&
    rightClickMenuItem.enabled)
    {
    rightClickMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    return;
    }
    }
    }

    function preProcessKeys(key, shift)
    {
    return callHook(keyDownHook, key, shift);
    }

    function internalOnKeyDown(key, shift)
    {
    if(!preProcessKeys(key, shift)) processKeys(key, shift);
    }

    function checkProceedingKey(key, shift)
    {
    // key ‚ª“Ç‚Ý‚·‚·‚݂̃L[ ( ƒXƒy[ƒXƒL[‚*ReturnƒL[ ) ‚̏ꍇ‚Í
    // ƒL[‚ðˆ—‚µAtrue ‚ð•Ô‚·B‚»‚¤‚Å‚È‚¯‚ê‚Î false ‚ð•Ô‚·
    if(key == VK_RETURN || key == VK_SPACE)
    {
    // ƒL[‚ªƒƒbƒZ[ƒWƒLƒ…[‚É—­‚Ü‚Á‚Ä‚éê‡‚ª‚ ‚é‚Ì‚Å
    // ŽÀÛ‚É‚»‚̃L[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚Ì‚*‚Ç‚¤‚*‚ð
    // getKeyState ‚ð—p‚¢‚Ä’²‚ׂé
    var sg = getKeyState;
    if(sg(VK_RETURN) || sg(VK_SPACE))
    {
    // ƒL[‚ª‰Ÿ‚³‚ê‚Ä‚½
    if((shift & ssRepeat) && clickSkipEnabled &&
    conductor.status == conductor.mRun)
    {
    // ƒL[ƒŠƒs[ƒg
    if(skipMode != 4 && skipKeyRepressed)
    skipToStop2(); // ‚Ü‚¾skipMode 4‚É“ü‚Á‚Ä‚¢‚È‚¢ê‡‚Í‘‘—‚胂[ƒh‚É“ü‚é
    // skipKeyRepressed ‚ðƒ`ƒFƒbƒN‚·‚é‚Ì‚Í
    // ˜A‘±‚µ‚ăL[ƒŠƒs[ƒg‚ª”­¶‚µ‚Ä‚¢‚é‚Æ‚«‚É
    // cancelSkip Œã‚ɃXƒLƒbƒv‚É“Ë“ü‚·‚é‚Ì‚ð–h‚®‚½‚ß
    }
    else
    {
    skipKeyRepressed = true;
    onPrimaryClickByKey();
    }
    return true;
    }
    }

    return false;
    }

    function skipCancelKeyPressing()
    {
    // ƒXƒLƒbƒv‚ð‰ðœ‚·‚é—vˆö‚Æ‚È‚éƒL[‚ ‚é‚¢‚̓}ƒEƒXƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚*
    var sg = getKeyState;
    return sg(VK_RETURN) || sg(VK_SPACE) || sg(VK_LBUTTON);
    }

    function skipKeyPressing()
    {
    // VK_RETURN ‚ ‚é‚¢‚Í VK_SPACE ‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚*‚Ç‚¤‚*
    var sg = getKeyState;
    return sg(VK_RETURN) || sg(VK_SPACE);
    }

    function goBackByKey()
    {
    if(typeof this.goBackMenuItem != "undefined" &&
    goBackMenuItem.enabled)
    goBackMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function skipToNextStopByKey()
    {
    if(typeof this.skipToNextStopMenuItem != "undefined" &&
    skipToNextStopMenuItem.enabled)
    skipToNextStopMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function showHistoryByKey()
    {
    if(typeof this.showHistoryMenuItem != "undefined" &&
    showHistoryMenuItem.enabled)
    showHistoryMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function switchAutoModeByKey()
    {
    if(typeof this.autoModeMenuItem != "undefined" &&
    autoModeMenuItem.enabled)
    autoModeMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function onKeyDown(key, shift)
    {
    if(focusedLayer === null)
    internalOnKeyDown(key, shift);
    super.onKeyDown(...);
    }

    function onMouseWheel(shift, delta, x, y)
    {
    // ƒzƒC[ƒ‹‚ª‰ñ“]‚µ‚½
    super.onMouseWheel(...);
    if(!historyLayer.visible)
    {
    if(delta > 0)
    showHistoryByKey(); // ƒƒbƒZ[ƒW—š—ð‚ð•\Ž¦
    else if(System.getTickCount() - lastHistoryHiddenTick > 150)
    onPrimaryClick(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    // ª tick ‚ð”äŠr‚µ‚Ä‚¢‚é‚̂́AƒƒbƒZ[ƒW—š—ð‚ð‰B‚·‘€ì‚ƃzƒC[ƒ‹‚ð
    // Žè‘O‚ɉñ‚·‘€ì‚ª˜A‘±‚µ‚½ê‡‚ɏŸŽè‚ɓǂݐi‚Þ‚Ì‚ð‚ ‚é’ö“x–h‚®ŽdŠ|‚¯
    }
    else
    {
    // ƒƒbƒZ[ƒW—š—ð‚ɃCƒxƒ“ƒg‚𐂂ꗬ‚·
    historyLayer.windowMouseWheel(shift, delta, x, y);
    }
    }

    //------------------------------------------------- ƒNƒŠƒbƒN‘Ò‚¿‹L†ˆ— --

    function hideClickGlyphs()
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ð”ñ•\Ž¦‚É
    lineBreak.visible = false;
    pageBreak.visible = false;
    if(conductor == mainConductor)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏ó‘Ô‚ð‹L˜^
    lastClickGlyphVisible = false;
    }
    }

    function storeClickGlyphState(which)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏î•ñ‚ðˆêŽž“I‚É‘Ò”ð
    // ‚±‚̃f[ƒ^‚͉EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚âextraConductorƒTƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚é‚Æ‚«‚ÉŽQÆ‚·‚é
    if(conductor == mainConductor)
    {
    lastClickGlyphVisible = true;
    lastClickGlyphMessagePage = currentPage;
    lastClickGlyphMessageNum = currentNum;
    lastClickGlyphWhich = which;
    }
    }

    function restoreClickGlyphState()
    {
    // lastClickGlyph *** ‚Ɉꎞ“I‚É‘Ò”ð‚µ‚½ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏î•ñ
    // ‚ÉŠî‚¢‚ăNƒŠƒbƒN‘Ò‚¿‹L†‚ðÝ’è‚·‚é
    if(lastClickGlyphVisible)
    {
    var layer = getMessageLayerObjectFromPageAndNumber
    (lastClickGlyphMessagePage, lastClickGlyphMessageNum);
    if(layer !== void)
    {
    switch(lastClickGlyphWhich)
    {
    case 'line':
    layer.showLineBreakGlyph(lineBreak);
    break;
    case 'page':
    layer.showPageBreakGlyph(pageBreak);
    break;
    }
    }
    }
    }

    function canIgnoreL()
    {
    // L ƒ^ƒO‚𖳎‹‚Å‚«‚é‚*‚Ç‚¤‚*
    return chNonStopToPageBreak || (getCurrentRead() && ch2ndNonStopToPageBreak);
    }

    function showLineBreak(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ɍs‘Ò‚¿‹L†‚ð•\Ž¦‚·‚é
    stablePosibility = true;
    if(canIgnoreL())
    {
    // l ƒ^ƒO‚Ì–³Ž‹
    if(elm.canskip === void || !+elm.canskip)
    return (skipMode==3 || skipMode==4) ? 0 : -4;
    }
    if(autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    return autoModeLineWait;
    }
    if(skipMode == 1) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    if(skipMode == 4) return -4;
    if(skipMode) return skipCancelKeyPressing()?-4:0;
    // ƒXƒLƒbƒv’†(ƒXƒLƒbƒv‚ðƒLƒƒƒ“ƒZƒ‹‚·‚é‚悤‚ȃL[‚ª‚ ‚ê‚΃XƒLƒbƒv‰ðœ
    // ‚Ì‚½‚߂̃Cƒxƒ“ƒgˆ—‚Ì‹@‰ï‚ð—^‚¦‚é)

    current.showLineBreakGlyph(lineBreak);
    storeClickGlyphState("line");

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚ōsƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -2;
    }

    function showPageBreak(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚Ƀy[ƒW‘Ò‚¿‹L†‚ð•\Ž¦‚·‚é
    stablePosibility = true;
    if(skipMode == 1 || skipMode == 2) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    if(skipMode) return -4; // ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—
    if(autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    return autoModePageWait;
    }

    current.showPageBreakGlyph(pageBreak);
    storeClickGlyphState("page");

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚Ńy[ƒWƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -2;
    }

    function showPageBreakAndClear()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ªÅIs‚Ü‚Å’B‚µ‚ÄŽ*“®‰üƒy[ƒW‚ª‚³‚ê‚é‚Æ‚«‚É
    // ŒÄ‚΂ê‚éBŒ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚Ƀy[ƒW‘Ò‚¿‹L†‚ð•\Ž¦‚µA
    // ŽÀsÄŠJŽž‚É‚Í MessageLayer.clear2 ‚ðŒÄ‚Ô
    stablePosibility = true;
    if(skipMode == 1 || skipMode == 2) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    var lasttagname = conductor.lastTagName;
    if(!autoMode && ((!canIgnoreL() && lasttagname == 'l') || lasttagname == 'p'))
    { current.clear2(); return -5; }// ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—(ƒ^ƒO‚ÍŒã‰ñ‚µ)
    if(skipMode) { current.clear2(); return -5; }// ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—(ƒ^ƒO‚ÍŒã‰ñ‚µ)

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚ÅŽ*“®‰üƒy[ƒWƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    if(autoMode)
    {
    conductor.waitWithTimeOut(%[ // ƒ^ƒCƒ€ƒAƒEƒg•t‚«ƒEƒFƒCƒg
    click : function
    {
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    cancelAutoMode();
    } incontextof this,
    timeout : function
    {
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    } incontextof this
    ], autoModePageWait <= 0 ? 1 : autoModePageWait);
    return -3;
    }
    else
    {
    current.showPageBreakGlyph(pageBreak);
    storeClickGlyphState("page");

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -3;
    }
    }

    //------------------------------------------------------------- BGM ˆ— --

    function onBGMFadeCompleted()
    {
    // BGM ‚̃tƒF[ƒh‚ªŠ®—¹‚µ‚½
    conductor.trigger('bgmfade');
    }

    function onBGMStop()
    {
    // BGM ‚ª’âŽ~‚µ‚½
    conductor.trigger('bgmstop');
    }

    function waitBGMFade(elm)
    {
    // BGM ‚̃tƒF[ƒhI—¹‚ð‘Ò‚Â
    if(!bgm.inFading) return 0; // ƒtƒF[ƒh’†‚Å‚È‚¯‚ê‚Α҂½‚È‚¢
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    bgm.stopFade();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚̓tƒF[ƒh‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    bgm.stopFade(); // ƒtƒF[ƒfƒBƒ“ƒO‚Í’âŽ~‚·‚é
    } incontextof this,

    bgmfade : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    bgmfade : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    function waitBGMStop(elm)
    {
    // BGM ‚̍жI—¹‚ð‘Ò‚Â
    if(!bgm.canWaitStop) return 0; // BGM Ä¶I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    bgm.stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    bgm.stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    bgmstop : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    bgmstop : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    //----------------------------------------------------------- Œø‰Ê‰¹ˆ— --

    function onSESoundBufferFadeCompleted(id)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh‚ªI—¹‚µ‚½
    conductor.trigger('sefade' + id);
    }

    function onSESoundBufferStop(id)
    {
    // Œø‰Ê‰¹‚̍ж‚ªI—¹‚µ‚½
    conductor.trigger('sestop' + id);
    }

    function waitSEFade(elm)
    {
    var id = +elm.buf;
    var buf = se[id];
    if(!buf.inFading) return 0; // ƒtƒF[ƒh’†‚Å‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    buf.stopFade();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚̓tƒF[ƒh‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    se[id].stopFade(); // ƒtƒF[ƒh‚ðI—¹‚·‚é
    } incontextof this,

    click_arg : id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'sefade'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sefade'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'sefade'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sefade'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    function waitSEStop(elm)
    {
    var id = +elm.buf;
    var buf = se[id];
    if(!buf.canWaitStop()) return 0; // I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü•Ô‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    buf.stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    se[id].stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    'click_arg' => id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'sestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'sestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    //--------------------------------------------------------- ƒ€[ƒr[ŠÖ˜A --

    function onMovieStop(id)
    {
    // ƒ€[ƒr[‚̍ж‚ªI—¹‚µ‚½
    conductor.trigger('moviestop'+id);
    }

    function waitMovieStop(elm)
    {
    var id = +elm.slot;

    // ƒ€[ƒr[‚̍жI—¹‚ð‘Ò‚Â
    if(!movies[id].canWaitStop) return 0; // ƒ€[ƒr[Ä¶I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    movies[id].stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    movies[id].stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    'click_arg' => id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'moviestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'moviestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'moviestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'moviestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    function onMoviePeriod(id,type)
    {
    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ª”­¶‚µ‚½
    if( isLeavePeriodEvent != false )
    {
    holdPeriodEventQueue.add( 'movieperiod'+id+'_'+type );
    }
    else
    {
    conductor.trigger('movieperiod'+id+'_'+type);
    }
    }

    function waitMoviePeriod(elm)
    {
    isWaitPeriodEvent = true;
    waitedPeriodEventStorageName = conductor.curStorage;

    var id = +elm.slot;

    stablePosibility = true;

    if( holdPeriodEventQueue.count > 0 )
    {
    var triggered = false;
    for( var i = 0; i < holdPeriodEventQueue.count; i++ )
    {
    if( elm.for !== void )
    {
    if( elm.for == 'loop' )
    {
    if( ('movieperiod'+id+'_'+perLoop) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'period' )
    {
    if( ('movieperiod'+id+'_'+perPeriod) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'prepare' )
    {
    if( ('movieperiod'+id+'_'+perPrepare) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'segLoop' )
    {
    if( ('movieperiod'+id+'_'+perSegLoop) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else
    {
    triggered == true;
    }
    }
    else
    {
    triggered == true;
    }
    }
    holdPeriodEventQueue.clear();
    if( triggered == true )
    {
    isWaitPeriodEvent = false;
    return 0;
    }
    }

    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð‘Ò‚Â
    if(!movies[id].canWaitStop) return 0; // ƒ€[ƒr[‚ªÄ¶’†‚Å‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if( elm.for !== void )
    {
    if( elm.for == 'loop' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'period' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perPeriod => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'prepare' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perPrepare => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'segLoop' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perSegLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    return 0; // ˆø”‚ª•Ï
    }
    }
    else
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perPeriod => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perPrepare => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perSegLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    notifyStable();
    return -2;
    }

    //------------------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ --

    function getHandlers()
    {
    return %[ // Ž«‘”z—ñƒIƒuƒWƒFƒNƒg

    /*
    ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ‚́A–¼‘O‚Æ‚»‚ê‚ɑΉž‚·‚éŠÖ”‚̃yƒA‚ð—ñ‹“‚·‚é‚à‚̂ŁA
    ŠÖ”–¼ : function(elm)
    {
    // ŠÖ”‚Ì’†g
    } incontextof this,
    ‚̏‘Ž®‚ð—p‚¢‚éB‚½‚¾‚µAŠÖ”–¼‚ª—\–ñŒê‚̏ꍇ‚́AuŠÖ”–¼ : v‚Å‚Í‚È‚­
    u"ŠÖ”–¼" => v‚ð—p‚¢‚éB
    incontextof this ‚́AŠÖ”‚ª³‚µ‚­ ‚±‚̃Nƒ‰ƒX‚Ì
    ƒIƒuƒWƒFƒNƒg‚̃Rƒ“ƒeƒLƒXƒgã‚Å“®‚­‚悤‚É‚·‚邽‚ß‚É•K—vB
    */

    //--------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒƒbƒZ[ƒW‘€ì) --

    ch : function(elm)
    {
    // •¶Žš•\Ž¦
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    var text = elm.text;
    if(currentWithBack) current.comp.processCh(text);
    if(current.processCh(text))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled) historyLayer.store(text);
    if(autoWCEnabled)
    {
    // Ž*“®ƒEƒFƒCƒg
    var ind;
    if((ind = autoWCChars.indexOf(text)) != -1)
    {
    return int(acs * autoWCWaits[ind]);
    }
    }
    return acs;
    } incontextof this,

    graph : function(elm)
    {
    // ƒOƒ‰ƒtƒBƒbƒN‚𕶎š‚Æ‚µ‚Ä•\Ž¦
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    if(currentWithBack) current.comp.processGraph(elm);
    if(current.processGraph(elm))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled && elm.alt !== void) historyLayer.store(elm.alt);
    return acs;
    } incontextof this,

    hch : function(elm)
    {
    // c’†‰¡
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    var text = elm.text;
    var expand = elm.expand !== void && +elm.expand;
    if(currentWithBack) current.comp.putHorizonCh(text, expand);
    if(current.putHorizonCh(text, expand))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled) historyLayer.store(text);
    return acs;
    } incontextof this,

    r : function(elm)
    {
    // ‰üs
    if(historyWriteEnabled) historyLayer.reline();
    if(currentWithBack) current.comp.processReturn();
    if(current.processReturn())
    {
    var ret = showPageBreakAndClear();
    // ‰üs‚Ípending‚µ‚È‚¢
    if(ret == -5)
    ret = -4;
    else if(ret == -3)
    ret = -2;
    return ret;
    }
    return actualChSpeed;
    } incontextof this,

    ruby : function(elm)
    {
    // ŽŸ‚Ì•¶Žš‚ɑ΂·‚郋ƒrÝ’è
    if(currentWithBack) current.comp.setRuby(elm.text);
    current.setRuby(elm.text);
    return 0;
    } incontextof this,

    font : function(elm)
    {
    // ƒtƒHƒ“ƒgÝ’è
    if(currentWithBack) current.comp.setFont(elm);
    current.setFont(elm);
    return 0;
    } incontextof this,

    deffont : function(elm)
    {
    // ƒfƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒgÝ’è
    if(currentWithBack) current.comp.setDefaultFont(elm);
    current.setDefaultFont(elm);
    return 0;
    } incontextof this,

    resetfont : function(elm)
    {
    // ƒtƒHƒ“ƒg‚̃ŠƒZƒbƒg
    if(currentWithBack) current.comp.resetFont();
    current.resetFont();
    return 0;
    } incontextof this,

    style : function(elm)
    {
    // ƒXƒ^ƒCƒ‹Ý’è
    if(currentWithBack) current.comp.setStyle(elm);
    current.setStyle(elm);
    return 0;
    } incontextof this,

    defstyle : function(elm)
    {
    // ƒfƒtƒHƒ‹ƒg‚̃Xƒ^ƒCƒ‹Ý’è
    if(currentWithBack) current.comp.setDefaultStyle(elm);
    current.setDefaultStyle(elm);
    return 0;
    } incontextof this,

    resetstyle : function(elm)
    {
    // ƒXƒ^ƒCƒ‹‚̃ŠƒZƒbƒg
    if(currentWithBack) current.comp.resetStyle();
    current.resetStyle();
    return 0;
    } incontextof this,

    link : function(elm)
    {
    // ƒnƒCƒp[ƒŠƒ“ƒN‚ÌŠJŽn
    if(currentWithBack) current.comp.beginHyperLink(elm);
    current.beginHyperLink(elm);
    return 0;
    } incontextof this,

    endlink : function(elm)
    {
    // ƒnƒCƒp[ƒŠƒ“ƒN‚̏I—¹
    if(currentWithBack) current.comp.endHyperLink(elm);
    current.endHyperLink(elm);
    return 0;
    } incontextof this,

    button : function(elm)
    {
    // ƒOƒ‰ƒtƒBƒJƒ‹ƒ{ƒ^ƒ“
    if(currentWithBack) current.comp.addButton(elm);
    current.addButton(elm);
    return 0;
    } incontextof this,

    edit : function(elm)
    {
    // ’Pˆês•ÒW
    if(currentWithBack) current.comp.addEdit(elm);
    current.addEdit(elm);
    return 0;
    } incontextof this,

    checkbox : function(elm)
    {
    // ’Pˆês•ÒW
    if(currentWithBack) current.comp.addCheckBox(elm);
    current.addCheckBox(elm);
    return 0;
    } incontextof this,

    commit : function(elm)
    {
    // ƒtƒH[ƒ€—v‘f‚̃Rƒ~ƒbƒg
    current.commit();
    return 0;
    } incontextof this,

    l : function(elm)
    {
    // sƒNƒŠƒbƒN‘Ò‚¿
    return showLineBreak(elm);
    } incontextof this,

    p : function(elm)
    {
    // ƒy[ƒWƒNƒŠƒbƒN‘Ò‚¿
    if(historyWriteEnabled) historyLayer.reline();
    return showPageBreak(elm);
    } incontextof this,

    current : function(elm)
    {
    // ‘€ì‘Ώۂ̃ƒbƒZ[ƒWƒŒƒCƒ„‚ÌŽw’è
    setCurrentMessageLayer(elm);
    return 0;
    } incontextof this,

    position : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̈ʒuA‘®«‚ðÝ’è
    getMessageLayerObjectFromElm(elm).setPosition(elm);
    return 0;
    } incontextof this,

    ct : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃ŠƒZƒbƒg(‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA‚Æ
    // current ‚̃ŠƒZƒbƒg)
    if(historyWriteEnabled) historyLayer.repage();
    clearMessageLayers(true);
    return 0;
    } incontextof this,

    cm : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃ŠƒZƒbƒg‚ðs‚¤‚ªAct ‚̂悤‚É
    // current ‚̃ŠƒZƒbƒg‚͍s‚í‚È‚¢‚à‚Ì
    if(historyWriteEnabled) historyLayer.repage();
    clearMessageLayers(false);
    return 0;
    } incontextof this,

    er : function(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    if(historyWriteEnabled) historyLayer.repage();
    if(currentWithBack) current.comp.clear();
    current.clear();
    return 0;
    } incontextof this,

    indent : function(elm)
    {
    // ƒCƒ“ƒfƒ“ƒg‚̐ݒè
    if(currentWithBack) current.comp.setIndent();
    current.setIndent();
    if(historyWriteEnabled) historyLayer.beginIndent();
    return 0;
    } incontextof this,

    endindent : function(elm)
    {
    // ƒCƒ“ƒfƒ“ƒg‚̉ðœ
    if(currentWithBack) current.comp.resetIndent();
    current.resetIndent();
    if(historyWriteEnabled) historyLayer.endIndent();
    return 0;
    } incontextof this,

    delay : function(elm)
    {
    // •¶Žš•\Ž¦‘¬“x‚ÌŽw’è
    setDelay(elm);
    return 0;
    } incontextof this,

    nowait : function(elm)
    {
    // ˆêŽž“I‚Ƀm[ƒEƒFƒCƒg‚ÅŽÀs
    enterNoWait();
    return 0;
    } incontextof this,

    endnowait : function(elm)
    {
    // nowait ‚̉ðœ
    leaveNoWait();
    return 0;
    } incontextof this,

    locate : function(elm)
    {
    // •¶Žš•\Ž¦ˆÊ’u‚ðŽw’è
    if(currentWithBack) current.comp.locate(elm.x, elm.y);
    current.locate(elm.x, elm.y);
    return 0;
    } incontextof this,

    glyph : function(elm)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ðŽw’è
    current.setGlyph(elm);
    return 0;
    } incontextof this,

    locklink : function(elm)
    {
    // ƒŠƒ“ƒN‚̃ƒbƒN
    lockMessageLayerSelProcess();
    return 0;
    } incontextof this,

    unlocklink : function(elm)
    {
    // ƒŠƒ“ƒN‚̃Aƒ“ƒƒbƒN
    unlockMessageLayerSelProcess();
    return 0;
    } incontextof this,

    //----------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒVƒXƒeƒ€‘€ì) --

    loadplugin : function(elm)
    {
    // ƒvƒ‰ƒOƒCƒ“‚̓ǂݍž‚Ý
    Plugins.link(elm.module);
    dm("ƒvƒ‰ƒOƒCƒ“‚ð“ǂݍž‚Ý‚Ü‚µ‚½ : " + elm.module);
    return 0;
    } incontextof this,

    title : function(elm)
    {
    // ƒ^ƒCƒgƒ‹‚̐ݒè
    setTitle(elm.name);
    return 0;
    } incontextof this,

    s : function(elm)
    {
    // ŽÀs’âŽ~
    stablePosibility = true;
    cancelSkip();
    if(!usingExtraConductor) incRecordLabel(true);
    inSleep = true;
    if(recordHistoryOfStore == 2) // 2 : ‘I‘ðŽˆ ( @s ƒ^ƒO ) ‚²‚Æ
    setToRecordHistory();
    notifyStable();
    return -1;
    } incontextof this,

    clickskip : function(elm)
    {
    // ƒNƒŠƒbƒNƒXƒLƒbƒv‚̐ݒè
    clickSkipEnabled = +elm.enabled;
    return 0;
    } incontextof this,

    nextskip : function(elm)
    {
    // ŽŸ‚Ì‘I‘ðŽˆ(/–¢“Ç)‚܂Ői‚ނ̐ݒè
    nextSkipEnabled = +elm.enabled;
    return 0;
    } incontextof this,

    cancelskip : function(elm)
    {
    // ƒXƒLƒbƒv‚̉ðœ
    cancelSkip();
    return 0;
    } incontextof this,

    cancelautomode : function(elm)
    {
    // uŽ*“®“I‚ɓǂݐi‚ށv‚̉ðœ
    cancelAutoMode();
    return 0;
    } incontextof this,

    resetwait : function(elm)
    {
    // ŽžŠÔŒ´“_‚̐ݒè
    resetWait();
    return 0;
    } incontextof this,

    wait : function(elm)
    {
    // ƒEƒFƒCƒg
    return doWait(elm);
    } incontextof this,

    wc : function(elm)
    {
    // Žw’蕶Žš•ª‚̃EƒFƒCƒg
    return doWaitCh(elm);
    } incontextof this,

    waitclick : function(elm)
    {
    // ƒNƒŠƒbƒN‚ð‘Ò‚Â
    return waitClick(elm);
    } incontextof this,

    rclick : function(elm)
    {
    // ‰EƒNƒŠƒbƒN‚Ì“®ìÝ’è
    setRightClickOptions(elm);
    return 0;
    } incontextof this,

    history : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̐ݒè
    setHistoryOptions(elm);
    return 0;
    } incontextof this,

    showhistory : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚Ì•\Ž¦
    return showHistoryByScenario(elm);
    } incontextof this,

    hr : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ɉüs‚ðo—Í
    if(historyWriteEnabled)
    {
    if(elm.repage !== void && +elm.repage)
    historyLayer.repage();
    else
    historyLayer.reline();
    }
    return 0;
    } incontextof this,

    hact : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚ɃAƒNƒVƒ‡ƒ“‚ðÝ’è
    if(historyWriteEnabled)
    historyLayer.setNewAction(elm.exp);
    return 0;
    } incontextof this,

    endhact : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚̃AƒNƒVƒ‡ƒ“‚ðƒNƒŠƒA
    if(historyWriteEnabled)
    historyLayer.clearAction();
    return 0;
    } incontextof this,

    hidemessage : function(elm)
    {
    // ƒƒbƒZ[ƒW‚ðˆêŽž“I‚ɉB‚·
    return hideMessageLayerByScenario(elm);
    } incontextof this,

    quake : function(elm)
    {
    // —h‚ê
    doQuake(elm);
    return 0;
    } incontextof this,

    stopquake : function(elm)
    {
    // —h‚ê‚Ì’âŽ~
    stopQuake();
    return 0;
    } incontextof this,

    wq : function(elm)
    {
    // —h‚ê‚Ì’âŽ~‚ð‘Ò‚Â
    return waitQuake(elm);
    } incontextof this,

    autowc : function(elm)
    {
    // Ž*“®ƒEƒFƒCƒg
    setAutoWait(elm);
    return 0;
    } incontextof this,

    cursor : function(elm)
    {
    // ƒ}ƒEƒXƒJ[ƒ\ƒ‹‚̕ύX
    setCursor(elm);
    return 0;
    } incontextof this,

    close : function(elm)
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    closeByScript(elm);
    return -2;
    } incontextof this,

    copybookmark : function(elm)
    {
    // žx‚ðƒRƒs[
    copyBookMark(+elm.from, +elm.to);
    return 0;
    } incontextof this,

    erasebookmark : function(elm)
    {
    // žx‚ðíœ
    eraseBookMark(+elm.place);
    return 0;
    } incontextof this,

    disablestore : function(elm)
    {
    // žx‚ðˆêŽž“I‚ÉŽg—p•s‰Â‚É
    tempDisableStore(elm);
    return 0;
    } incontextof this,

    store : function(elm)
    {
    // žx‚ÌŽg—p•s‰ÂEŽg—p‰Â‚ðÝ’è‚·‚é
    setStoreEnabled(+elm.enabled);
    return 0;
    } incontextof this,

    load : function(elm)
    {
    // žx‚̓ǂݍž‚Ý
    if(elm.ask !== void && +elm.ask)
    loadBookMarkWithAsk(+elm.place);
    else
    loadBookMark(+elm.place);
    return -4;
    } incontextof this,

    save : function(elm)
    {
    // žx‚̓ǂݍž‚Ý
    if(elm.ask !== void && +elm.ask)
    saveBookMarkWithAsk(+elm.place);
    else
    saveBookMark(+elm.place);
    return -4;
    } incontextof this,

    startanchor : function(elm)
    {
    // uÅ‰‚É–ß‚év‚ÌŽg—p•s‰ÂEŽg—p‰Â‚ðÝ’è‚·‚é
    setStartAnchorEnabled(elm.enabled === void || +elm.enabled);
    return 0;
    } incontextof this,

    gotostart : function(elm)
    {
    // uÅ‰‚É–ß‚év
    if(elm.ask !== void && +elm.ask)
    goToStartWithAsk();
    else
    goToStart();
    return -4;
    } incontextof this,

    goback : function(elm)
    {
    // ’ʉߋL˜^‚ð–ß‚é
    if(elm.ask !== void && +elm.ask)
    goBackHistory(true);
    else
    goBackHistory(false);
    return -4;
    } incontextof this,

    record : function(elm)
    {
    // ’ʉߋL˜^‚ð‚·‚é
    setToRecordHistory();
    return 0;
    } incontextof this,

    tempsave : function(elm)
    {
    // ó‘Ԃ̃ƒ‚ƒŠ‚Ö‚Ì•Û‘¶
    tempSave(+elm.place);
    return 0;
    } incontextof this,

    tempload : function(elm)
    {
    // ó‘Ԃ̃ƒ‚ƒŠ‚Ö‚Ì•Û‘¶
    tempLoad(+elm.place, elm);
    //elm.se === void || +elm.se, elm.bgm === void || +elm.bgm,
    //elm.backlay !== void && +elm.backlay);
    return 0;
    } incontextof this,

    mappfont : function(elm)
    {
    // ƒŒƒ“ƒ_ƒŠƒ“ƒOÏ‚݃tƒHƒ“ƒg‚ðŒ»Ý‚ÌƒtƒHƒ“ƒg‚Ƀ}ƒbƒsƒ“ƒO
    mapPrerenderedFont(elm.storage);
    return 0;
    } incontextof this,

    locksnapshot : function(elm)
    {
    // ‰æ–ʂ̃XƒiƒbƒvƒVƒ‡ƒbƒg‚ðƒƒbƒN‚·‚é
    lockSnapshot();
    return 0;
    } incontextof this,

    unlocksnapshot : function(elm)
    {
    // ‰æ–ʂ̃XƒiƒbƒvƒVƒ‡ƒbƒg‚̃ƒbƒN‚ð‰ðœ‚·‚é
    unlockSnapshot();
    return 0;
    } incontextof this,

    //------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒŒƒCƒ„‘€ì) --

    image : function(elm)
    {
    // ‰æ‘œ“ǂݍž‚Ý
    updateBeforeCh = 1;
    var start = System.getTickCount();
    getLayerFromElm(elm).loadImages(elm);
    dm(elm.storage + " ‚̓ǂݍž‚Ý‚É " + (System.getTickCount() - start) + "ms ‚*‚*‚è‚Ü‚µ‚½");
    return 0;
    } incontextof this,

    img : function(elm)
    {
    // ‰æ‘œ“ǂݍž‚Ý(image‚Æ‚¨‚È‚¶)
    updateBeforeCh = 1;
    var start = System.getTickCount();
    getLayerFromElm(elm).loadImages(elm);
    dm(elm.storage + " ‚̓ǂݍž‚Ý‚É " + (System.getTickCount() - start) + "ms ‚*‚*‚è‚Ü‚µ‚½");
    return 0;
    } incontextof this,

    pimage : function(elm)
    {
    // •”•ª’ljÁ‰æ‘œ“ǂݍž‚Ý
    getLayerFromElm(elm).loadPartialImage(elm);
    return 0;
    } incontextof this,

    ptext : function(elm)
    {
    // ”wŒi/‘OŒiƒŒƒCƒ„‚Ö‚Ì•¶Žš•`‰æ
    getLayerFromElm(elm).drawReconstructibleText(elm);
    return 0;
    } incontextof this,

    freeimage : function(elm)
    {
    // ‰æ‘œ‚̃NƒŠƒA
    updateBeforeCh = 1;
    getLayerFromElm(elm).freeImage(elm);
    return 0;
    } incontextof this,

    animstart : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚ÌŠJŽn
    updateBeforeCh = 1;
    getLayerFromElm(elm).startAnim(elm);
    return 0;
    } incontextof this,

    animstop : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~
    updateBeforeCh = 1;
    getLayerFromElm(elm).stopAnim(+elm.seg);
    return 0;
    } incontextof this,

    wa : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‘Ò‚¿
    return waitAnimation(elm);
    } incontextof this,

    mapimage : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚̗̈æ‰æ‘œ‚ð“ǂݍž‚Þ
    getLayerFromElm(elm).loadProvinceImage(elm.storage);
    return 0;
    } incontextof this,

    mapaction : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚̗̈æƒAƒNƒVƒ‡ƒ“’è‹`‚ð“ǂݍž‚Þ
    getLayerFromElm(elm).loadProvinceActions(elm.storage);
    return 0;
    } incontextof this,

    mapdisable : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚𖳌ø‚É‚·‚é
    getLayerFromElm(elm).clearProvinceActions();
    return 0;
    } incontextof this,

    backlay : function(elm)
    {
    // ƒŒƒCƒ„‚ð— ‰æ–ʂɃRƒs[
    updateBeforeCh = 1;
    backupLayer(elm, true);
    return 0;
    } incontextof this,

    forelay : function(elm)
    {
    // ƒŒƒCƒ„‚ð•\‰æ–ʂɃRƒs[
    updateBeforeCh = 1;
    backupLayer(elm, false);
    return 0;
    } incontextof this,

    copylay : function(elm)
    {
    // “¯Ží‚̃ŒƒCƒ„“¯Žm‚̃Rƒs[
    updateBeforeCh = 1;
    copyLayer(elm);
    return 0;
    } incontextof this,

    layopt : function(elm)
    {
    // ƒŒƒCƒ„‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è
    updateBeforeCh = 1;
    getLayerFromElm(elm).setOptions(elm);
    return 0;
    } incontextof this,

    trans : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ÌŠJŽn
    getLayerPageFromElm(elm, false).beginTransition(elm);
    return 0;
    } incontextof this,

    wt : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Â
    return waitTransition(elm);
    } incontextof this,

    stoptrans : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚·‚é
    stopAllTransitions();
    return 0;
    } incontextof this,

    move : function(elm)
    {
    // Ž*“®ˆÚ“®‚ÌŠJŽn
    getLayerFromElm(elm).beginMove(elm);
    return 0;
    } incontextof this,

    wm : function(elm)
    {
    // Ž*“®ˆÚ“®‚ð‘Ò‚Â
    return waitMove(elm);
    } incontextof this,

    stopmove : function(elm)
    {
    // Ž*“®ˆÚ“®‚ð’âŽ~‚·‚é
    stopAllMoves();
    return 0;
    } incontextof this,

    laycount : function(elm)
    {
    updateBeforeCh = 1;
    allocateCharacterLayers(+elm.layers) if elm.layers !== void;
    allocateMessageLayers(+elm.messages) if elm.messages !== void;
    return 0;
    } incontextof this,

    //------------------------------ ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(Œø‰Ê‰¹EBGMEƒrƒfƒI‘€ì) --

    playbgm : function(elm)
    {
    // BGM ‚̉‰‘t
    bgm.play(elm);
    return 0;
    } incontextof this,

    stopbgm : function(elm)
    {
    // BGM ‚Ì’âŽ~
    bgm.stop();
    return 0;
    } incontextof this,

    pausebgm : function(elm)
    {
    // BGM ‚̈ꎞ’âŽ~
    bgm.pause();
    return 0;
    } incontextof this,

    resumebgm : function(elm)
    {
    // BGM ‚̍ĊJ
    bgm.resume();
    return 0;
    } incontextof this,

    fadeinbgm : function(elm)
    {
    // BGM ‚̃tƒF[ƒhƒCƒ“
    bgm.fadeIn(elm);
    return 0;
    } incontextof this,

    fadeoutbgm : function(elm)
    {
    // BGM ‚̃tƒF[ƒhƒAƒEƒg
    bgm.fadeOut(elm);
    return 0;
    } incontextof this,

    fadebgm : function(elm)
    {
    // BGM ‚ÌŽw’艹—ʂ܂ł̃tƒF[ƒh
    bgm.fade(elm);
    return 0;
    } incontextof this,

    xchgbgm : function(elm)
    {
    // BGM ‚Ì“ü‚ê‘Ö‚¦/ƒNƒƒXƒtƒF[ƒh
    bgm.exchange(elm);
    return 0;
    } incontextof this,

    bgmopt : function(elm)
    {
    // BGM ‚̃IƒvƒVƒ‡ƒ“Ý’è
    bgm.setOptions(elm);
    return 0;
    } incontextof this,

    wb : function(elm)
    {
    // BGM ‚̃tƒF[ƒhI—¹‘Ò‚¿
    return waitBGMFade(elm);
    } incontextof this,

    wl : function(elm)
    {
    // BGM ‚̍жI—¹‘Ò‚¿
    return waitBGMStop(elm);
    } incontextof this,

    playse : function(elm)
    {
    // Œø‰Ê‰¹‚̍ж
    se[+elm.buf].play(elm);
    return 0;
    } incontextof this,

    stopse : function(elm)
    {
    // Œø‰Ê‰¹‚Ì’âŽ~
    se[+elm.buf].stop();
    return 0;
    } incontextof this,

    fadeinse : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhƒCƒ“Ä¶
    se[+elm.buf].fadeIn(elm);
    return 0;
    } incontextof this,

    fadeoutse : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhƒAƒEƒg
    se[+elm.buf].fadeOut(elm);
    return 0;
    } incontextof this,

    fadese : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh
    se[+elm.buf].fade(elm);
    return 0;
    } incontextof this,

    seopt : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh
    se[+elm.buf].setOptions(elm);
    return 0;
    } incontextof this,

    wf : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhI—¹‘Ò‚¿
    return waitSEFade(elm);
    } incontextof this,

    ws : function(elm)
    {
    // Œø‰Ê‰¹‚̍жI—¹‘Ò‚¿
    return waitSEStop(elm);
    } incontextof this,

    video : function(elm)
    {
    // ƒ€[ƒr[‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    movies[+elm.slot].setOptions(elm);
    return 0;
    } incontextof this,

    playvideo : function(elm)
    {
    // ƒ€[ƒr[‚ðÄ¶‚·‚é
    movies[+elm.slot].play(elm.storage);
    return 0;
    } incontextof this,

    stopvideo : function(elm)
    {
    // ƒ€[ƒr[‚ð’âŽ~‚·‚é
    movies[+elm.slot].stop();
    return 0;
    } incontextof this,

    openvideo : function(elm)
    {
    // ƒ€[ƒr[Ä¶‚̏€”õ‚ð‚·‚é
    movies[+elm.slot].open(elm.storage);
    return 0;
    } incontextof this,

    wv : function(elm)
    {
    // ƒ€[ƒr[‚̍жI—¹‚ð‘Ò‚Â
    return waitMovieStop(elm);
    } incontextof this,

    // Start: Add: T.Imoto
    wp : function(elm)
    {
    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð‘Ò‚Â
    return waitMoviePeriod(elm);
    } incontextof this,

    pausevideo : function(elm)
    {
    movies[+elm.slot].pause();
    return 0;
    } incontextof this,

    resumevideo : function(elm)
    {
    movies[+elm.slot].resume();
    return 0;
    } incontextof this,

    preparevideo : function(elm)
    {
    movies[+elm.slot].prepare();
    return 0;
    } incontextof this,

    rewindvideo : function(elm)
    {
    movies[+elm.slot].rewind();
    return 0;
    } incontextof this,

    videolayer : function(elm)
    {
    movies[+elm.slot].storeLayer( elm.layer, elm.page, elm.channel );
    movies[+elm.slot].setVideoLayer(getLayerFromElm(elm),elm);
    return 0;
    } incontextof this,

    clearvideolayer : function(elm)
    {
    movies[+elm.slot].cancelLayer( elm.channel );
    movies[+elm.slot].setVideoLayer(null,elm);
    return 0;
    } incontextof this,

    videosegloop : function(elm)
    {
    movies[+elm.slot].setSegment(elm);
    return 0;
    } incontextof this,

    cancelvideosegloop : function(elm)
    {
    movies[+elm.slot].cancelSegmentLoop();
    return 0;
    } incontextof this,

    videoevent : function(elm)
    {
    movies[+elm.slot].setPeriod(elm);
    return 0;
    } incontextof this,

    cancelvideoevent : function(elm)
    {
    movies[+elm.slot].cancelPeriodEvent();
    return 0;
    } incontextof this,
    // End: Add: T.Imoto

    //--------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(•Ï”ETJS ‘€ì) --

    eval : function(elm)
    {
    // Ž®‚Ì•]‰¿
    Scripts.eval(elm.exp);
    return 0;
    } incontextof this,

    trace : function(elm)
    {
    // Ž®‚̃gƒŒ[ƒX•\Ž¦
    var exp = elm.exp;
    var result = Scripts.eval(exp);
    dm("¥[trace] expression=\"" + exp + "\" type of result=" + typeof result +
    " result=" + result);
    return 0;
    } incontextof this,

    input : function(elm)
    {
    // •¶Žš—ñ‚Ì“ü—Í
    inputString(elm);
    return 0;
    } incontextof this,

    clearsysvar : function(elm)
    {
    // ƒVƒXƒeƒ€•Ï”‚̃NƒŠƒA
    clearSystemVariables();
    return 0;
    } incontextof this,

    clearvar : function(elm)
    {
    // ƒQ[ƒ€•Ï”‚̃NƒŠƒA
    clearVariables();
    return 0;
    } incontextof this,

    waittrig : function(elm)
    {
    // ƒgƒŠƒK‚ð‘Ò‚Â
    return waitTrigger(elm);
    } incontextof this,

    //----------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ‚̏I‚í‚è --

    interrupt : function(elm) { return -2; } incontextof this ];
    }
    }



    // TJS ƒXƒNƒŠƒvƒg‚Í‚±‚±‚ŏI‚í‚è
    "
    END_OF_TJS_SCRIPT
    # "; /*

    # assign ‚ŃRƒs[‚·‚ׂ«•Ï”‚̍ж¬‚ðs‚¤ perl ƒXƒNƒŠƒvƒg

    open FH, "MainWindow.tjs" or die;
    undef($/);
    $content = <FH>;

    $list_store = '';
    $list_restore = '';
    while($content =~ /\/\*C\*\/var\s+(\w+)/gs)
    {
    $list_store .= "\t\tf.$1 = $1;\n";
    $list_restore .= "\t\t$1 = f.$1 if f.$1 !== void;\n";
    }

    $content =~
    s/\t\t\/\/ \[start_store_vars\]\n.*?\t\t\/\/ \[end_store_vars\]/\t\t\/\/ \[start_store_vars\]\n$list_store\t\t\/\/ \[end_store_vars\]/s;
    $content =~
    s/\t\t\/\/ \[start_restore_vars\]\n.*?\t\t\/\/ \[end_restore_vars\]/\t\t\/\/ \[start_restore_vars\]\n$list_restore\t\t\/\/ \[end_restore_vars\]/s;

    open FH, ">MainWindow.tjs" or die;
    print FH $content;


    # */
    Ignore This Signature

  2. # ADS
    Circuit advertisement
    Join Date
    Always
    Posts
    Many
     

  3. #2
    One of countless souls... nanashi1's Avatar
    Join Date
    Jul 2012
    Location
    Somewhere in a point of the universe
    Age
    31
    Posts
    78,872
    Thanks
    2,043
    Thanked 4,219 Times in 3,085 Posts
    Points: 242,917, Level: 100
    Points: 242,917, Level: 100
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Your first GroupThree FriendsOverdriveTagger First Class50000 Experience PointsRecommendation Second Class
    Awards:
    SOTM #29 WinnerSOTM #54 WinnerSOTM #56 WinnerSOTM #59 WinnerSOTM #60 Winner

    Re: Errr....

    Quote Originally Posted by Ichiko View Post
    What the hell.

      Spoiler: Wuh 
    //;# MainWindow.tjs - KAG ƒƒCƒ“ƒEƒBƒ“ƒhƒE
    //;# Copyright (C)2001-2005, W.Dee and contributors ‰ü•ÏE”z•z‚ÍŽ*—R‚Å‚·
    //;<<'END_OF_TJS_SCRIPT';

    // ‚±‚̃XƒNƒŠƒvƒg‚Í—LŒø‚È perl5 ƒXƒNƒŠƒvƒg‚Å‚à‚ ‚é

    class KAGWindow extends Window
    {
    // KAG ‚̃EƒBƒ“ƒhƒE ƒNƒ‰ƒX
    // KAG ‚Ì“®ì‚̃ƒCƒ“‚È•”•ª‚Í‚±‚±‚É‹Lq‚µ‚Ä‚ ‚é

    // ˆÈ‰º‚Ì‚¤‚¿A/*C*/ ‚̂‚­•Ï”‚́A––’[‚Ì perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚Ä
    // Ž*“®“I‚Éžx‚ɃRƒs[‚³‚ê‚éƒR[ƒh‚ª¶¬‚³‚ê‚é•Ï”

    var scWidth = 640; // ‰æ–ʉ¡•
    var scHeight = 480; // ‰æ–ʏc•

    var aboutWidth = 320; // u‚±‚̃\ƒtƒg‚ɂ‚¢‚āvƒEƒBƒ“ƒhƒE‚̉¡•
    var aboutHeight = 200; // “¯c•

    var isFirstProcess = true; // ˆê”ԍŏ‰‚Ì process ‚̌Ăяo‚µ‚*‚Ç‚¤‚*

    var freeSaveDataMode = false; // žx‚ðƒƒjƒ…[ƒo[‚È‚Ç‚ÅŠÇ—‚¹‚¸‚ɁAŒÂ•Ê‚̃tƒ@ƒCƒ‹‚Æ‚µ‚ÄŠÇ—‚·‚é
    var saveThumbnail = false; // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶‚·‚é‚*‚Ç‚¤‚*
    var thumbnailWidth = 133; // ƒTƒ€ƒlƒCƒ‹‚̉¡•
    var thumbnailDepth = 8; // ƒTƒ€ƒlƒCƒ‹‚ÌBMPƒ‚[ƒhB8‚*24
    // ƒTƒ€ƒlƒCƒ‹‚Ì ƒtƒ‹ƒJƒ‰[‰»‚¨‚æ‚уTƒCƒYƒtƒŠ[‰»‚̃pƒbƒ`‚Í
    // ‚ä‚ñŽ‚*‚ç‚¢‚½‚¾‚«‚Ü‚µ‚½B
    // ‚±‚̏ê‚ðŽØ‚è‚Ä‚¨—ç\‚µã‚°‚Ü‚·B


    var snapshotLayer = void; // ‰æ‘œ‚̃XƒiƒbƒvƒVƒ‡ƒbƒg‚ðˆêŽž“I‚É•Û‘¶‚·‚郌ƒCƒ„
    var snapshotLockCount = 0; // ƒƒbƒNƒJƒEƒ“ƒg

    var lastSaveDataNameGlobal = ""; // ÅŒã‚É•Û‘¶‚µ‚½ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚ł̃tƒ@ƒCƒ‹–¼
    /*C*/var lastSaveDataName = ""; // ÅŒã‚É•Û‘¶‚µ‚½ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚ł̃tƒ@ƒCƒ‹–¼

    var saveDataLocation = "savedata"; // ƒZ[ƒuƒf[ƒ^•Û‘¶êŠ

    var saveDataID = "00000000-0000-0000-0000-000000000000"; // ƒZ[ƒuƒf[ƒ^‚Ì ID

    var readOnlyMode = false; // “ǂݍž‚ݐê—pƒ‚[ƒh(ƒf[ƒ^‚ðƒfƒBƒXƒN‚ɏ‘‚*‚È‚¢)
    var dataName = "data"; // ƒZ[ƒuƒf[ƒ^–¼
    var saveDataMode = ""; // ƒf[ƒ^•Û‘¶ƒ‚[ƒh( "c" ‚ň͆‰» )

    var recordHistoryOfStore = 0; // ’ʉߗš—ð‚ð‹L˜^‚·‚é‚*‚Ç‚¤‚*
    // 0 = Ž*“®“I‚É‚Í‹L˜^‚µ‚È‚¢ 1 = •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚²‚Æ
    // 2 = ‘I‘ðŽˆ ( @s ƒ^ƒO ) ‚²‚Æ
    var maxHistoryOfStore = 5; // ’ʉߋL˜^‚̍ő吔
    var historyOfStore = []; // ’ʉߗš—ðƒf[ƒ^
    var nextRecordHistory = false;
    // ŽŸ‚Ì•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹’ʉߎž‚ÉŒ»Ý‚̏î•ñ‚ð•Û‘¶‚·‚é‚*‚Ç‚¤‚*

    var stablePosibility = false;
    // žx‚ð•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹ŠÔ‚Å stable ‚É‚È‚é‰Â”\«‚ª‚ ‚é‚*‚Ç‚¤‚*

    var fullScreened = false; // Œ»Ýƒtƒ‹ƒXƒNƒŠ[ƒ“‚*‚Ç‚¤‚*

    var isMain = true; // ‚±‚ꂪƒƒCƒ“ƒEƒBƒ“ƒhƒE‚*‚Ç‚¤‚*

    var askOnClose = true; // I—¹Žž‚ɏI—¹‚·‚é‚*‚ðƒ†[ƒU‚É•·‚­‚*‚Ç‚¤‚*

    var helpFile = ""; // uƒwƒ‹ƒv > –ÚŽŸv‚ÅŠJ‚­ƒtƒ@ƒCƒ‹

    var quakeTimer; // quake —p‚̃^ƒCƒ}
    var defaultQuakeTimeInChUnit = false;
    /*C*/var quaking = false; // —h‚ê‚Ä‚¢‚é‚*
    /*C*/var quakeEndTick = 0; // —h‚ê‚ðI—¹‚³‚¹‚é tick
    /*C*/var quakeHorzMax = 0; // ‰¡U•
    /*C*/var quakeVertMax = 0; // cU•
    /*C*/var quakePhase = 0;

    var chDefaultAntialiased; // •¶Žš‚ɃAƒ“ƒ`ƒGƒCƒŠƒAƒX‚ð‚*‚¯‚é‚*‚Ç‚¤‚*
    var chDefaultFace; // •¶Žš‚̃fƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒg

    var initialMessageLayerVisible = true;

    var historyLayer; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„
    /*C*/var historyWriteEnabled = true; // ƒƒbƒZ[ƒWƒŒƒCƒ„‚É•¶Žš‚ðo—Í‚·‚é‚*
    /*C*/var historyEnabled = true; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦‰Â”\‚*
    var historyShowing = false; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦’†‚*
    var lastHistoryHiddenTick = 0; // ÅŒã‚É—š—ðƒŒƒCƒ„‚ª”ñ•\Ž¦‚É‚È‚Á‚½‚Æ‚«‚Ì tick

    /*C*/var numCharacterLayers = 0; // ‘OŒiƒŒƒCƒ„‚̐”
    /*C*/var numMessageLayers = 1; // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̐”
    var fore = %[]; // •\ƒŒƒCƒ„
    var back = %[]; // — ƒŒƒCƒ„

    var scPositionX = %[]; // —§‚¿ŠG‚Ì’†SÀ•W(X)

    var tempLayer = void; // ˆêŽž“I‚ȃŒƒCƒ„

    var lineBreak; // s‘Ò‚¿—pƒAƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„
    var pageBreak; // ƒy[ƒW‘Ò‚¿—pƒOƒŠƒt‚̃Aƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„
    var clickWaiting = false; // ƒNƒŠƒbƒN‘Ò‚¿‚*‚Ç‚¤‚*

    var mainConductor; // ƒƒCƒ“‚̃Rƒ“ƒ_ƒNƒ^
    var extraConductor; // —\”õ‚̃Rƒ“ƒ_ƒNƒ^
    var conductor; // Œ»Ý‚̃Rƒ“ƒ_ƒNƒ^
    var usingExtraConductor = false; // —\”õ‚̃Rƒ“ƒ_ƒNƒ^‚ðŽg—p’†‚*‚Ç‚¤‚*
    var onExtraConductorReturn; // extraConductor ‚*‚ç’ʏí‚̃Rƒ“ƒ_ƒNƒ^‚É–ß‚é‚Æ‚«‚É‚æ‚Ԋ֐”

    var tagHandlers; // ƒ^ƒO‚̃nƒ“ƒhƒ‰ŒQŽ«‘”z—ñ

    var saveMacros = true; // ƒ}ƒNƒ‚ðžx‚É•Û‘¶‚·‚é‚*‚Ç‚¤‚*

    var current; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„
    /*C*/var currentNum; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„”ԍ†
    /*C*/var currentPage; // Œ»Ý‘€ì’†‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̃y[ƒW(•\0/— 1)
    /*C*/var currentWithBack = false; // — ‰æ–Ê‚É‚à•¶Žš‚ð•`‰æ‚·‚é‚*‚Ç‚¤‚*

    var bgm; // BGM ƒIƒuƒWƒFƒNƒg

    var numSEBuffers = 1; // Œø‰Ê‰¹ƒoƒbƒtƒ@‚̐”
    var se = []; // Œø‰Ê‰¹ƒoƒbƒtƒ@ƒIƒuƒWƒFƒNƒg

    var numMovies = 1; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg”
    // var movie; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg
    var movies = []; // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg

    var transCount; // Œ»Ýis’†‚̃gƒ‰ƒ“ƒWƒVƒ‡ƒ“‚̐”
    var moveCount; // Œ»Ýis’†‚ÌŽ*“®ˆÚ“®‚̐”

    var chSpeeds = %[
    fast: 10, // u‚‘¬v•¶Žš•\Ž¦ƒXƒs[ƒh
    normal: 30, // u•’ʁv•¶Žš•\Ž¦ƒXƒs[ƒh
    slow: 50, // u’x‚¢v•¶Žš•\Ž¦ƒXƒs[ƒh
    ];

    var userChSpeed = 30; // ƒ†[ƒU‚Ì‘I‚ñ‚¾•¶Žš•\Ž¦ƒXƒs[ƒh
    var userCh2ndSpeed = -1; // ƒ†[ƒU‚Ì‘I‚ñ‚¾ Šù“Ç•”•ª‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh
    var chNonStopToPageBreak = false; // ƒy[ƒW––‚܂ňê‹C‚ɓǂݐi‚Þ‚* ( l ƒ^ƒO‚𖳎‹‚·‚é‚* )
    var ch2ndNonStopToPageBreak = false; // Šù“Ç‚Ì•”•ª‚Ńy[ƒW––‚܂ňê‹C‚ɓǂݐi‚Þ‚*
    /*C*/var chUserMode = true; // •¶Žš•\Ž¦‘¬“x‚ÍŒ»Ýƒ†[ƒU‚Ì‘I‚ñ‚¾‚à‚Ì‚*
    /*C*/var chSpeed = 30; // Œ»Ý‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh
    /*C*/var actualChSpeed = chSpeed; // ŽÀÛ‚Ì•¶Žš•\Ž¦ƒXƒs[ƒh

    /*C*/var beforeNoWaitActualChSpeed; // nowait ‚É“ü‚é‘O‚Ì actualChSpeed
    /*C*/var beforeNoWaitChUserMode; // nowait ‚É“ü‚é‘O‚Ì chUserMode

    /*C*/var clickSkipEnabled = true; // ƒNƒŠƒbƒNƒXƒLƒbƒv‚ª—LŒø‚*
    /*C*/var nextSkipEnabled = true; // ŽŸ‚Ì‘I‘ðŽˆ(/–¢“Ç)‚܂Ői‚Þ‚ª—LŒø‚*
    var skipMode = 0; // ƒXƒLƒbƒv‚̃‚[ƒh
    // 0=ƒXƒLƒbƒv‚È‚µ, 1=ƒNƒŠƒbƒN‘Ò‚¿‹L†‚Ü‚Å, 2=‰üƒy[ƒW‘Ò‚¿‹L†‚Ü‚Å, 3=ŽŸ‚Ì’âŽ~‚Ü‚Å
    // 4=‘‘—‚è
    var autoMode = false; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚*‚Ç‚¤‚*
    var autoModePageWait = 350; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒhŽž‚̉üƒy[ƒWŽž‚̃EƒFƒCƒg
    var autoModeLineWait = 50; // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒhŽž‚̍sƒNƒŠƒbƒN‘Ò‚¿Žž‚̃EƒFƒCƒg
    // ã‚Ì“ñ‚‚́Aƒm[ƒEƒFƒCƒg‚É‚µ‚½‚¢ê‡‚Í 0 ‚Å‚Í‚È‚­‚Ä -4 ‚ðŽw’è‚·‚邱‚Æ

    var skipKeyRepressed = false; // return ‚ ‚é‚¢‚Í space ƒL[ ( f ƒL[‚È‚Ç‚Å‚Í‚È‚¢ )
    // ‚ª‰Ÿ‚³‚ê‚é‚Æ true ‚É‚È‚é ( ƒXƒLƒbƒv‰ðœŽž‚É false

    var autoModePageWaits = %[
    fast: 400, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu’Z‚¢v
    faster: 700, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu‚â‚â’Z‚¢v
    medium: 1000, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu•’ʁv
    slower: 1300, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu‚â‚â’x‚¢v
    slow: 2000, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̉üƒy[ƒWŽž ƒEƒFƒCƒgu’x‚¢v
    ];

    var autoModeLineWaits = %[
    fast: 180, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu’Z‚¢v
    faster: 240, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu‚â‚â’Z‚¢v
    medium: 300, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu•’ʁv
    slower: 360, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu‚â‚â’x‚¢v
    slow: 500, // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̍s–– ƒEƒFƒCƒgu’x‚¢v
    ];

    /*C*/var canCancelSkipByClick = true; // ƒNƒŠƒbƒN‚É‚æ‚èƒXƒLƒbƒvó‘Ԃ̃Lƒƒƒ“ƒZƒ‹‚ª‚Å‚«‚é‚*

    /*C*/var autoWCEnabled = false; // Ž*“®ƒEƒFƒCƒg‚ª—LŒø‚*‚Ç‚¤‚*
    /*C*/var autoWCChars = ""; // Ž*“®ƒEƒFƒCƒg‚ð‚*‚¯‚镶Žš
    var autoWCWaits = []; // Ž*“®ƒEƒFƒCƒg‚̃EƒFƒCƒg

    var timeOrigin; // resetWait ‚Őݒ肳‚ꂽŽžŠÔŒ´“_
    var lastWaitTime; // wait mode=until ‚ÅŽÀÛ‚É‘Ò‚Á‚½ŽžŠÔ

    var stableHandlers = []; // ƒVƒXƒeƒ€‚ªˆÀ’è(ƒNƒŠƒbƒN‘Ò‚¿/’âŽ~)‚µ‚½‚Æ‚«‚ɌĂ΂ê‚é
    var runHandlers = []; // ƒVƒXƒeƒ€‚ª‘–‚èŽn‚ß‚½‚Æ‚«‚ɌĂ΂ê‚é
    var inStable = true; // ˆÀ’肵‚Ä‚¢‚é‚Æ‚«(‘–s’†‚Å‚È‚¢‚Æ‚«) true
    var inSleep = false; // s ƒ^ƒO‚Å’âŽ~‚µ‚Ä‚¢‚é‚Æ‚« true

    var updateBeforeCh = 0; // •¶Žš‚ð•`‰æ‚·‚é‘O‚É‚¢‚Á‚½‚ñ‰æ–Ê•`‰æ‚É“ü‚é‚*‚Ç‚¤‚*‚̃JƒEƒ“ƒg

    var messageLayerHiding = false; // ƒ†[ƒU‚É‚æ‚胁ƒbƒZ[ƒWƒŒƒCƒ„‚ª‰B‚³‚ê‚Ä‚¢‚é‚*

    /*C*/var rightClickEnabled = true; // ‰EƒNƒŠƒbƒN‚ª—LŒø‚*
    /*C*/var rightClickCall = false; // ‰EƒNƒŠƒbƒN‚Å“Á’è‚̃‹[ƒ`ƒ“‚ðŒÄ‚Ô‚*
    /*C*/var rightClickJump = false; // ‰EƒNƒŠƒbƒN‚*‚Å“Á’è‚̃‰ƒxƒ‹‚ɃWƒƒƒ“ƒv‚·‚é‚*
    /*C*/var rightClickTarget = ""; // ‰EƒNƒŠƒbƒN‚ł̌Ăяo‚µæ
    /*C*/var rightClickStorage = ""; // ‰EƒNƒŠƒbƒN‚ł̌Ăяo‚µæ
    /*C*/var rightClickName = "default"; // ‰EƒNƒŠƒbƒN‚̃ƒjƒ…[•\Ž¦–¼
    /*C*/var rightClickCurrentMenuName = ""; // ‰EƒNƒŠƒbƒN‚̃ƒjƒ…[‚ÉŒ»ÝÝ’肳‚ê‚Ä‚¢‚é–¼‘O
    var rightClickDefaultName = ""; // ‰EƒNƒŠƒbƒN‚̃fƒtƒHƒ‹ƒg‚̃ƒjƒ…[•\Ž¦–¼

    /*C*/var lastClickGlyphVisible; // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚ɃNƒŠƒbƒN‘Ò‚¿‹L†‚ª‰ÂŽ‹‚¾‚Á‚½‚*‚Ç‚¤‚*
    var lastClickGlyphMessagePage;
    // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚̃NƒŠƒbƒN‘Ò‚¿‹L†‚Ì•\Ž¦‚³‚ê‚Ä‚¢‚郁ƒbƒZ[ƒWƒŒƒCƒ„‚̃y[ƒW
    var lastClickGlyphMessageNum; // V ”ԍ†
    var lastClickGlyphWhich; // V "page" ‚* "line" ‚*
    var inSleepBeforeExtraConductor; // extraConductor ‚ðŽg—p‚·‚é’¼‘O‚ª inSleep ‚¾‚Á‚½‚*

    // ’ʏí‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorDefault = crArrow; // ’ʏí‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorPointed = crHandPoint; // ƒ{ƒ^ƒ“AƒŠƒ“ƒN“™‚ðƒ|ƒCƒ“ƒg‚µ‚½Žž‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorWaitingClick = crArrow; // ƒNƒŠƒbƒN‘Ò‚¿‚̃}ƒEƒXƒJ[ƒ\ƒ‹
    /*C*/var cursorDraggable = crSizeAll; // ƒhƒ‰ƒbƒO‰Â”\‚ȏꏊ—p‚̃}ƒEƒXƒJ[ƒ\ƒ‹

    /*C*/var startAnchorEnabled = false; // uÅ‰‚É–ß‚év‚ªŽg—p‰Â”\‚*‚Ç‚¤‚*

    /*C*/var storeEnabled = true; // ƒ†[ƒU‚ªužx‚ð‚Í‚³‚ށvƒƒjƒ…[‚ɃAƒNƒZƒX‰Â”\‚*‚Ç‚¤‚*
    /*C*/var restoreEnabled = true; // ƒ†[ƒU‚ªužx‚ð‚½‚Ç‚évƒƒjƒ…[‚ɃAƒNƒZƒX‰Â”\‚*‚Ç‚¤‚*
    var storeLabelPassed = false; // •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚ð’ʉ߂µ‚½‚*‚Ç‚¤‚*
    /*C*/var currentLabel = ""; // Œ»Ý‚̃‰ƒxƒ‹
    /*C*/var currentPageName = ""; // Œ»Ý‚̃y[ƒW–¼
    var currentRecordName = ""; // Œ»Ý‚Ì‹L˜^–¼ ( trail_ƒXƒgƒŒ[ƒW_ƒ‰ƒxƒ‹ )
    var autoRecordPageShowing = false; // ƒ‰ƒxƒ‹’ʉߋL˜^‚ð‚·‚é‚*

    var numBookMarks = 10; // ƒƒjƒ…[‚É—pˆÓ‚·‚éžx‚̃Tƒuƒƒjƒ…[€–ڂ̐”
    var showBookMarkDate = false; // ƒƒjƒ…[‚Éžx‚ð‚Í‚³‚ñ‚¾“ú•tŽž‚ð•\Ž¦‚·‚é‚*

    var bookMarkNames = []; // ƒƒjƒ…[‚ɐݒ肳‚ê‚Ä‚¢‚éžx‚Ì–¼‘O
    var bookMarkDates = []; // žx‚Ì“ú•t
    var bookMarkProtectedStates = []; // žx‚ª•ÛŒì‚³‚ê‚Ä‚¢‚é‚*‚̏î•ñ

    var showFixedPitchOnlyInFontSelector = false; // ƒtƒHƒ“ƒg‘I‘ð‚ŌŒèƒsƒbƒgƒtƒHƒ“ƒg‚Ì‚Ý‚ð•\Ž¦‚·‚é‚*

    var flags = %[]; // ƒtƒ‰ƒO(ƒ†[ƒU)
    var pflags = %[]; // u•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹v‚ð’ʉ߂µ‚½Žž“_‚ł̃tƒ‰ƒO(ƒ†[ƒU)
    var pcflags = %[]; // V (ƒRƒA)
    var sflags = %[]; // ƒVƒXƒeƒ€•Ï”—̈æ(ƒ†[ƒU)
    var scflags = %[]; // ƒVƒXƒeƒ€•Ï”—̈æ(ƒRƒA)
    var tflags = %[]; // ˆêŽžƒtƒ‰ƒO

    var tempBookMarks = []; // ˆêŽž“I‚É•Û‘¶‚µ‚½žx

    var clickCount = 0; // ¶ƒNƒŠƒbƒNƒJƒEƒ“ƒg
    var lastMouseDownX; // ÅŒã‚ɃNƒŠƒbƒN‚³‚ꂽ X À•W
    var lastMouseDownY; // ÅŒã‚ɃNƒŠƒbƒN‚³‚ꂽ Y À•W

    var mouseKeyEnabledCount = 0; // ƒ}ƒEƒXƒL[‚ª—LŒø‚*‚Ç‚¤‚*

    var kagPlugins = []; // KAG ƒvƒ‰ƒOƒCƒ“

    var keyDownHook = []; // ƒL[‚ª‰Ÿ‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨
    var leftClickHook = []; // ‰EƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨
    var rightClickHook = []; // ¶ƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂяo‚³‚ê‚镨

    var padKeyMap; // ƒpƒbƒhƒ{ƒ^ƒ“ -> ƒnƒ“ƒhƒ‰(ƒL[ƒR[ƒh)BƒRƒ“ƒXƒgƒ‰ƒNƒ^“à‚Őݒè
    var padKeyMapReverse; // ƒL[ƒR[ƒh -> ƒpƒbƒhƒ{ƒ^ƒ“BƒRƒ“ƒXƒgƒ‰ƒNƒ^“à‚Őݒè


    var holdPeriodEventQueue = []; // •Û—¯‚É‚³‚ꂽƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒgƒLƒ…[
    var isLeavePeriodEvent = false; // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð•Û—¯‚É‚·‚é‚*‚Ç‚¤‚*
    var isWaitPeriodEvent = false; // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿ó‘Ô‚*‚Ç‚¤‚*
    var waitedPeriodEventStorageName = void; // ƒsƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿‚ðƒR[ƒ‹‚µ‚½ƒXƒgƒŒ[ƒW–¼

    //------------------------------------------------------ ƒRƒ“ƒXƒgƒ‰ƒNƒ^ --

    function KAGWindow(ismain = true, width = 0, height = 0)
    {
    // ƒRƒ“ƒXƒgƒ‰ƒNƒ^
    // ˆø” : ismain : ƒƒCƒ“ƒEƒBƒ“ƒhƒE‚Æ‚µ‚č쐬‚³‚ê‚é‚Ì‚*‚Ç‚¤‚*
    super.Window(); // eƒNƒ‰ƒX‚̃Rƒ“ƒXƒgƒ‰ƒNƒ^‚ðŒÄ‚Ô

    // ƒRƒ“ƒtƒBƒMƒ…ƒŒ[ƒVƒ‡ƒ“
    isMain = ismain;
    if(ismain)
    {
    (KAGWindow_config incontextof this)();
    (KAGWindow_config_override incontextof this)()
    if typeof global.KAGWindow_config_override != "undefined";
    }

    userChSpeed = chSpeed = actualChSpeed = chSpeeds.normal;
    autoModePageWait = autoModePageWaits.medium;
    autoModeLineWait = autoModeLineWaits.medium;

    askOnClose = false if !ismain;

    // saveDataLocation ‚ªƒtƒ‹ƒpƒX‚Å‚È‚¢‚悤‚È‚ç‚Î System.exePath ‚ð
    // •t‚¯‰Á‚¦‚é
    if(saveDataLocation.indexOf(":") == -1)
    saveDataLocation = System.exePath + saveDataLocation;

    // ƒƒjƒ…[ƒAƒCƒeƒ€‚̍쐬
    if(ismain) (KAGWindow_createMenus incontextof this)();
    if(typeof this.rightClickMenuItem != "undefined")
    rightClickDefaultName = rightClickCurrentMenuName = rightClickMenuItem.caption;

    if(typeof this.autoModeMediumMenuItem != "undefined")
    autoModeMediumMenuItem.checked = true;
    if(typeof this.windowedMenuItem != "undefined")
    windowedMenuItem.checked = true;
    if(typeof this.chNormalMenuItem != "undefined")
    chNormalMenuItem.checked = true;
    if(typeof this.ch2ndNoChangeMenuItem != "undefined")
    ch2ndNoChangeMenuItem.checked = true;

    if(ismain) (Menu_visible_config incontextof this)();

    createBookMarkSubMenus();

    // ƒEƒBƒ“ƒhƒEŠOŒ*‚Ì’²®
    if(ismain)
    {
    borderStyle = bsSingle;
    innerSunken = true;
    }
    else
    {
    borderStyle = bsDialog;
    innerSunken = false;
    }
    showScrollBars = false;
    if(ismain) caption = System.title;

    // ƒVƒXƒeƒ€ƒ^ƒCƒgƒ‹‚ðƒLƒƒƒvƒVƒ‡ƒ“‚Æ“¯‚¶‚É
    if(ismain) System.title = caption;

    // ƒEƒBƒ“ƒhƒEƒTƒCƒY‚Ì’²®
    if(width != 0 && height != 0)
    {
    // —^‚¦‚ç‚ꂽƒTƒCƒY‚ð“K—p
    scWidth = width;
    scHeight = height;
    }
    setInnerSize(scWidth, scHeight);

    // quake —pƒ^ƒCƒ}‚̍쐬
    quakeTimer = new Timer(onQuakeTimerInterval, '');
    add(quakeTimer);
    quakeTimer.interval = 50;

    // ”wŒiƒŒƒCƒ„‚̍쐬
    fore.messages = [];
    back.messages = [];
    fore.layers = [];
    back.layers = [];
    fore.base = new BaseLayer(this, null, "•\-”wŒi");
    add(fore.base);
    fore.base.setImageSize(scWidth, scHeight);
    fore.base.setSizeToImageSize();
    back.base = new BaseLayer(this, fore.base, "— -”wŒi");
    add(back.base);
    back.base.setImageSize(scWidth, scHeight);
    back.base.setSizeToImageSize();
    fore.base.setCompLayer(back.base);
    back.base.setCompLayer(fore.base);
    fore.base.freeImage();
    back.base.freeImage();

    fore.base.setDefaultCursor(cursorDefault);
    back.base.setDefaultCursor(cursorDefault);

    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̍쐬
    historyLayer = new HistoryLayer(this, fore.base);
    add(historyLayer);

    // ‘OŒiƒŒƒCƒ„‚̍쐬
    allocateCharacterLayers(numCharacterLayers);

    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̍쐬
    allocateMessageLayers(numMessageLayers, false);
    current = fore.messages[0];
    currentNum = 0;
    currentPage = 0;
    currentWithBack = false;
    if(initialMessageLayerVisible)
    {
    fore.messages[0].visible = true;
    back.messages[0].visible = true;
    }

    chDefaultAntialiased = fore.messages[0].defaultAntialiased;
    // •¶Žš‚ɃAƒ“ƒ`ƒGƒCƒŠƒAƒX‚ð‚*‚¯‚é‚*‚Ç‚¤‚*
    chDefaultFace = fore.messages[0].userFace;
    // •¶Žš‚̃fƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒg

    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;

    // s‘Ò‚¿/ƒy[ƒW‘Ò‚¿ƒAƒjƒ[ƒVƒ‡ƒ“ƒŒƒCƒ„‚̍쐬
    lineBreak = new ClickGlyphLayer(this, fore.base);
    add(lineBreak);
    lineBreak.name = "sƒNƒŠƒbƒN‘Ò‚¿‹L†";
    pageBreak = new ClickGlyphLayer(this, fore.base);
    add(pageBreak);
    pageBreak.name = "ƒy[ƒW––ƒNƒŠƒbƒN‘Ò‚¿‹L†";

    // ƒ^ƒOƒnƒ“ƒhƒ‰/ƒRƒ“ƒ_ƒNƒ^‚ðì¬
    tagHandlers = getHandlers();
    mainConductor = new Conductor(this, tagHandlers);
    add(mainConductor);
    conductor = mainConductor;
    extraConductor = new Conductor(this, tagHandlers);
    add(extraConductor);

    // BGM ƒIƒuƒWƒFƒNƒg‚ðì¬
    bgm = new BGM(this);
    add(bgm);

    // Œø‰Ê‰¹ƒIƒuƒWƒFƒNƒg‚ðì¬
    for(var i = 0; i < numSEBuffers; i++)
    add(se[i] = new SESoundBuffer(this, i));

    // ƒ€[ƒr[ƒIƒuƒWƒFƒNƒg‚ðì¬
    if(ismain)
    {
    for( var i = 0; i < numMovies; i++)
    add(movies[i] = new Movie(this,i));
    }

    // ƒfƒtƒHƒ‹ƒg‚̃nƒ“ƒhƒ‰‚ð’ljÁ
    stableHandlers.add(defaultStableHandler);
    runHandlers.add(defaultRunHandler);

    // ƒVƒXƒeƒ€•Ï”‚̓ǂݍž‚Ý
    if(ismain) loadSystemVariables();

    // ƒVƒXƒeƒ€•Ï”‚𔽉f
    if(ismain)
    {
    setSystemStateFromSystemVariables();
    setBookMarkMenuCaptions();
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    clearMessageLayers(false);

    // ƒEƒBƒ“ƒhƒEˆÊ’u‚Ì’²ß
    if(this.width + this.left > System.desktopLeft + System.desktopWidth)
    left = ((System.desktopWidth - this.width) >>1) + System.desktopLeft;
    if(this.height + this.top > System.desktopTop + System.desktopHeight)
    top = ((System.desktopHeight - this.height) >>1) + System.desktopTop;

    // ƒpƒbƒhƒ{ƒ^ƒ“ƒnƒ“ƒhƒ‰‚̍쐬
    createPadKeyMap();


    // ƒEƒBƒ“ƒhƒE‚ð•\Ž¦
    if(ismain) visible = true;

    // ‰æ–ʃTƒCƒY‚ªƒEƒBƒ“ƒhƒEƒTƒCƒY‚æ‚è‚à¬‚³‚¢ê‡‚Í
    // ƒtƒ‹ƒXƒNƒŠ[ƒ“‚É‚µ‚Ä‚Ý‚é
    if(ismain)
    {
    if(System.screenWidth <= scWidth && System.screenHeight <= scHeight)
    onFullScreenMenuItemClick(this);
    }

    // ‘O‰ñ‹N“®Žž‚Ƀtƒ‹ƒXƒNƒŠ[ƒ“‚¾‚Á‚½ê‡‚̓tƒ‹ƒXƒNƒŠ[ƒ“‚É‚µ‚Ä‚Ý‚é
    if(ismain)
    {
    if(scflags.fullScreen !== void && +scflags.fullScreen)
    onFullScreenMenuItemClick(this);
    }

    // ‚¢‚Á‚½‚ñƒVƒXƒeƒ€•Ï”‚ð‘‚«o‚·
    if(ismain) saveSystemVariables();
    }

    //------------------------------------------------------------- finalize --

    function finalize()
    {
    // finalize ƒƒ\ƒbƒh

    // ƒvƒ‰ƒOƒCƒ“‚Ì–³Œø‰»
    for(var i = 0; i < kagPlugins.count; i++) invalidate kagPlugins[i];

    // ‘OŒiAƒƒbƒZ[ƒWƒŒƒCƒ„‚𖳌ø‰»
    for(var i = 0; i< fore.layers.count; i++) invalidate fore.layers[i];
    for(var i = 0; i< back.layers.count; i++) invalidate back.layers[i];
    for(var i = 0; i< fore.messages.count; i++) invalidate fore.messages[i];
    for(var i = 0; i< back.messages.count; i++) invalidate back.messages[i];

    // snapshotLayer ‚𖳌ø‰»
    invalidate snapshotLayer if snapshotLayer !== void;

    // tempLayer ‚𖳌ø‰»
    invalidate tempLayer if tempLayer !== void;

    // ƒX[ƒp[ƒNƒ‰ƒX‚Ì finalize ‚ðŒÄ‚Ô
    super.finalize(...);
    }

    //-------------------------------------------------- onCloseQuery/close --

    function onCloseQuery()
    {
    saveSystemVariables();
    if(!askOnClose) { super.onCloseQuery(true); return; }
    super.onCloseQuery(askYesNo("Quit the GameH"));
    }

    function close()
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    saveSystemVariables();
    super.close(...);
    }

    function shutdown()
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚邪AI—¹Šm”F‚ðs‚í‚È‚¢
    // ‚±‚̃ƒ\ƒbƒh“à‚Å close ‚ð‚·‚é‚ƁA—lX‚È
    // ƒIƒuƒWƒFƒNƒg‚ª–³Œø‰»‚³‚ê‚Ä‚µ‚Ü‚¢A‚±‚Ì
    // ŠÖ”‚*‚ç–ß‚Á‚½æ‚ŃGƒ‰[‚ª”­¶‚·‚éB
    // ‚»‚Ì‚½‚߁A‚¢‚Á‚½‚ñ AsyncTrigger ‚ð‰î‚µ‚āA
    // ‘S‚Ẵƒ\ƒbƒh‚*‚ç‹A‚Á‚½‚ ‚ƂɃVƒƒƒbƒgƒ_ƒEƒ“
    // ˆ—‚ðs‚¤B
    global.shutdownTrigger =
    new AsyncTrigger(handleShutdown, '');
    global.shutdownTrigger.cached = true;
    global.shutdownTrigger.trigger();
    if(conductor.status == conductor.mRun)
    conductor.interrupt();
    // ƒRƒ“ƒ_ƒNƒ^‚ª‘–s’†‚ÌŽž‚Í
    // ƒRƒ“ƒ_ƒNƒ^‚É’†’f‚ð“`‚¦‚é
    }

    function handleShutdown()
    {
    // shutdown() ‚*‚ç‚̃Vƒƒƒbƒgƒ_ƒEƒ“—v‹‚ð
    // ŽÀÛ‚ɏˆ—‚·‚郁ƒ\ƒbƒh
    var askOnClose_save = askOnClose;
    askOnClose = false;
    close();
    if(this isvalid) askOnClose = askOnClose_save;
    }

    function closeByScript(elm)
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    // ‚¿‚å‚Á‚Æ–Ê“|‚­‚³‚¢‚Æ‚ð‚â‚Á‚Ä‚¢‚é‚Ì‚Í
    // shutdown ‚Æ“¯‚¶——R
    // u‚¢‚¢‚¦v‚ª‘I‘ð‚³‚ê‚ăEƒBƒ“ƒhƒE‚ª•Â‚¶‚È‚*‚Á‚½ê‡‚Í
    // 'not_closed' ƒgƒŠƒK‚ª”­s‚³‚êAŽÀs‚͍ĊJ‚·‚éB
    var askOnClose_save = askOnClose;
    if(elm.ask !== void && !(+elm.ask)) askOnClose = false;
    global.shutdownTrigger =
    new AsyncTrigger(handleCloseByScript, '');
    global.shutdownTrigger.cached = true;
    global.shutdownTrigger.trigger();

    // closeByScript ‚́A‚±‚̃nƒ“ƒhƒ‰‚ªI‚í‚Á‚½’¼Œã‚É
    // uI—¹‚µ‚Ü‚·‚*Hv‚̃_ƒCƒAƒƒO‚ð•\Ž¦‚·‚éB
    // I—¹‚·‚éê‡‚Í‚»‚̂܂܏I—¹‚·‚éB
    // I—¹‚µ‚È‚¢ê‡‚Í 'not_closed' ƒgƒŠƒK‚ª”­s‚³‚êA
    // ŽÀs‚ÍŒp‘±‚·‚éB
    conductor.wait(%[
    not_closed : askOnClose_save
    ? (function
    {
    // ŽÀÛ‚É‚±‚ꂪŒÄ‚΂ê‚邱‚Æ‚Í‚È‚¢‚ªAˆê‰ž
    askOnClose = true;
    } incontextof this)
    : (function
    {
    } incontextof this)
    ]);
    }

    function handleCloseByScript()
    {
    // shutdown() ‚*‚ç‚̃Vƒƒƒbƒgƒ_ƒEƒ“—v‹‚ð
    // ŽÀÛ‚ɏˆ—‚·‚郁ƒ\ƒbƒh
    close();
    if(this isvalid) // ‚¢‚¢‚¦ ‚ª‘I‘ð‚³‚ê‚½ê‡
    conductor.trigger('not_closed');
    }

    //------------------------------------------------------ ƒvƒ‰ƒOƒCƒ“ˆ— --

    function forEachEventHook(method, func, arg)
    {
    // ‚·‚ׂẴvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚Ì method ‚É‚½‚¢‚µ‚Ä
    // func ‚ðŽÀs‚·‚é
    // func ‚̈ø”‚É‚ÍŠe—v‘f‚Æ arg ‚ª“n‚³‚ê‚é
    if(kagPlugins.count)
    {
    var array = [];
    array.assign(kagPlugins); // ‚¢‚Á‚½‚ñƒRƒs[‚µAƒRƒs[‚µ‚½•¨‚ɑ΂µ‚ÄŽÀs‚·‚é
    var arraycount = array.count;
    for(var i =0; i<arraycount; i++)
    {
    var obj = array[i];
    if(typeof obj[method] != "undefined")
    func(obj[method], arg);
    }
    }
    }

    function addPlugin(plugin)
    {
    // ƒvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚ð’ljÁ
    kagPlugins.add(plugin);
    }

    function removePlugin(plugin)
    {
    // ƒvƒ‰ƒOƒCƒ“ƒIƒuƒWƒFƒNƒg‚ðíœ
    kagPlugins.remove(plugin);
    }

    //---------------------------------------------------------- ƒtƒbƒNˆ— --

    function callHook(array, arg1, arg2, arg3)
    {
    if(array.count)
    {
    var processed = false;
    var newarray = [];
    newarray.assign(array);
    var arraycount = newarray.count;
    for(var i = 0; i < arraycount; i++)
    {
    var func = newarray[i];
    var ret = func(arg1, arg2, arg3);
    processed = processed || ret;
    }
    return processed;
    }
    else
    {
    return false;
    }
    }

    //------------------------------------------ ƒpƒbƒh‚̃L[ƒ}ƒbƒsƒ“ƒOì¬ --

    function createPadKeyMap()
    {
    // ƒpƒbƒh“ü—Í‚Æ‚»‚ê‚ɑΉž‚·‚é“®ì‚̃}ƒbƒsƒ“ƒOB
    // •W€‚ł͏\ŽšƒL[‚̓L[ƒ{[ƒh‚̃J[ƒ\ƒ‹ƒL[‚Ƀ}ƒbƒsƒ“ƒOA
    // ƒ{ƒ^ƒ“1 ‚Í ReturnAƒ{ƒ^ƒ“2 ‚Í ESCAƒ{ƒ^ƒ“3 ‚Í ƒƒbƒZ[ƒW—š—ð‚Ì•\Ž¦
    // ‚Ƀ}ƒbƒsƒ“ƒO‚³‚ê‚éB
    // ŠÖ”‚ðŽw’肵‚½ê‡‚̓{ƒ^ƒ“‚ð‰Ÿ‚µ‚½‚Æ‚«‚É‚Í‚»‚̊֐”‚ªŒÄ‚΂ê‚éB

    padKeyMap = %[
    VK_PADLEFT => VK_LEFT,
    VK_PADRIGHT => VK_RIGHT,
    VK_PADUP => VK_UP,
    VK_PADDOWN => VK_DOWN,
    VK_PAD1 => VK_RETURN,
    VK_PAD2 => VK_ESCAPE,
    VK_PAD3 =>
    function(ev) {
    showHistoryByKey(this);
    },
    ];

    // padKeyMapReverse ‚ðì¬
    padKeyMapReverse = %[];
    var ar = [];
    ar.assign(padKeyMap);
    for(var i = 0; i < ar.count; i += 2)
    {
    if(typeof(ar[i+1]) != "Object")
    {
    padKeyMapReverse[ar[i+1]] = ar[i];
    }
    }
    }

    function getKeyState(key)
    {
    // System.getKeyState ŠÖ”‚Æ“¯“™‚¾‚ªAƒpƒbƒh‚̃L[‚ÉŠÖ‚µ‚Ä‚à
    // ”½‰ž‚ð•Ô‚·
    var sg = System.getKeyState;
    var state = sg(key);
    if(state) return true;
    var pad_key = padKeyMapReverse[key];
    if(pad_key !== void)
    {
    // ƒL[ƒR[ƒh -> ƒpƒbƒh‚̃L[ƒR[ƒh‚Ì•ÏŠ·‚ªŒ*‚‚*‚Á‚½
    return sg(pad_key);
    }
    return false;
    }

    //-------------------------------------------------------------- action --

    function action(ev)
    {
    if(ev.type == 'onKeyDown' && ev.target === this)
    {
    // ƒpƒbƒh“ü—͂ɑΉž‚·‚鏈—
    var handler = padKeyMap[ev.key];
    if(handler !== void)
    {
    // ƒnƒ“ƒhƒ‰‚ªŒ*‚‚*‚Á‚½
    if(typeof(handler) == "Object")
    {
    // ƒnƒ“ƒhƒ‰‚͊֐”
    (handler incontextof this)(ev);
    }
    else
    {
    // ƒnƒ“ƒhƒ‰‚̓L[ƒR[ƒh
    postInputEvent('onKeyDown', %[key: handler]);
    postInputEvent('onKeyUp', %[key: handler]);
    }
    }
    }
    }

    //------------------------------------------------------ tempLayer ŠÖ˜A --

    property temporaryLayer
    {
    // ƒ[ƒNƒGƒŠƒA‚Æ‚µ‚Ĉꎞ“I‚ÉŽg—p‚Å‚«‚郌ƒCƒ„‚ð•Ô‚·
    getter()
    {
    if(tempLayer === void)
    {
    tempLayer = new KAGLayer(this, primaryLayer);
    tempLayer.name = "ˆêŽžƒ[ƒNƒŒƒCƒ„";
    }
    return tempLayer;
    }
    }

    //------------------------------------------------ ƒƒjƒ…[ƒAƒCƒeƒ€ŠÖ˜A --

    function onExitMenuItemClick(sender)
    {
    close();
    }

    function onRightClickMenuItemClick(sender)
    {
    onPrimaryRightClick(); // ‰EƒNƒŠƒbƒN‚Ì“®ì
    }

    function onShowHistoryMenuItemClick(sender)
    {
    if(historyLayer.visible) hideHistory(); else showHistory();
    }

    function onSkipToNextStopMenuItemClick(sender)
    {
    skipToStop();
    }

    function onAutoModeMenuItemClick(sender)
    {
    if(autoMode) cancelAutoMode(); else enterAutoMode();
    }

    function onAutoModeWaitMenuClick(sender)
    {
    sender.checked = true;
    autoModePageWait = sender.wait;
    autoModeLineWait = sender.lwait;
    }

    function onBackStartMenuItemClick(sender)
    {
    goBackHistory();
    }

    function onGoToStartMenuItemClick(sender)
    {
    goToStartWithAsk();
    }

    function onChSpeedMenuItemClick(sender)
    {
    sender.checked = true;
    userChSpeed = sender.speed;
    setUserSpeed();
    saveSystemVariables();
    }

    function onChNonStopToPageBreakItemClick(sender)
    {
    chNonStopToPageBreak = ! chNonStopToPageBreak;
    if(typeof this.chNonStopToPageBreakItem != "undefined")
    chNonStopToPageBreakItem.checked = chNonStopToPageBreak;
    saveSystemVariables();
    }

    function onCh2ndNonStopToPageBreakItemClick(sender)
    {
    ch2ndNonStopToPageBreak = ! ch2ndNonStopToPageBreak;
    if(typeof this.ch2ndNonStopToPageBreakItem != "undefined")
    ch2ndNonStopToPageBreakItem.checked = ch2ndNonStopToPageBreak;
    saveSystemVariables();
    }

    function onCh2ndSpeedMenuItemClick(sender)
    {
    sender.checked = true;
    userCh2ndSpeed = sender.speed;
    setUserSpeed();
    saveSystemVariables();
    }

    function onChAntialiasMenuItemClick(sender)
    {
    chDefaultAntialiased = !chDefaultAntialiased;
    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;
    setMessageLayerUserFont();
    saveSystemVariables();
    }

    function onChChangeFontMenuItem(sender)
    {
    selectFont();
    saveSystemVariables();
    }

    function onRestoreMenuClick(sender)
    {
    if(!freeSaveDataMode) return;
    loadBookMarkFromFileWithAsk();
    }

    function onStoreMenuClick(sender)
    {
    if(!freeSaveDataMode) return;
    saveBookMarkToFileWithAsk();
    }

    function onWindowedMenuItemClick(sender)
    {
    if(fullScreened)
    {
    try
    {
    fullScreen = false;
    }
    catch(e)
    {
    Debug.notice("ƒEƒBƒ“ƒhƒEƒ‚[ƒh‚Ɉڍs‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½ : " + e.message);
    }
    fullScreened = fullScreen;
    if(fullScreened)
    fullScreenMenuItem.checked = true;
    else
    windowedMenuItem.checked = true;
    }
    saveSystemVariables();
    }

    function onFullScreenMenuItemClick(sender)
    {
    if(!fullScreened)
    {
    try
    {
    fullScreen = true;
    }
    catch(e)
    {
    Debug.notice("ƒtƒ‹ƒXƒNƒŠ[ƒ“ƒ‚[ƒh‚Ɉڍs‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½ : " + e.message);
    }
    fullScreened = fullScreen;
    if(fullScreened)
    fullScreenMenuItem.checked = true;
    else
    windowedMenuItem.checked = true;
    }
    saveSystemVariables();
    }

    function onHelpIndexMenuItemClick(sender)
    {
    // ƒwƒ‹ƒvƒtƒ@ƒCƒ‹‚ðŠJ‚­
    System.shellExecute(Storages.getLocalName(System.exePath) + helpFile);
    }

    function onHelpAboutMenuItemClick(sender)
    {
    // u‚±‚̃\ƒtƒg‚ɂ‚¢‚āvƒEƒBƒ“ƒhƒE‚ð•\Ž¦
    var win = new global.KAGWindow(false, aboutWidth, aboutHeight);
    win.setPos(left + ((width - win.width)>>1), top + ((height - win.height)>>1));
    win.process('about.ks' ,,, true); // about.ks ‚ð immediate ‚Å•\Ž¦
    win.showModal(); // ƒ‚[ƒh•t‚«‚Å•\Ž¦
    invalidate win;
    }

    function onReloadScenarioMenuItemClick(sender)
    {
    saveBookMark(1000, false);
    loadBookMark(1000);
    }

    function onShowConsoleMenuItemClick(sender)
    {
    Debug.console.visible = true;
    }

    function onShowContollerMenuItemClick(sender)
    {
    Debug.controller.visible = true;
    }

    function internalSetMenuAccessibleAll(menu, state)
    {
    // autoEnable ‚ª true ‚Ì‚·‚ׂẴƒjƒ…[€–Ú‚Ì accessible ‚É’l state ‚ð
    // Ý’è‚·‚é
    if(typeof menu.autoEnable != "undefined" && menu.autoEnable)
    menu.accessible = state;
    if(typeof menu.stopRecur == "undefined" || !menu.stopRecur)
    {
    var children = menu.children;
    for(var i = children.count -1; i >= 0; i--)
    internalSetMenuAccessibleAll(children[i], state); // Ä‹A
    }
    }

    function canStore()
    {
    return storeEnabled && storeLabelPassed;
    }

    function canRestore()
    {
    return restoreEnabled;
    }

    function setMenuAccessibleAll()
    {
    // ƒƒjƒ…[€–Ú‚ÌŽg—p‰Â/•s‰Â‚ðÝ’è‚·‚é

    // autoEnable ‚ª true ‚Ì‚·‚ׂẴƒjƒ…[€–Ú‚Ì accessible ‚Ì
    // ’l‚ðÝ’è‚·‚é
    var notmodal = !historyLayer.visible && !messageLayerHiding;
    var state = inStable && notmodal;
    internalSetMenuAccessibleAll(menu, state);

    // ‚»‚Ì‘¼‚̃ƒjƒ…[‚ÌŽg—p‰Â/•s‰Â
    if(typeof this.skipToNextStopMenuItem != "undefined")
    skipToNextStopMenuItem.enabled = state && !inSleep && nextSkipEnabled;

    if(typeof this.rightClickMenuItem != "undefined")
    rightClickMenuItem.enabled = inStable && !historyLayer.visible;

    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.enabled = inStable && !messageLayerHiding &&
    historyEnabled;

    if(typeof this.autoModeMenuItem != "undefined")
    autoModeMenuItem.enabled = notmodal;

    if(typeof this.goBackMenuItem != "undefined")
    goBackMenuItem.enabled = state && isHistoryOfStoreAlive();

    if(typeof this.goToStartMenuItem != "undefined")
    goToStartMenuItem.enabled = state && startAnchorEnabled;

    if(typeof this.storeMenu != "undefined")
    {
    var st = state && canStore();
    var children = storeMenu.children;
    if(freeSaveDataMode) storeMenu.enabled = st;
    for(var i = children.count - 1; i >= 0; i--)
    {
    var obj = children[i];
    obj.enabled = obj.orgEnabled && st;
    }
    }

    if(typeof this.restoreMenu != "undefined")
    {
    var st = state && canRestore();
    var children = restoreMenu.children;
    if(freeSaveDataMode) restoreMenu.enabled = st;
    for(var i = children.count - 1; i >= 0; i--)
    {
    var obj = children[i];
    obj.enabled = obj.orgEnabled && st;
    }
    }
    }

    //----------------------------------------------- ƒ}ƒEƒXƒL[‚ð—LŒø‚É‚·‚é --

    function enableMouseKey()
    {
    // ƒ}ƒEƒXƒL[‚ð—LŒø‚É‚·‚é
    if(mouseKeyEnabledCount == 0)
    {
    useMouseKey = true;
    mouseCursorState = mcsVisible;
    }
    mouseKeyEnabledCount++; // ŽQÆƒJƒEƒ“ƒ^•ûŽ®
    }

    function disableMouseKey()
    {
    // ƒ}ƒEƒXƒL[‚𖳌ø‚É‚·‚é
    mouseKeyEnabledCount --;
    if(mouseKeyEnabledCount == 0) useMouseKey = false;
    }

    //----------------------------------------------------- ƒVƒXƒeƒ€•Ï”ŠÖ˜A --

    function loadSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚̓ǂݍž‚Ý
    try
    {
    var fn = saveDataLocation + "/" + dataName +
    "sc.ksd";
    if(Storages.isExistentStorage(fn))
    {
    scflags = Scripts.evalStorage(fn);
    scflags = %[] if scflags === void;
    }
    else
    {
    scflags = %[];
    }

    var fn = saveDataLocation + "/" + dataName +
    "su.ksd";
    if(Storages.isExistentStorage(fn))
    {
    sflags = Scripts.evalStorage(fn);
    sflags = %[] if sflags === void;
    }
    else
    {
    sflags = %[];
    }
    }
    catch(e)
    {
    throw new Exception("ƒVƒXƒeƒ€•Ï”ƒf[ƒ^‚ð“ǂݍž‚ß‚È‚¢‚*A"
    "‚ ‚é‚¢‚̓VƒXƒeƒ€•Ï”ƒf[ƒ^‚ª‰ó‚ê‚Ä‚¢‚Ü‚·(" + e.message + ")");
    }
    }

    function setSystemStateFromSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚ÉŠî‚¢‚ăVƒXƒeƒ€‚ðÝ’è
    // (ƒtƒ‹ƒXƒNƒŠ[ƒ“ŠÖ˜A‚ð‚Ì‚¼‚­)
    if(scflags.autoModePageWait !== void)
    {
    if(typeof this.autoModeWaitMenu !== "undefined")
    {
    var children = autoModeWaitMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.wait !== "undefined" && item.wait == scflags.autoModePageWait)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    if(scflags.userChSpeed !== void)
    {
    if(typeof this.chSpeedMenu !== "undefined")
    {
    var children = chSpeedMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.speed !== "undefined" && item.speed == scflags.userChSpeed)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    if(scflags.userCh2ndSpeed !== void)
    {
    if(typeof this.chSpeedMenu !== "undefined")
    {
    var children = ch2ndSpeedMenu.children;
    for(var i = children.count-1; i >= 0; i--)
    {
    var item = children[i];
    if(typeof item.speed !== "undefined" && item.speed == scflags.userCh2ndSpeed)
    {
    item.checked = true;
    break;
    }
    }
    }
    }

    lastSaveDataNameGlobal = scflags.lastSaveDataNameGlobal if scflags.lastSaveDataNameGlobal !== void;

    bookMarkNames = scflags.bookMarkNames if scflags.bookMarkNames !== void;
    bookMarkDates = scflags.bookMarkDates if scflags.bookMarkDates !== void;
    bookMarkProtectedStates = scflags.bookMarkProtectedStates if scflags.bookMarkProtectedStates !== void;

    autoModePageWait = scflags.autoModePageWait if scflags.autoModePageWait !== void;
    autoModeLineWait = scflags.autoModeLineWait if scflags.autoModeLineWait !== void;
    userChSpeed = scflags.userChSpeed if scflags.userChSpeed !== void;
    userCh2ndSpeed = scflags.userCh2ndSpeed if scflags.userCh2ndSpeed !== void;

    setUserSpeed();

    chNonStopToPageBreak = scflags.chNonStopToPageBreak if scflags.chNonStopToPageBreak !== void;
    if(typeof this.chNonStopToPageBreakItem != "undefined")
    chNonStopToPageBreakItem.checked = chNonStopToPageBreak;

    ch2ndNonStopToPageBreak = scflags.ch2ndNonStopToPageBreak if scflags.ch2ndNonStopToPageBreak !== void;
    if(typeof this.ch2ndNonStopToPageBreakItem != "undefined")
    ch2ndNonStopToPageBreakItem.checked = ch2ndNonStopToPageBreak;

    chDefaultAntialiased = scflags.chDefaultAntialiased if scflags.chDefaultAntialiased !== void;
    if(typeof this.chAntialiasMenuItem != "undefined")
    chAntialiasMenuItem.checked = chDefaultAntialiased;
    chDefaultFace = scflags.chDefaultFace if scflags.chDefaultFace !== void;

    setMessageLayerUserFont();

    bgm.restoreSystemState(scflags);

    for(var i = 0; i<numSEBuffers; i++)
    {
    se[i].restoreSystemState(scflags);
    }
    }

    function clearSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚̃NƒŠƒA
    (Dictionary.clear incontextof sflags)();
    }

    function saveSystemVariables()
    {
    // ƒVƒXƒeƒ€•Ï”‚Ì•Û‘¶
    if(!isMain) return;

    // ƒvƒ‰ƒOƒCƒ“‚ðŒÄ‚Ô
    forEachEventHook('onSaveSystemVariables',
    function(handler, f) { handler(); } incontextof this);

    // ƒtƒ‹ƒXƒNƒŠ[ƒ“
    scflags.fullScreen = fullScreened;

    // •¶Žš•\Ž¦‘¬“x
    scflags.autoModePageWait = autoModePageWait;
    scflags.autoModeLineWait = autoModeLineWait;
    scflags.userChSpeed = userChSpeed;
    scflags.userCh2ndSpeed = userCh2ndSpeed;
    scflags.chDefaultAntialiased = chDefaultAntialiased;
    scflags.chDefaultFace = chDefaultFace;
    scflags.chNonStopToPageBreak = chNonStopToPageBreak;
    scflags.ch2ndNonStopToPageBreak = ch2ndNonStopToPageBreak;

    // ƒuƒbƒNƒ}[ƒN–¼
    scflags.bookMarkNames = bookMarkNames; // (ƒRƒs[‚Å‚Í‚È‚­‚Ä)ŽQÆ‚ŏ\•ª
    scflags.bookMarkDates = bookMarkDates;
    scflags.bookMarkProtectedStates = bookMarkProtectedStates;

    scflags.lastSaveDataNameGlobal = lastSaveDataNameGlobal;

    // ƒtƒ@ƒCƒ‹‚ɏ‘‚«ž‚Þ
    if(!readOnlyMode)
    {
    var fn = saveDataLocation + "/" + dataName +
    "sc.ksd";
    (Dictionary.saveStruct incontextof scflags)(fn, saveDataMode);

    var fn = saveDataLocation + "/" + dataName +
    "su.ksd";
    (Dictionary.saveStruct incontextof sflags)(fn, saveDataMode);
    }
    }

    //------------------------------------------------------- ƒQ[ƒ€•Ï”ŠÖ˜A --

    function internalStoreFlags(f)
    {
    // f ‚ÉŒ»Ý‚̏ó‘Ô‚ð‹L˜^‚·‚é

    // KAGWindow ‚ÉŠÖ‚·‚é‚à‚Ì
    (Dictionary.clear incontextof f)(); // ƒNƒŠƒA
    // ‚±‚±‚Ì [start_store_vars] ‚*‚ç [end_store_vars] ‚ň͂܂ꂽ•”•ª‚Í
    // ––’[‚Ì perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚é‚̂ŁA‚±‚̃}[ƒN‚ðÁ‚µ‚½‚è
    // ‚±‚̃}[ƒN‚ÌŠÔ‚ð•ÒW‚µ‚½‚肵‚È‚¢‚±‚ƁB
    // [start_store_vars]
    f.lastSaveDataName = lastSaveDataName;
    f.quaking = quaking;
    f.quakeEndTick = quakeEndTick;
    f.quakeHorzMax = quakeHorzMax;
    f.quakeVertMax = quakeVertMax;
    f.quakePhase = quakePhase;
    f.historyWriteEnabled = historyWriteEnabled;
    f.historyEnabled = historyEnabled;
    f.numCharacterLayers = numCharacterLayers;
    f.numMessageLayers = numMessageLayers;
    f.currentNum = currentNum;
    f.currentPage = currentPage;
    f.currentWithBack = currentWithBack;
    f.chUserMode = chUserMode;
    f.chSpeed = chSpeed;
    f.actualChSpeed = actualChSpeed;
    f.beforeNoWaitActualChSpeed = beforeNoWaitActualChSpeed;
    f.beforeNoWaitChUserMode = beforeNoWaitChUserMode;
    f.clickSkipEnabled = clickSkipEnabled;
    f.nextSkipEnabled = nextSkipEnabled;
    f.canCancelSkipByClick = canCancelSkipByClick;
    f.autoWCEnabled = autoWCEnabled;
    f.autoWCChars = autoWCChars;
    f.rightClickEnabled = rightClickEnabled;
    f.rightClickCall = rightClickCall;
    f.rightClickJump = rightClickJump;
    f.rightClickTarget = rightClickTarget;
    f.rightClickStorage = rightClickStorage;
    f.rightClickName = rightClickName;
    f.rightClickCurrentMenuName = rightClickCurrentMenuName;
    f.lastClickGlyphVisible = lastClickGlyphVisible;
    f.cursorDefault = cursorDefault;
    f.cursorPointed = cursorPointed;
    f.cursorWaitingClick = cursorWaitingClick;
    f.cursorDraggable = cursorDraggable;
    f.startAnchorEnabled = startAnchorEnabled;
    f.storeEnabled = storeEnabled;
    f.restoreEnabled = restoreEnabled;
    f.currentLabel = currentLabel;
    f.currentPageName = currentPageName;
    // [end_store_vars]

    // perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚È‚¢‚à‚́A‚¢‚­‚‚*B
    // Ž*“®ƒEƒFƒCƒg
    f.autoWCWaits = [];
    f.autoWCWaits.assign(autoWCWaits); // Ž*“®ƒEƒFƒCƒg‚̃EƒFƒCƒg

    // bgm
    f.bgm = bgm.store();

    // Œø‰Ê‰¹
    f.se = [];
    for(var i = 0; i<numSEBuffers; i++)
    {
    f.se[i] = se[i].store();
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„
    f.foreMessageLayers = [];
    f.backMessageLayers = [];
    for(var i = 0; i < numMessageLayers; i++)
    {
    f.foreMessageLayers[i] = fore.messages[i].store();
    f.backMessageLayers[i] = back.messages[i].store();
    }

    // ‘OŒiƒŒƒCƒ„
    f.foreCharacterLayers = [];
    f.backCharacterLayers = [];
    for(var i = 0; i < numCharacterLayers; i++)
    {
    f.foreCharacterLayers[i] = fore.layers[i].store();
    f.backCharacterLayers[i] = back.layers[i].store();
    }

    // ”wŒiƒŒƒCƒ„
    f.foreBaseLayer = fore.base.store();
    f.backBaseLayer = back.base.store();

    // ƒEƒBƒ“ƒhƒEƒLƒƒƒvƒVƒ‡ƒ“
    f.caption = caption;

    // ƒRƒ“ƒ_ƒNƒ^
    f.mainConductor = mainConductor.store();
    if(!saveMacros) f.mainConductor.macros = void;
    // ƒ}ƒNƒî•ñ‚ð void ‚ŏ㏑‚«‚·‚é‚Æžx’†‚̃}ƒNƒî•ñ‚Í–³Œø‚É‚È‚é

    // ƒƒbƒZ[ƒW—š—ð
    if(historyLayer.storeState)
    {
    f.historyData = historyLayer.save();
    }

    // ƒ€[ƒr[
    if( isMain )
    {
    f.movies = [];
    for( var i = 0; i < numMovies; i++)
    f.movies[i] = movies[i].store();
    }

    // storeHook
    forEachEventHook('onStore',
    function(handler, f) { handler(f.flags, f.options); } incontextof this,
    %[flags:f, options:void]);
    }

    function storeFlags()
    {
    // pcflags, pflags ‚É’l‚ð‘‚«ž‚Þ

    // flags -> pflags
    (Dictionary.assignStruct incontextof pflags)(flags);

    internalStoreFlags(pcflags);
    }

    function internalRestoreFlags(f, clear = true, elm = void)
    {
    // f ‚*‚çî•ñ‚ð“ǂݏo‚·
    // clear ‚ª true ‚È‚ç‚΃ƒbƒZ[ƒWƒŒƒCƒ„‚ðƒNƒŠƒA‚·‚é
    // se, bgm ‚ª‚»‚ꂼ‚ê true ‚È‚ç‚΂»‚̏î•ñ‚à”½‰f‚³‚¹‚é
    // backlay ‚ª true ‚̏ꍇ‚́A•\‰æ–ʂɃ[ƒh‚·‚ׂ«‚à‚Ì‚ð— ‰æ–ʂɃ[ƒh‚·‚é

    // KAGWindow ‚ÉŠÖ‚·‚é‚à‚Ì
    // ‚±‚±‚Ì [start_restore_vars] ‚*‚ç [end_restore_vars] ‚ň͂܂ꂽ•”•ª‚Í
    // (—ª)
    // [start_restore_vars]
    lastSaveDataName = f.lastSaveDataName if f.lastSaveDataName !== void;
    quaking = f.quaking if f.quaking !== void;
    quakeEndTick = f.quakeEndTick if f.quakeEndTick !== void;
    quakeHorzMax = f.quakeHorzMax if f.quakeHorzMax !== void;
    quakeVertMax = f.quakeVertMax if f.quakeVertMax !== void;
    quakePhase = f.quakePhase if f.quakePhase !== void;
    historyWriteEnabled = f.historyWriteEnabled if f.historyWriteEnabled !== void;
    historyEnabled = f.historyEnabled if f.historyEnabled !== void;
    numCharacterLayers = f.numCharacterLayers if f.numCharacterLayers !== void;
    numMessageLayers = f.numMessageLayers if f.numMessageLayers !== void;
    currentNum = f.currentNum if f.currentNum !== void;
    currentPage = f.currentPage if f.currentPage !== void;
    currentWithBack = f.currentWithBack if f.currentWithBack !== void;
    chUserMode = f.chUserMode if f.chUserMode !== void;
    chSpeed = f.chSpeed if f.chSpeed !== void;
    actualChSpeed = f.actualChSpeed if f.actualChSpeed !== void;
    beforeNoWaitActualChSpeed = f.beforeNoWaitActualChSpeed if f.beforeNoWaitActualChSpeed !== void;
    beforeNoWaitChUserMode = f.beforeNoWaitChUserMode if f.beforeNoWaitChUserMode !== void;
    clickSkipEnabled = f.clickSkipEnabled if f.clickSkipEnabled !== void;
    nextSkipEnabled = f.nextSkipEnabled if f.nextSkipEnabled !== void;
    canCancelSkipByClick = f.canCancelSkipByClick if f.canCancelSkipByClick !== void;
    autoWCEnabled = f.autoWCEnabled if f.autoWCEnabled !== void;
    autoWCChars = f.autoWCChars if f.autoWCChars !== void;
    rightClickEnabled = f.rightClickEnabled if f.rightClickEnabled !== void;
    rightClickCall = f.rightClickCall if f.rightClickCall !== void;
    rightClickJump = f.rightClickJump if f.rightClickJump !== void;
    rightClickTarget = f.rightClickTarget if f.rightClickTarget !== void;
    rightClickStorage = f.rightClickStorage if f.rightClickStorage !== void;
    rightClickName = f.rightClickName if f.rightClickName !== void;
    rightClickCurrentMenuName = f.rightClickCurrentMenuName if f.rightClickCurrentMenuName !== void;
    lastClickGlyphVisible = f.lastClickGlyphVisible if f.lastClickGlyphVisible !== void;
    cursorDefault = f.cursorDefault if f.cursorDefault !== void;
    cursorPointed = f.cursorPointed if f.cursorPointed !== void;
    cursorWaitingClick = f.cursorWaitingClick if f.cursorWaitingClick !== void;
    cursorDraggable = f.cursorDraggable if f.cursorDraggable !== void;
    startAnchorEnabled = f.startAnchorEnabled if f.startAnchorEnabled !== void;
    storeEnabled = f.storeEnabled if f.storeEnabled !== void;
    restoreEnabled = f.restoreEnabled if f.restoreEnabled !== void;
    currentLabel = f.currentLabel if f.currentLabel !== void;
    currentPageName = f.currentPageName if f.currentPageName !== void;
    // [end_restore_vars]

    // perl ƒXƒNƒŠƒvƒg‚É‚æ‚Á‚ÄŽ*“®“I‚ɏˆ—‚³‚ê‚È‚¢‚à‚́A‚¢‚­‚‚*B

    // Ž*“®ƒEƒFƒCƒg
    autoWCWaits.assign(f.autoWCWaits) if f.autoWCWaits !== void;

    // ƒ€[ƒr[
    if( isMain )
    {
    for( var i = 0; i < numMovies; i++)
    movies[i].restore(f.movies[i]);
    }

    // ”wŒiƒŒƒCƒ„
    var backlay = elm != void && elm.backlay != void && +elm.backlay;
    if(backlay)
    {
    back.base.restore(f.foreBaseLayer);
    }
    else
    {
    fore.base.restore(f.foreBaseLayer);
    back.base.restore(f.backBaseLayer);
    }

    // ƒƒbƒZ[ƒWƒŒƒCƒ„
    allocateMessageLayers(numMessageLayers);
    if(backlay)
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    back.messages[i].restore(f.foreMessageLayers[i]);
    }
    }
    else
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    fore.messages[i].restore(f.foreMessageLayers[i]);
    back.messages[i].restore(f.backMessageLayers[i]);
    }
    }

    if(clear)
    {
    for(var i = 0; i < numMessageLayers; i++)
    {
    fore.messages[i].clear();
    back.messages[i].clear();
    }
    if(historyLayer.storeState)
    {
    historyLayer.load(f.historyData);
    }
    else
    {
    if(historyWriteEnabled)
    {
    if(historyLayer.everypage)
    historyLayer.repage();
    else
    historyLayer.reline(), historyLayer.reline();
    }
    historyLayer.clearAction();
    }
    }

    // ‘OŒiƒŒƒCƒ„
    allocateCharacterLayers(numCharacterLayers);
    if(backlay)
    {
    for(var i = 0; i < numCharacterLayers; i++)
    {
    back.layers[i].restore(f.foreCharacterLayers[i]);
    }
    }
    else
    {
    for(var i = 0; i < numCharacterLayers; i++)
    {
    fore.layers[i].restore(f.foreCharacterLayers[i]);
    back.layers[i].restore(f.backCharacterLayers[i]);
    }
    }

    // quake ŠÖ˜A
    restoreQuake();

    // bgm
    if(elm === void || elm.bgm === void || +elm.bgm)
    {
    bgm.restore(f.bgm);
    }

    // Œø‰Ê‰¹
    if(elm === void || elm.se === void || +elm.se)
    {
    for(var i = 0; i<numSEBuffers; i++)
    {
    se[i].restore(f.se[i]);
    }
    }

    // ƒEƒBƒ“ƒhƒEƒLƒƒƒvƒVƒ‡ƒ“
    caption = f.caption;
    System.title = caption;

    // current ‚̐ݒ肵’¼‚µ
    current = (currentPage?back:fore).messages[currentNum];

    // ‰EƒNƒŠƒbƒNƒƒjƒ…[–¼
    if(typeof this.rightClickMenuItem != "undefined")
    rightClickMenuItem.caption = rightClickCurrentMenuName;

    // restoreHook
    forEachEventHook('onRestore',
    function(handler, f) { handler(f.flags, f.clear, f.options); } incontextof this,
    %[flags:f, clear:clear, options:elm]);

    }

    function restoreFlags()
    {
    // pcflags, pflags ‚*‚çî•ñ‚ð“ǂݏo‚·

    // ƒ[ƒhŽžAƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒgî•ñ‚ðƒNƒŠƒA‚·‚é
    purgeMoviePeriod();

    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚Ì”jŠü
    freeSnapshot();

    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“AŽ*“®ˆÚ“®‚Ì’âŽ~
    stopAllTransitions();
    stopAllMoves();

    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ð‰B‚·
    hideClickGlyphs();

    // ƒƒbƒZ[ƒW—š—ð‚ð‰B‚·
    hideHistory();

    // ƒXƒLƒbƒv‚̃Lƒƒƒ“ƒZƒ‹
    cancelSkip();

    // pflags -> flags
    (Dictionary.assignStruct incontextof flags)(pflags);

    // žxŠÇ—ŠÖ˜A
    storeLabelPassed = true;
    nextRecordHistory = false;
    stablePosibility = false;

    // ƒRƒ“ƒ_ƒNƒ^
    currentRecordName = "";
    mainConductor.restore(pcflags.mainConductor);
    extraConductor.clear();
    setConductorToMain();

    // “ǂݍž‚Ý
    internalRestoreFlags(pcflags);

    // ƒƒjƒ…[ŠÖ˜A
    setMenuAccessibleAll();

    // ŽÀsŠJŽn
    processGo();
    }

    function clearVariables()
    {
    // ƒQ[ƒ€•Ï”‚̃NƒŠƒA
    (Dictionary.clear incontextof flags)();
    }

    //--------------------------------------------------------- ’ʉߋL˜^ŠÇ— --

    function pushHistoryOfStore()
    {
    // ’ʉߋL˜^‚ðs‚¤
    // pflags, pcflags ‚ɏî•ñ‚ðŠi”[‚µ‚½Œã‚ɌĂԂ±‚Æ

    if(nextRecordHistory)
    {
    if(stablePosibility)
    {
    // stablePosibility ‚ª false ‚̏ꍇ‚́A
    // ‚»‚±‚̃‰ƒxƒ‹‚ŒʉߋL˜^‚ðs‚Á‚Ä‚à
    // ‚»‚±‚æ‚è‚à‘O‚É–ß‚é‚·‚ׂª‚È‚¢‚̂ŒʉߋL˜^‚ð‚µ‚È‚¢

    // Ž«‘”z—ñ‚ðì¬
    var dic = %[];

    // user ‚Æ core ‚ð‹L˜^
    dic.user = %[];
    (Dictionary.assignStruct incontextof dic.user)(pflags);
    dic.core = %[];
    (Dictionary.assignStruct incontextof dic.core)(pcflags);

    // dic ‚ð historyOfStore ‚̐擪‚É‘}“ü
    historyOfStore.insert(0, dic);

    // ‚͂ݏo‚½•ª‚ðíœ
    if(historyOfStore.count > maxHistoryOfStore)
    historyOfStore.count = maxHistoryOfStore;
    }

    nextRecordHistory = false;
    }
    }

    function setToRecordHistory()
    {
    // ŽŸ‚́u•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹v’ʉߎž‚É
    // ’ʉߋL˜^‚ðs‚¤‚悤‚ɐݒ肷‚é
    // ( ‚½‚¾‚µA‚»‚Ì‚Æ‚«‚É‹L˜^‚³‚ê‚é‚̂́AŒ»Ý‚̏ó‘Ô )
    nextRecordHistory = true;
    }

    function isHistoryOfStoreAlive()
    {
    // ’ʉߋL˜^‚ª—˜—p‰Â”\‚*‚Ç‚¤‚*‚ð•Ô‚·
    return historyOfStore.count;
    }

    function goBackHistory(ask = true)
    {
    // ’ʉߋL˜^‚ð‚½‚Ç‚èA–ß‚é

    if(!isHistoryOfStoreAlive())
    return false;

    var result;
    if(ask)
    {
    var prompt = "u"+ historyOfStore[0].core.currentPageName + "v‚Ü‚Å–ß‚è‚Ü‚·‚*?";
    result = askYesNo(prompt);
    }
    else
    {
    result = true;
    }

    if(result)
    {
    // user ‚Æ core ‚ð pflags, pcflags ‚É–ß‚·
    (Dictionary.assignStruct incontextof pflags)(historyOfStore[0].user);
    (Dictionary.assignStruct incontextof pcflags)(historyOfStore[0].core);

    // ‹L˜^‚̐擪‚ðíœ‚·‚é
    historyOfStore.erase(0);

    // ƒf[ƒ^‚ðŒ³‚ÉAžx‚ð‚½‚Ç‚é“®ì‚ð‚·‚é
    restoreFlags();

    return true;
    }
    return false;
    }

    //--------------------------------------------------------------- žxŠÇ— --

    function createBookMarkSubMenus()
    {
    // užx‚ð‚½‚Ç‚évužx‚ð‚Í‚³‚ށvˆÈ‰º‚ɃTƒuƒƒjƒ…[€–Ú‚ð’ljÁ
    if(freeSaveDataMode) return; // ƒtƒŠ[ƒZ[ƒuƒ‚[ƒh‚Å‚Í‚È‚É‚à‚µ‚È‚¢
    if(typeof this.storeMenu !== "undefined" && storeMenu.visible)
    {
    for(var i = 0; i<numBookMarks; i++)
    {
    var item;
    storeMenu.add(item = new KAGMenuItem(this, string i, 0, onBookMarkStore,
    false));
    item.bmNum = i;
    item.orgEnabled = false;
    }
    }
    if(typeof this.restoreMenu !== "undefined" && restoreMenu.visible)
    {
    for(var i = 0; i<numBookMarks; i++)
    {
    var item;
    restoreMenu.add(item = new KAGMenuItem(this, string i, 0, onBookMarkRestore,
    false));
    item.bmNum = i;
    item.orgEnabled = false;
    }
    }
    }

    function setBookMarkMenuCaptions()
    {
    // užx‚ð‚½‚Ç‚évužx‚ð‚Í‚³‚ށvˆÈ‰º‚̃Tƒuƒƒjƒ…[‚É
    // ƒLƒƒƒvƒVƒ‡ƒ“‚ðÝ’è

    // žx‚ð‹²‚Þ
    if(typeof this.storeMenu !== "undefined")
    {
    var children = storeMenu.children;
    for(var i = children.count - 1; i >= 0; i--)
    {
    if(bookMarkDates[i] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    {
    // žx‚ª‘¶Ý‚·‚é
    var caption;
    if(showBookMarkDate) caption = bookMarkDates[i] + " ";
    caption += bookMarkNames[i];
    var item = children[i];
    item.caption = caption;
    item.enabled = false;
    item.orgEnabled = !bookMarkProtectedStates[i];
    }
    else
    {
    // žx‚ª‘¶Ý‚µ‚È‚¢
    var item = children[i];
    item.caption = "(None)";
    item.enabled = false;
    item.orgEnabled = !bookMarkProtectedStates[i];
    }
    }
    }

    // žx‚ð‚½‚Ç‚é
    if(typeof this.restoreMenu !== "undefined")
    {
    var children = restoreMenu.children;
    for(var i = children.count - 1; i >= 0; i--)
    {
    if(bookMarkDates[i] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    {
    // žx‚ª‘¶Ý‚·‚é
    var caption;
    if(showBookMarkDate) caption = bookMarkDates[i] + " ";
    caption += bookMarkNames[i];
    var item = restoreMenu.children[i];
    item.caption = caption;
    item.enabled = false;
    item.orgEnabled = true;
    }
    else
    {
    var item = restoreMenu.children[i];
    item.caption = "(None)";
    item.enabled = false;
    item.orgEnabled = false;
    }
    }
    }
    setMenuAccessibleAll();
    }

    function setBookMarkProtectedState(num, s)
    {
    // n ”Ô‚Ìžx‚Ì•ÛŒìƒtƒ‰ƒO‚ðÝ’è‚·‚é
    // s = true ‚È‚ç‚Ξx‚ɏ‘‚«ž‚Ý•ÛŒì‚ð‚·‚é
    bookMarkProtectedStates[num] = s;
    setBookMarkMenuCaptions();
    }

    function onBookMarkStore(sender)
    {
    // žx‚ð‚Í‚³‚Þƒƒjƒ…[‚ª‘I‘ð‚³‚ê‚½
    // if(!sender.parent.accessEnabled) return;
    saveBookMarkWithAsk(sender.bmNum);
    }

    function onBookMarkRestore(sender)
    {
    // žx‚ð‚½‚Ç‚éƒƒjƒ…[‚ª‘I‘ð‚³‚ê‚½
    // if(!sender.parent.accessEnabled) return;
    loadBookMarkWithAsk(sender.bmNum);
    }

    function getBookMarkPageName(num)
    {
    // žx”ԍ† num ‚̃uƒbƒNƒ}[ƒN–¼‚𓾂é
    if(bookMarkDates[num] != '') // ‹ó•¶Žš—ñ‚̏ꍇ‚Ížx‚ª‚È‚¢‚Æ‚¢‚¤‚±‚Æ
    return bookMarkNames[num];
    return "(None)";
    }

    function getBookMarkDate(num)
    {
    // žx”ԍ† num ‚Ì“ú•t‚𓾂é
    return bookMarkDates[num];
    }

    function getBookMarkFileNameAtNum(num)
    {
    if(num >= 999) // 999 ”Ԉȍ~‚Í“ÁŽê‚ȃf[ƒ^‚É—p‚¢‚é‚Ì‚Å
    return saveDataLocation + "/" + dataName + num + ".ksd";
    else
    return saveDataLocation + "/" + dataName + num + (saveThumbnail?".bmp":".kdt");
    }

    function lockSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚ðƒƒbƒN‚·‚é
    // ‰‚߂ăXƒiƒbƒvƒVƒ‡ƒbƒg‚ªƒƒbƒN‚³‚ꂽŽž“_‚ł̉æ–Ê‚ð•Û‘¶‚·‚é
    if(snapshotLockCount == 0)
    {
    if(snapshotLayer === void)
    snapshotLayer = new Layer(this, primaryLayer);
    snapshotLayer.setImageSize(scWidth, scHeight);
    snapshotLayer.face = dfAlpha;
    snapshotLayer.piledCopy(0, 0, kag.fore.base, 0, 0, scWidth, scHeight);
    }
    snapshotLockCount ++;
    }

    function unlockSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚̃ƒbƒN‚ð‰ðœ‚·‚é
    if(snapshotLockCount == 0)
    throw new Exception("snapshotLockCount ‚ªƒAƒ“ƒ_[ƒtƒ[‚µ‚Ü‚µ‚½");
    snapshotLockCount --;
    if(snapshotLockCount == 0)
    {
    if(snapshotLayer !== void)
    invalidate snapshotLayer, snapshotLayer = void;
    }
    }

    function calcThumbnailSize()
    {
    // ƒTƒ€ƒlƒCƒ‹‚̃TƒCƒY‚ðŒvŽZ‚·‚é
    // ‰¡•‚Í 133 ‚É
    var ratio = scHeight / scWidth;
    var w = thumbnailWidth;
    var h = (int)(w * ratio);

    // ƒTƒ€ƒlƒCƒ‹—pƒrƒbƒgƒ}ƒbƒv‚̃TƒCƒY‚ðŒvŽZ
    // ƒTƒ€ƒlƒCƒ‹—p‰æ‘œ‚Í 256 F BMP ‚Ü‚½‚Í 24bit ƒtƒ‹ƒJƒ‰[ BMP
    var size;
    if (thumbnailDepth == 8)
    size = ((((w - 1) >> 2) + 1) << 2) * h + 1024 + 54;
    else
    size = (((w * 3 + 3) >> 2) << 2) * h + 54;

    return %[width : w, height : h, size : size];
    }

    function freeSnapshot()
    {
    // ƒXƒiƒbƒvƒVƒ‡ƒbƒg‚ð‹­§“I‚É”jŠü‚µAsnapshotLockCount ‚ð 0 ‚ɐݒ肷‚é
    snapshotLockCount = 0;
    if(snapshotLayer !== void)
    invalidate snapshotLayer, snapshotLayer = void;
    }

    function saveBookMarkToFile(fn, savehist = true)
    {
    // ƒtƒ@ƒCƒ‹ fn ‚Éžx‚ð•Û‘¶‚·‚é
    if(readOnlyMode) return false;
    pcflags.storeTime = (new Date()).getTime(); // “ú•t‚ð•Û‘¶

    // ƒZ[ƒuƒf[ƒ^‚ð‚Ü‚Æ‚ß‚é
    var data = %[];
    data.id = saveDataID;
    data.core = pcflags;
    data.user = pflags;
    if(savehist) data.history = historyOfStore;

    if(saveThumbnail)
    {
    // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶
    lockSnapshot();
    try
    {
    // ƒTƒ€ƒlƒCƒ‹‚̃TƒCƒY‚܂ŏk¬
    var size = calcThumbnailSize();
    var tmp = new Layer(this, primaryLayer);
    try
    {
    tmp.setImageSize(size.width, size.height);
    tmp.face = dfAlpha;
    tmp.stretchCopy(0, 0, size.width, size.height, snapshotLayer,
    0, 0, snapshotLayer.imageWidth, snapshotLayer.imageHeight, stLinear);
    /*
    // ƒTƒ€ƒlƒCƒ‹‰æ‘œ‚ðƒZƒsƒA’²‚É‚µ‚Ä•Û‘¶‚·‚éê‡‚̓Rƒƒ“ƒgƒAƒEƒg‚ð‰ðœ
    tmp.doGrayScale();
    tmp.adjustGamma(
    1.3, 0, 255, // R gamma, floor, ceil
    1.0, 0, 255, // G gamma, floor, ceil
    0.8, 0, 255); // B gamma, floor, ceil
    */
    try
    {
    // ƒTƒ€ƒlƒCƒ‹‚ð•Û‘¶
    tmp.saveLayerImage(fn, "bmp" + thumbnailDepth);

    // ƒf[ƒ^‚ð•Û‘¶
    var mode = saveDataMode;
    mode += "o" + size.size; // ƒ‚[ƒh•¶Žš—ñ‚É ‘‚«ž‚݃IƒtƒZƒbƒg‚ðŽw’è
    (Dictionary.saveStruct incontextof data)(fn, mode);
    }
    catch(e)
    {
    invalidate tmp;
    unlockSnapshot();
    System.inform("File Does not Exist (Can't Open FileA"
    "Overwriting Locked)");
    return false;
    }
    }
    catch(e)
    {
    invalidate tmp;
    throw e;
    }
    invalidate tmp;
    }
    catch(e)
    {
    unlockSnapshot();
    throw e;
    }
    unlockSnapshot();
    }
    else
    {
    // ’ʏí‚̃tƒ@ƒCƒ‹‚É•Û‘¶
    try
    {
    (Dictionary.saveStruct incontextof data)(fn, saveDataMode);
    }
    catch(e)
    {
    System.inform("File Does Not Exist (Can't Open FileA"
    "Overwriting Locked)");
    return false;
    }
    }

    return true;
    }

    function saveBookMark(num, savehist = true)
    {
    // žx”ԍ† num ‚Éžx‚ð•Û‘¶‚·‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[num]) return false;

    var ret = saveBookMarkToFile(getBookMarkFileNameAtNum(num), savehist);
    if(ret)
    {
    // ƒƒjƒ…[ / bookMarkNames / bookMarkDates ‚ðXV
    getBookMarkInfoFromData(pcflags, num);
    }
    return ret;
    }

    function getBookMarkInfoFromData(dic, num)
    {
    // Ž«‘”z—ñ dic ‚*‚çžx‚̃y[ƒW–¼‚Æ“ú•t‚ð“ǂݏo‚µA
    // bookMarkDates[num] ‚â bookMarkNames[num] ‚ɐݒ肷‚é
    if(num < numBookMarks)
    {
    bookMarkNames[num] = dic.currentPageName;
    var date = new Date();
    date.setTime(dic.storeTime);
    date = "%04d/%02d/%02d %02d:%02d".sprintf(
    date.getYear(), date.getMonth() + 1, date.getDate(),
    date.getHours(), date.getMinutes() );
    bookMarkDates[num] = date;
    setBookMarkMenuCaptions();
    saveSystemVariables();
    }
    }

    function loadBookMarkFromFile(fn, loaduser = true)
    {
    // ƒtƒ@ƒCƒ‹ fn ‚*‚çžx‚ð“ǂݍž‚Þ
    // loaduser ‚ª false ‚ÌŽž‚Í user ‚ð“ǂݍž‚Ü‚È‚¢
    try
    {
    if(!Storages.isExistentStorage(fn)) return false; //ƒtƒ@ƒCƒ‹‚ª‚È‚¢

    var data;

    var modestr;

    if(saveThumbnail)
    {
    // Žw’èƒIƒtƒZƒbƒg‚*‚çƒf[ƒ^‚ð“ǂݍž‚Þ
    modestr += "o" + calcThumbnailSize().size;
    }

    data = Scripts.evalStorage(fn, modestr);

    if(data.id != saveDataID)
    {
    System.inform("Try to Load Other System Data", "Error");
    return false;
    }

    pcflags = data.core;
    pcflags = %[] if pcflags === void;
    if(loaduser)
    {
    pflags = data.user;
    pflags = %[] if pflags === void;
    }
    else
    {
    (Dictionary.assignStruct incontextof pflags)(flags);
    }
    historyOfStore = data.history;
    historyOfStore = [] if historyOfStore === void;
    }
    catch(e)
    {
    System.inform("Save cannot be read, the save"
    "May be corrupted or have another form"
    "(" + e.message + ")", "Error");
    return false;
    }

    restoreFlags();
    return true;
    }

    function loadBookMark(num, loaduser = true)
    {
    // žx”ԍ† num ‚*‚çƒf[ƒ^‚ð“ǂݏo‚·
    return loadBookMarkFromFile(getBookMarkFileNameAtNum(num), loaduser);
    }

    function saveBookMarkWithAsk(num)
    {
    // žx”ԍ† num ‚Éžx‚ðÝ’è‚·‚é
    // ‚»‚Ì‚Æ‚«AÝ’è‚·‚é‚*‚Ç‚¤‚*‚ð‚½‚¸‚Ë‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[num]) return false;
    var prompt = "OverWrite Save ";
    if(num < numBookMarks) prompt += (num + 1);
    if(bookMarkDates[num] != "") // bookMarkDates ‚ª‹ó•¶Žš‚̏ꍇ‚Ížx‚Í‘¶Ý‚µ‚È‚¢
    prompt += "u" + bookMarkNames[num] + "v";
    prompt += "and replace withu"+ pcflags.currentPageName + "v?";
    var result = askYesNo(prompt);
    if(result) return saveBookMark(num);
    return false;
    }

    function loadBookMarkWithAsk(num)
    {
    // žx”ԍ† num ‚*‚çžx‚ð“ǂݏo‚·
    // ‚»‚Ì‚Æ‚«A“ǂݏo‚·‚*‚Ç‚¤‚*‚ð‚½‚¸‚Ë‚é
    if(num < numBookMarks && bookMarkDates[num] == "") // bookMarkDates ‚ª‹ó•¶Žš‚̏ꍇ‚Ížx‚Í‘¶Ý‚µ‚È‚¢
    return false;
    var prompt = "Load Save ";
    if(num < numBookMarks) prompt += (num + 1);
    prompt += "u"+ bookMarkNames[num] + "v?";
    var result = askYesNo(prompt);
    if(result) return loadBookMark(num);
    return false;
    }

    function saveBookMarkToFileWithAsk()
    {
    // ”CˆÓ‚̃tƒ@ƒCƒ‹‚Éžx‚ð•Û‘¶‚·‚é
    // currentPageName ‚ðƒtƒ@ƒCƒ‹–¼‚Æ‚µ‚Ä“K‡‚·‚é‚悤‚É
    // •ÏŒ`‚·‚é
    var invalid = "\\/:,;*?\"<>!.";
    var valid = "^FCG–Hhƒ„ID";

    var initialname = saveDataLocation + "/";
    var through = false;
    var orgname = currentPageName;

    if(lastSaveDataNameGlobal != "")
    {
    try
    {
    initialname = Storages.extractStoragePath(lastSaveDataNameGlobal);
    }
    catch(e)
    {
    initialname = saveDataLocation + "/";
    }
    }

    if(orgname == "")
    {
    // žx‚ÌŒ*o‚µ‚ª‚È‚¢‚Ì‚Å
    if(lastSaveDataName == "")
    orgname = System.title; // System.title ‚ð‘ã‚í‚è‚ÉŽg‚¤
    else
    initialname = lastSaveDataName, through = true;
    }

    if(!through)
    {
    var length = orgname.length;
    for(var i = 0; i < length; i++)
    {
    var ch = orgname[i];
    var ind = invalid.indexOf(ch);
    if(ind != -1)
    initialname += valid[ind];
    else if(#ch >= 32)
    initialname += ch;
    }
    }

    // •Û‘¶‚·‚éƒtƒ@ƒCƒ‹–¼‚𓾂é
    var selectdata = %[
    title:"žx‚ð‚Í‚³‚Þ",
    filter: [saveThumbnail ?
    "ƒTƒ€ƒlƒCƒ‹‰æ‘œ•t‚«žxƒf[ƒ^(*.bmp)|*.bmp" :
    "žxƒf[ƒ^(*.kdt)|*.kdt"],
    filterIndex : 1,
    name : initialname,
    initialDir : "",
    defaultExt : saveThumbnail?"bmp":"kdt",
    save : true,
    ];
    if(Storages.selectFile(selectdata))
    {
    // •Û‘¶
    saveBookMarkToFile(lastSaveDataName = lastSaveDataNameGlobal = selectdata.name);
    lastSaveDataName = Storages.chopStorageExt(lastSaveDataName);
    }
    }

    function loadBookMarkFromFileWithAsk()
    {
    // ”CˆÓ‚̃tƒ@ƒCƒ‹‚*‚çžx‚ð“ǂݍž‚Þ
    var initialdir = "";
    if(lastSaveDataNameGlobal == "")
    initialdir = saveDataLocation + "/";

    var selectdata = %[
    title:"žx‚ð‚½‚Ç‚é",
    filter: [saveThumbnail ?
    "ƒTƒ€ƒlƒCƒ‹‰æ‘œ•t‚«žxƒf[ƒ^(*.bmp)|*.bmp" :
    "žxƒf[ƒ^(*.kdt)|*.kdt"],
    filterIndex : 1,
    name : lastSaveDataNameGlobal,
    initialDir : initialdir,
    defaultExt : saveThumbnail?"bmp":"kdt",
    save : false,
    ];
    if(Storages.selectFile(selectdata))
    {
    loadBookMarkFromFile(lastSaveDataName = lastSaveDataNameGlobal = selectdata.name);
    lastSaveDataName = Storages.chopStorageExt(lastSaveDataName);
    }
    }


    function copyBookMark(from, to)
    {
    // žx”ԍ† from ‚*‚çžx”ԍ† to ‚Éžx‚ðƒRƒs[‚·‚é
    if(readOnlyMode) return false;
    if(bookMarkProtectedStates[to]) return;

    var fn = getBookMarkFileNameAtNum(from);

    if(!Storages.isExistentStorage(fn)) return; //ƒtƒ@ƒCƒ‹‚ª‚È‚¢

    var data = Scripts.evalStorage(fn);

    fn = getBookMarkFileNameAtNum(to);

    (Dictionary.saveStruct incontextof data)(fn, saveDataMode);
    getBookMarkInfoFromData(data.core, to);
    }

    function eraseBookMark(num)
    {
    // žx‚ðÁ‚·
    // num < numBookMarks ‚ÌŽž‚É‚µ‚*“®ì‚µ‚È‚¢‚悤‚É‚È‚Á‚½‚Ì‚Å’ˆÓ
    if(num < numBookMarks)
    {
    if(!bookMarkProtectedStates[num])
    {
    bookMarkDates[num] = "";
    setBookMarkMenuCaptions();
    }
    }
    }

    function tempDisableStore(elm)
    {
    // žx‚ðˆêŽž“I‚É•Û‘¶•s‰Â”\‚É‚·‚é
    storeEnabled = true;
    if(elm.store === void)
    storeLabelPassed = false;
    else
    storeLabelPassed = !(+elm.store);
    if(elm.restore == void)
    restoreEnabled = true;
    else
    restoreEnabled = !(+elm.restore);
    setMenuAccessibleAll();
    }

    function setStoreEnabled(enabled)
    {
    // žxƒƒjƒ…[‚Ì—LŒø/–³Œø‚̐ݒè
    storeEnabled = enabled;
    restoreEnabled = enabled;
    setMenuAccessibleAll();
    }

    function setStartAnchorEnabled(enabled)
    {
    // uÅ‰‚É–ß‚év‚Ì—LŒø/–³Œø‚̐ݒè
    startAnchorEnabled = enabled;
    if(enabled) saveBookMark(999, false); // 999 ”Ô‚É•Û‘¶
    setMenuAccessibleAll();
    }

    function goToStart()
    {
    // Å‰‚É–ß‚é
    if(!startAnchorEnabled) return;
    loadBookMark(999, false); // žx‚ð“ǂݍž‚Þ
    }

    function goToStartWithAsk()
    {
    // Å‰‚É–ß‚é(Šm”F‚ ‚è)
    var result = askYesNo("Return to Title?");
    if(result) goToStart();
    }

    function tempSave(num)
    {
    // tempBookMarks[num] ‚ÉŒ»Ý‚̏ó‘Ô‚ð•Û‘¶‚·‚é
    tempBookMarks[num] = %[];
    internalStoreFlags(tempBookMarks[num]);
    }

    function tempLoad(num, elm)
    {
    // tempBookMarks[num] ‚*‚çó‘Ô‚ð“ǂݍž‚Þ
    internalRestoreFlags(tempBookMarks[num], false, elm);
    }

    function restoreBookMark(num, ask = true)
    {
    // KAG 2.x ŒÝŠ·—p
    if(ask)
    return loadBookMarkWithAsk(num);
    else
    return loadBookMark(num);
    }

    function storeBookMark(num, ask = true)
    {
    // KAG 2.x ŒÝŠ·—p
    if(ask)
    return saveBookMarkWithAsk(num);
    else
    return saveBookMark(num);
    }

    //------------------------------------------------- –¢“Ç/Šù“Ç/ƒ‰ƒxƒ‹‹L˜^ --

    function setRecordLabel(storage, label)
    {
    // Œ»Ý‚̃‰ƒxƒ‹‚ðÝ’è‚·‚é
    if(autoRecordPageShowing)
    {
    if(label != '')
    {
    if(label[0] == '*') label = label.substring(1);
    if(label[1] == '-') return; // ƒ[ƒJƒ‹ƒ‰ƒxƒ‹
    }
    currentRecordName = 'trail_' + Storages.chopStorageExt(
    Storages.extractStorageName(storage)) + '_' + label;
    }
    }

    function incRecordLabel(count)
    {
    // sflags[currentRecordName]++
    if(autoRecordPageShowing)
    {
    if(currentRecordName != "")
    {
    if(count)
    {
    if(sflags[currentRecordName] === void)
    sflags[currentRecordName] = 0;
    sflags[currentRecordName]++;
    }
    currentRecordName = "";
    }
    }
    }

    //------------------------------------------- ƒVƒXƒeƒ€‘S‘Ì‚ÉŠÖŒW‚·‚é‚à‚Ì --

    function setTitle(title)
    {
    // ƒ^ƒCƒgƒ‹‚ðÝ’è
    if(isMain) System.title = title;
    caption = title;
    }

    function setCursor(elm)
    {
    // ƒ}ƒEƒXƒJ[ƒ\ƒ‹‚̐ݒè
    var conv = function(variable, value)
    {
    if(value !== void)
    {
    if(!(typeof value == "String" &&
    (value.indexOf('.cur')!=-1 || value.indexOf('.ani')!=-1) ))
    value = +value;
    this[variable] = value;
    }
    } incontextof this;

    conv('cursorDefault', elm['default']);
    conv('cursorPointed', elm.pointed);
    conv('cursorWaitingClick', elm.click);
    conv('cursorDraggable', elm.draggable);
    fore.base.setDefaultCursor(cursorDefault);
    back.base.setDefaultCursor(cursorDefault);
    }

    //---------------------------------------------------- ƒgƒŠƒKŠÇ—(TJS—p) --

    function waitTrigger(elm)
    {
    // elm.name ‚ÅŽ¦‚³‚ꂽƒgƒŠƒK‚ð‘Ò‚Â
    if((elm.canskip !== void && +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    if(elm.onskip !== void) Scripts.eval(elm.onskip);
    return 0; // ‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function(arg)
    {
    if(arg !== void) Scripts.eval(arg);
    } incontextof this,
    click_arg : elm.onskip,
    elm.name => function
    {
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    elm.name => function
    {
    } incontextof this
    ]);
    }
    return -2;
    }

    function trigger(name)
    {
    // name ‚ÅŽ¦‚µ‚½ƒgƒŠƒK‚ð”­“®‚·‚é
    conductor.trigger(name);
    }

    //------------------------------------------------------- ƒƒbƒZ[ƒW—š—ð --

    function showHistory()
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð•\Ž¦‚·‚é
    historyLayer.parent = fore.base; // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̐e‚àÄÝ’è
    historyLayer.absolute = 2000000;
    historyLayer.dispInit();
    historyShowing = true;
    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.checked = true;
    setMenuAccessibleAll();
    }

    function hideHistory()
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ð”ñ•\Ž¦‚É‚·‚é
    historyLayer.dispUninit();
    historyShowing = false;
    if(typeof this.showHistoryMenuItem != "undefined")
    showHistoryMenuItem.checked = false;
    setMenuAccessibleAll();
    lastHistoryHiddenTick = System.getTickCount();
    conductor.trigger('history'); // 'history' ‚ð‘—‚é
    }

    function setHistoryOptions(elm)
    {
    // elm ‚*‚烁ƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    historyWriteEnabled = +elm.output if elm.output !== void;
    historyEnabled = +elm.enabled if elm.enabled !== void;
    if(elm.enabled !== void && !historyEnabled)
    historyLayer.clearAction();
    historyLayer.setOptions(elm); // ‚»‚Ì‘¼‚̃IƒvƒVƒ‡ƒ“
    setMenuAccessibleAll();
    }

    function showHistoryByScenario(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚ðƒVƒiƒŠƒI’†‚*‚ç•\Ž¦‚³‚¹‚é
    showHistory();
    conductor.wait(%[ // ƒRƒ“ƒ_ƒNƒ^‚ð‘Ò‚¿‚É
    history : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    return -2; // break
    }

    //-------------------------------------------------------------- process --

    function process(file, label, countpage = true, immediate = false)
    {
    // Žw’èƒtƒ@ƒCƒ‹AŽw’胉ƒxƒ‹‚*‚çŽÀs‚ðŠJŽn‚·‚é
    if(!usingExtraConductor) incRecordLabel(countpage);
    setUserSpeed();

    if(file != '')
    {
    // ƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Ý
    conductor.loadScenario(file);
    }

    if(label != '')
    {
    // ƒ‰ƒxƒ‹‚Ɉړ®‚·‚é
    conductor.goToLabel(label);
    }

    if(isFirstProcess)
    {
    storeFlags(); // ˆê”ԍŏ‰‚̏ó‘Ô‚ðƒXƒgƒA
    isFirstProcess = false;
    }


    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    inSleep = false;
    notifyRun();
    if(conductor.status != conductor.mRun) conductor.run(immediate); // ŽÀsŠJŽn
    }

    function processGo()
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ðŒ»ÝˆÊ’u‚*‚çŽÀsŠJŽn‚³‚¹‚é
    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    inSleep = false;
    notifyRun();
    conductor.run(false); // ŽÀsŠJŽn
    }

    function processCall(file, label)
    {
    // Žw’èƒtƒ@ƒCƒ‹AŽw’胉ƒxƒ‹‚ðŒÄ‚Ô
    // incRecordLabel(); ‚͌Ă΂Ȃ¢‚Ì‚Å’ˆÓ

    if(file != '')
    {
    // ƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Ý
    conductor.loadScenario(file);
    }

    inSleep = false;
    notifyRun();
    conductor.callLabel(label); // ŽÀsŠJŽn
    dm("ˆ—‚ðŠJŽn‚µ‚Ü‚·");
    if(conductor.status != conductor.mRun) conductor.run();
    }

    //------------------------------------------------- ƒRƒ“ƒ_ƒNƒ^‚̃Cƒxƒ“ƒg --

    function onConductorScenarioLoad(name)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªV‚µ‚¢ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹‚ð“ǂݍž‚Þ‘O‚É‚æ‚΂ê‚éB
    // name ‚͓ǂݍž‚à‚¤‚Æ‚µ‚½ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹B
    // –ß‚è’l‚É•¶Žš—ñ‚ð•Ô‚·‚ƁA‚»‚ê‚ðƒVƒiƒŠƒI‚Æ‚µ‚Ä
    // ƒtƒ@ƒCƒ‹‚Ì‘ã‚í‚è‚ÉŽg‚¤‚悤‚É‚È‚é‚̂ŁA‚±‚±‚ɃtƒBƒ‹ƒ^‚ð‘‚­‚±
    // ‚Æ‚ª‚Å‚«‚éB
    // true ‚ð•Ô‚·‚ƒʏí‚̃VƒiƒŠƒIƒtƒ@ƒCƒ‹“ǂݍž‚Ý‚Æ‚È‚éB
    return true;
    }


    function onConductorScenarioLoaded(name)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªV‚µ‚¢ƒVƒiƒŠƒIƒtƒ@ƒCƒ‹‚ð“ǂݍž‚ñ‚¾
    // if(!usingExtraConductor) incRecordLabel(true);
    return true;
    }

    function onConductorLabel(label, page)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ªƒ‰ƒxƒ‹‚ð’ʉ߂µ‚½
    if(!usingExtraConductor)
    {
    incRecordLabel(true);
    setRecordLabel(conductor.curStorage, label);
    }
    setUserSpeed();
    if(!usingExtraConductor)
    {
    if(!getCurrentRead() && skipMode != 4)
    cancelSkip(); // –¢“ǂȂ̂ŃXƒLƒbƒv‚ð’âŽ~
    currentLabel = label;
    }
    if(page !== void && page !== '')
    {
    if(page[0] == '&') page = Scripts.eval((page.substring(1)));
    currentPageName = page;
    }
    if(page !== void)
    {
    pushHistoryOfStore();
    stablePosibility = false;
    dm(conductor.curStorage + " : ƒ‰ƒxƒ‹/ƒy[ƒW : " + label + "/" + currentPageName);
    if(usingExtraConductor) throw new Exception("‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ““à/extraCondutor"
    "ƒTƒuƒ‹[ƒ`ƒ““à‚Å‚Í•Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚ð‹Lq‚Å‚«‚Ü‚¹‚ñ");
    storeFlags(), storeLabelPassed = true, setMenuAccessibleAll();
    if(recordHistoryOfStore == 1) // 1 : •Û‘¶‰Â”\‚ȃ‰ƒxƒ‹‚²‚Æ
    setToRecordHistory();
    }
    return true;
    }

    function onConductorJump(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚Å jump ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage === void || +elm.countpage);
    return true;
    }

    function onConductorCall(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª call ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage !== void && +elm.countpage);
    return true;
    }

    function onConductorReturn(elm)
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª return ƒ^ƒO‚ðˆ—‚·‚é‚Æ‚«
    if(!usingExtraConductor) incRecordLabel(elm.countpage === void || +elm.countpage);
    if(conductor === extraConductor)
    {
    // extraConductor ƒTƒuƒ‹[ƒ`ƒ“—p‚̃Rƒ“ƒ_ƒNƒ^‚*‚çŒÄ‚΂ê‚Ä‚¢‚é
    if(conductor.callStackDepth == 1)
    {
    // ‚‚܂èAÅI‚Ì return ‚ªŽÀs‚³‚ꂽ‚ÆŒ¾‚¤‚±‚Æ
    dm("extraConductor ƒTƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚è‚Ü‚· ...");
    var run;
    if(elm.storage !== void || elm.target !== void) run = true; else run = false;
    returnExtraConductor(run);
    if(elm.storage !== void) conductor.loadScenario(elm.storage);
    if(elm.target !== void) conductor.goToLabel(elm.target);
    setRecordLabel(conductor.curStorage, currentLabel = conductor.curLabel);
    if(run)
    {
    notifyRun();
    conductor.run();
    }
    isLeavePeriodEvent = false;
    if(elm.storage !== void || elm.target !== void)
    { // return‚ÅŒ³‚̈ʒuˆÈŠO‚ɖ߂鎞‚̓sƒŠƒIƒhƒCƒxƒ“ƒg‚ðƒNƒŠƒA‚·‚éB
    holdPeriodEventQueue.clear();
    isWaitPeriodEvent = false;
    }
    if( isWaitPeriodEvent == true )
    { // [wp]‚ŃsƒŠƒIƒhƒCƒxƒ“ƒg‘Ò‚¿‚ð‚µ‚Ä‚¢‚鎞‚̂݁AƒgƒŠƒK[‚·‚é
    fireMoviePeriodFromQueue();
    }
    return false; // return ‚ÍŽÀs‚µ‚È‚¢
    }
    }
    return true;
    }
    function purgeMoviePeriod()
    {
    isLeavePeriodEvent = false;
    holdPeriodEventQueue.clear();
    isWaitPeriodEvent = false;
    waitedPeriodEventStorageName = void;
    }
    function fireMoviePeriodFromQueue()
    {
    var retVal = false;
    if( holdPeriodEventQueue.count > 0 )
    {
    if( waitedPeriodEventStorageName == conductor.curStorage && conductor == mainConductor )
    {
    for( var i = 0; i < holdPeriodEventQueue.count; i++ )
    {
    conductor.trigger( holdPeriodEventQueue[i] );
    retVal = true;
    }
    }
    holdPeriodEventQueue.clear();
    }
    return retVal;
    }

    function onConductorAfterReturn()
    {
    // ƒRƒ“ƒ_ƒNƒ^‚ª return ƒ^ƒO‚ðŽÀs‚µ‚½Œã
    if(!usingExtraConductor)
    {
    setRecordLabel(conductor.curStorage, currentLabel = conductor.curLabel);
    }
    setUserSpeed();
    if(!usingExtraConductor)
    {
    if(!getCurrentRead() && skipMode != 4)
    cancelSkip(); // –¢“ǂȂ̂ŃXƒLƒbƒv‚ð’âŽ~
    }
    }


    function onConductorScript(script, scriptname, lineofs)
    {
    // iscript ƒ^ƒO
    try
    {
    Scripts.exec(script, scriptname, lineofs);
    }
    catch(e)
    {
    throw new Exception(scriptname + " ‚Ì s " + lineofs + " ‚*‚çŽn‚Ü‚é"
    " iscript ƒuƒƒbƒN‚ŃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B"
    "\n( Ú×‚̓Rƒ“ƒ\[ƒ‹‚ðŽQÆ‚µ‚Ä‚­‚¾‚³‚¢ )\n" + e.message);
    }
    return true;
    }

    function onConductorUnknownTag(tagname, elm)
    {
    // •s–¾‚ȃ^ƒO‚ª‚ ‚Á‚½ê‡
    throw new Exception("ƒ^ƒO/ƒ}ƒNƒ \"" + tagname + "\" ‚Í‘¶Ý‚µ‚Ü‚¹‚ñ");
    return 0; // ‚±‚Ì–ß‚è’l‚́AŠeƒ^ƒOƒnƒ“ƒhƒ‰‚ª•Ô‚·•¨‚Æ‚¨‚È‚¶
    }

    //----------------------------------------------------------- stable/run --

    function notifyStable()
    {
    // ƒVƒXƒeƒ€‚ªˆÀ’è(ƒNƒŠƒbƒN‘Ò‚¿/’âŽ~)‚µ‚½‚Æ‚«‚ɁAƒnƒ“ƒhƒ‰‚ðŒÄ‚Ô
    if(!inStable)
    {
    inStable = true;
    var handlers = stableHandlers;
    for(var i = handlers.count-1; i>=0; i--)
    handlers[i]();

    // stableHook
    forEachEventHook('onStableStateChanged',
    function(handler, f) { handler(f.stable); } incontextof this,
    %[stable:true]);
    }
    }

    function notifyRun()
    {
    // ƒVƒXƒeƒ€‚ª‘–‚èŽn‚ß‚½‚Æ‚«‚ɁAƒnƒ“ƒhƒ‰‚ðŒÄ‚Ô
    if(inStable)
    {
    inStable = false;
    var handlers = runHandlers;
    for(var i = handlers.count-1; i>=0; i--)
    handlers[i]();

    // runHook
    forEachEventHook('onStableStateChanged',
    function(handler, f) { handler(f.stable); } incontextof this,
    %[stable:false]);

    if(autoMode) hideMouseCursor();
    }
    }

    function defaultStableHandler()
    {
    // ƒfƒtƒHƒ‹ƒg‚Ì stable ƒnƒ“ƒhƒ‰
    setMenuAccessibleAll();
    }

    function defaultRunHandler()
    {
    // ƒfƒtƒHƒ‹ƒg‚Ì run ƒnƒ“ƒhƒ‰
    hideHistory();
    hideClickGlyphs();
    showMessageLayerByUser();
    setMenuAccessibleAll();
    }

    //----------------------------------------------------------- •¶Žš—ñ“ü—Í --

    var inputTemp;
    function inputString(elm)
    {
    // •¶Žš—ñ‚ð“ü—Í‚·‚é
    var name = elm.name;
    var initial = Scripts.eval(name);
    var res = System.inputString(elm.title, elm.prompt, initial);
    if(res !== void)
    {
    // name ‚É res ‚ð‘ã“ü‚·‚é
    inputTemp = res;
    Scripts.eval(("(" + name + ") = kag.inputTemp"));
    }
    }

    //-------------------------------------------------- extraConductor ˆ— --

    function callExtraConductor(storage, label, onreturn)
    {
    // extraConductor ‚ðŽg‚Á‚ăTƒuƒ‹[ƒ`ƒ“‚ðŒÄ‚яo‚·
    onExtraConductorReturn = onreturn;
    inSleepBeforeExtraConductor = inSleep; // inSleep •Û‘¶
    storeMessageLayerSelProcessLock(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì storeSelProcessLock ‚ðŒÄ‚Ô
    conductor = extraConductor; // ƒRƒ“ƒ_ƒNƒ^‚ðØ‚è‘Ö‚¦‚é
    (Dictionary.assign incontextof extraConductor.macros)(mainConductor.macros);
    // ƒ}ƒNƒ‚̓Rƒs[
    usingExtraConductor = true;
    if(storage == '')
    {
    // ƒXƒgƒŒ[ƒWŽw’肪‚È‚¢‚Ì‚ÅŒ»Ý‚̃XƒgƒŒ[ƒW‚ð“ǂݍž‚Ü‚¹‚é
    storage = mainConductor.curStorage;
    }

    // ŒÄ‚яo‚·
    conductor.clearCallStack();
    processCall(storage, label);
    }

    function returnExtraConductor(run)
    {
    // extraConductor ‚̃Tƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚é
    // run ‚ª true ‚̏ꍇ‚Í ‘Ò‹@ó‘Ô‚Ì•œ‹A‚͍s‚í‚È‚¢

    conductor.sleep(); // ’âŽ~
    conductor.interrupt();
    // interrupt ‚Í ƒRƒ“ƒ_ƒNƒ^‚̃Cƒxƒ“ƒg“à‚ŃRƒ“ƒ_ƒNƒ^‚ÌŽÀs‚ð
    // ’âŽ~‚³‚¹‚邽‚߂̃ƒ\ƒbƒh
    conductor = mainConductor; // ƒRƒ“ƒ_ƒNƒ^‚ðØ‚è‘Ö‚¦
    (Dictionary.assign incontextof mainConductor.macros)(extraConductor.macros);
    // ƒ}ƒNƒ‚̓Rƒs[
    usingExtraConductor = false;
    if(!run)
    { restoreClickGlyphState(); // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚Ì•œ‹A
    inSleep = inSleepBeforeExtraConductor; // inSleep •œ‹A
    notifyStable();
    }
    restoreMessageLayerSelProcessLock(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì restoreSelProcessLock ‚ðŒÄ‚Ô
    setMenuAccessibleAll();
    cancelSkip();

    if(onExtraConductorReturn !== void) onExtraConductorReturn();
    }

    //------------------------------------------------------- ‰EƒNƒŠƒbƒNˆ— --

    function setRightClickOptions(elm)
    {
    // ‰EƒNƒŠƒbƒN‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    rightClickEnabled = +elm.enabled if elm.enabled !== void;
    if(elm.call !== void)
    {
    rightClickCall = +elm.call;
    if(rightClickCall) rightClickJump = false;
    }
    if(elm.jump !== void)
    {
    rightClickJump = +elm.jump;
    if(rightClickJump) rightClickCall = false;
    }
    rightClickTarget = elm.target if elm.target !== void;
    rightClickStorage = elm.storage if elm.storage !== void;
    if(elm.name !== void)
    {
    if(typeof this.rightClickMenuItem != "undefined")
    {
    rightClickName = elm.name;
    if(rightClickName == "default")
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    else
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickName;
    }
    }
    }

    function callRightClickSubRoutine()
    {
    isLeavePeriodEvent = true;

    // ‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚ðŒÄ‚Ô
    if(typeof this.rightClickMenuItem != "undefined")
    {
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    }

    callExtraConductor(rightClickStorage, rightClickTarget, restoreFromRightClick);

    lockMessageLayerSelProcess(); // ‘I‘ðŽˆƒƒbƒN
    }

    function restoreFromRightClick()
    {
    // ‰EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚*‚甲‚¯‚é‚Æ‚«‚ɌĂ΂ê‚é
    if(typeof this.rightClickMenuItem != "undefined")
    {
    if(rightClickName == "default")
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickDefaultName;
    else
    rightClickMenuItem.caption = rightClickCurrentMenuName = rightClickName;
    }
    }

    function setConductorToMain()
    {
    // restore ‚ÌŽž‚ɌĂ΂êAƒRƒ“ƒ_ƒNƒ^‚ð main ‚ɐ؂è‘Ö‚¦‚é
    if(usingExtraConductor)
    {
    extraConductor.sleep();
    extraConductor.interrupt();
    conductor= mainConductor;
    usingExtraConductor = false;
    }
    }

    function jumpToRightClickTarget()
    {
    process(rightClickStorage, rightClickTarget);
    }

    function onPrimaryRightClick()
    {
    // ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ʼnEƒNƒŠƒbƒN‚³‚ꂽ‚Æ‚«‚ɌĂ΂ê‚é
    if(!callHook(rightClickHook))
    {
    if(getKeyState(VK_LBUTTON))
    {
    enterAutoMode();
    return;
    }
    if(!rightClickEnabled) return;
    if(inStable)
    {
    if(rightClickJump)
    jumpToRightClickTarget();
    else if(rightClickCall && conductor == mainConductor)
    callRightClickSubRoutine();
    else
    switchMessageLayerHiddenByUser();
    }
    setMenuAccessibleAll();
    }
    }

    //------------------------------------------------------- ‘OŒiƒŒƒCƒ„ˆ— --

    function allocateCharacterLayers(num)
    {
    // ‘OŒiƒŒƒCƒ„”‚ð num ‚ɐݒ肷‚é
    if(fore.layers.count > num)
    {
    // ƒŒƒCƒ„‚ªŒ¸‚é
    for(var i = num; i<fore.layers.count; i++)
    {
    invalidate fore.layers[i];
    invalidate back.layers[i];
    }
    fore.layers.count = num;
    back.layers.count = num;
    }
    else if(fore.layers.count < num)
    {
    // ƒŒƒCƒ„‚ª‘‚¦‚é
    for(var i = fore.layers.count; i<num; i++)
    {
    fore.layers[i] = new CharacterLayer(this, fore.base, "•\‘OŒiƒŒƒCƒ„" + i, i);
    back.layers[i] = new CharacterLayer(this, back.base, "— ‘OŒiƒŒƒCƒ„" + i, i);
    fore.layers[i].setCompLayer(back.layers[i]);
    back.layers[i].setCompLayer(fore.layers[i]);
    }
    reorderLayers();
    }
    numCharacterLayers = num;
    }

    //------------------------------------------------- ƒƒbƒZ[ƒWƒŒƒCƒ„ˆ— --

    function allocateMessageLayers(num, setdefaultfont = true)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„”‚ð num ‚ɐݒ肷‚é
    if(fore.messages.count > num)
    {
    // ƒŒƒCƒ„‚ªŒ¸‚é
    for(var i = num; i<fore.messages.count; i++)
    {
    if(current == fore.messages[i] || current == back.messages[i])
    current = fore.messages[0], currentNum = 0, currentPage = 0;
    invalidate fore.messages[i];
    invalidate back.messages[i];
    }
    fore.messages.count = num;
    back.messages.count = num;
    }
    else if(fore.messages.count < num)
    {
    // ƒŒƒCƒ„‚ª‘‚¦‚é
    for(var i = fore.messages.count; i<num; i++)
    {
    fore.messages[i] = new MessageLayer(this, fore.base, "•\ƒƒbƒZ[ƒWƒŒƒCƒ„" + i, i, true);
    back.messages[i] = new MessageLayer(this, back.base, "— ƒƒbƒZ[ƒWƒŒƒCƒ„" + i, i, true);
    fore.messages[i].setCompLayer(back.messages[i]);
    back.messages[i].setCompLayer(fore.messages[i]);
    fore.messages[i].clear();
    back.messages[i].clear();
    }
    reorderLayers();
    if(setdefaultfont) setMessageLayerUserFont();
    }
    numMessageLayers = num;
    }

    function setCurrentMessageLayer(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ðÝ’è
    var page = getMessageLayerPageFromElm(elm);
    var num = getMessageLayerNumberFromElm(elm);
    currentNum = num;
    currentPage = page;
    if(page) current = back.messages[num]; else current = fore.messages[num];
    currentWithBack = +elm.withback if elm.withback !== void;
    }

    function setMessageLayerPosition(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̈ʒuA‘®«‚ðÝ’è
    var layer = getMessageLayerObjectFromElm(elm);
    elm.setPosition(elm);
    }

    function clearMessageLayers(resetcurrent)
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    // ct ƒ^ƒO‚*‚çŒÄ‚΂ê‚é
    // resetcurrent ‚ª true ‚̏ꍇ‚ÍŒ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ð
    // •\0‚ɐݒ肷‚é

    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].clear();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].clear();
    if(resetcurrent)
    {
    currentNum = 0;
    currentPage = 0;
    current = fore.messages[0];
    currentWithBack = false;
    }
    }

    function lockMessageLayerSelProcess()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚É ‘I‘ð‚Æprocess‚ð‹ÖŽ~‚³‚¹‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(true);
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(true);
    }

    function unlockMessageLayerSelProcess()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì‘I‘ð‚ð‹–‰Â‚·‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(false);
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].setSelProcessLock(false);
    }

    function setMessageLayerUserFont()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì defaultAntialiased ‚Æ
    // userFace ‚ðÝ’è‚·‚é
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--)
    messages[i].defaultAntialiased = chDefaultAntialiased,
    messages[i].userFace = chDefaultFace;
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--)
    messages[i].defaultAntialiased = chDefaultAntialiased,
    messages[i].userFace = chDefaultFace;
    }

    function storeMessageLayerSelProcessLock()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì storeSelProcessLock ‚ðŒÄ‚яo‚·
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].storeSelProcessLock();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].storeSelProcessLock();
    }

    function restoreMessageLayerSelProcessLock()
    {
    // ‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚Ì restoreSelProcessLock ‚ðŒÄ‚яo‚·
    var messages;
    messages = fore.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].restoreSelProcessLock();
    messages = back.messages;
    for(var i = messages.count-1; i >= 0; i--) messages[i].restoreSelProcessLock();
    }

    function setMessageLayerHiddenState(b)
    {
    var layers;
    layers = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].setHiddenStateByUser(b);
    layers = fore.layers;
    for(var i = layers.count-1; i >= 0; i--) layers[i].setHiddenStateByUser(b);

    // ƒvƒ‰ƒOƒCƒ“‚ðŒÄ‚Ô
    forEachEventHook('onMessageHiddenStateChanged',
    function(handler, f) { handler(f.hidden); } incontextof this,
    %[hidden:b]);
    }

    function hideMessageLayerByUser()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ðˆêŽž“I‚ɉB‚·
    if(messageLayerHiding) return;
    setMessageLayerHiddenState(true);
    if(typeof this.rightClickMenuItem !== "undefined")
    rightClickMenuItem.checked = true;
    messageLayerHiding = true;
    fore.base.cursor = cursorWaitingClick;
    setMenuAccessibleAll();
    }

    function showMessageLayerByUser()
    {
    // ˆêŽž“I‚ɉB‚³‚ê‚Ä‚¢‚½ƒƒbƒZ[ƒWƒŒƒCƒ„‚ðŒ³‚É–ß‚·
    if(!messageLayerHiding) return;
    setMessageLayerHiddenState(false);
    if(typeof this.rightClickMenuItem !== "undefined")
    rightClickMenuItem.checked = false;
    messageLayerHiding = false;
    conductor.trigger('message'); // 'message' ‚ð‘—‚é
    if(clickWaiting)
    fore.base.cursor = cursorWaitingClick;
    else
    fore.base.cursor = cursorDefault;
    setMenuAccessibleAll();
    }

    function switchMessageLayerHiddenByUser()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì”ñ•\Ž¦/•\Ž¦‚ðØ‚è‘Ö‚¦‚é
    if(messageLayerHiding) showMessageLayerByUser(); else hideMessageLayerByUser();
    }

    function hideMessageLayerByScenario(elm)
    {
    // ƒVƒiƒŠƒI‚*‚烁ƒbƒZ[ƒW‚ðˆêŽž“I‚ɉB‚·
    hideMessageLayerByUser();
    conductor.wait(%[ // ƒRƒ“ƒ_ƒNƒ^‚ð‘Ò‚¿‚É
    message : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    return -2; // break
    }

    function selectFont()
    {
    // ƒtƒHƒ“ƒg‚ð‘I‘ð‚·‚é
    fore.base.font.face = chDefaultFace;
    fore.base.font.height = -20;
    var flags = fsfSameCharSet | fsfNoVertical | fsfTrueTypeOnly | fsfUseFontFace;
    if(showFixedPitchOnlyInFontSelector) flags |= fsfFixedPitch;
    if(fore.base.font.doUserSelect(flags, "ƒtƒHƒ“ƒg‚Ì‘I‘ð",
    "ƒtƒHƒ“ƒg‚ð‘I‘ð‚µ‚Ä‚­‚¾‚³‚¢", "ABCDEFGHI‚ ‚¢‚¤‚¦‚¨ˆŸˆÝ‰FŠGŒä"))
    {
    chDefaultFace = fore.base.font.face;
    setMessageLayerUserFont();
    }
    }

    function mapPrerenderedFont(storage)
    {
    // ƒŒƒ“ƒ_ƒŠƒ“ƒOÏ‚݃tƒHƒ“ƒg‚ðŒ»Ý‚Ì‘€ì‘Ώۂ̃ŒƒCƒ„‚É‘I‘ð
    // ‚³‚ê‚Ä‚¢‚éƒtƒHƒ“ƒg‚Ƀ}ƒbƒsƒ“ƒO‚·‚é
    current.decideSizeChange();
    current.lineLayer.font.mapPrerenderedFont(storage);
    }

    //------------------------------------------------- ƒŒƒCƒ„‚𐳂µ‚¢‡˜‚É --

    function reorderLayers()
    {
    // ƒŒƒCƒ„‚𐳂µ‚¢‡˜‚É•À‚Ñ‘Ö‚¦‚é
    var index = 1000;
    for(var i = 0; i<fore.layers.count; i++)
    {
    fore.layers[i].absolute = index;
    back.layers[i].absolute = index;
    index += 1000;
    }
    index = 1000000;
    for(var i = 0; i<fore.messages.count; i++)
    {
    fore.messages[i].absolute = index;
    back.messages[i].absolute = index;
    index += 1000;
    }

    historyLayer.absolute = 2000000;

    }

    //--------------------------------------------- ‘®«->ƒŒƒCƒ„ƒIƒuƒWƒFƒNƒg --

    function getLayerFromElm(elm, prefix = '')
    {
    // elm ‚ÉŽw’肳‚ê‚Ä‚¢‚é page ‚Æ layer ‘®«‚*‚çAŠY“–‚·‚é
    // ƒIƒuƒWƒFƒNƒg‚ð•Ô‚·
    // prefix ‚ɂ́A‘®«–¼‚Ì‘O‚ɂ‚¯‚éƒvƒŒƒtƒBƒNƒX‚ðŽw’è‚·‚é
    var base;
    if(elm[prefix + 'page'] == 'back') base = back; else base = fore;
    var layer = elm[prefix + 'layer'];
    if(layer == 'base') return base.base; // ”wŒi
    if(layer[0] == 'm')
    {
    // message? ( ? = ”’l )
    // ‚±‚±‚Å‚Í‚ ‚܂茵–§‚ɃGƒ‰[ƒ`ƒFƒbƒN‚Í‚µ‚È‚¢
    if(layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }
    return base.layers[+layer];
    }

    function getLayerPageFromElm(elm, backlay)
    {
    // getLayerFromElm ‚ÆŽ—‚Ä‚¢‚邪Apage ‘®«‚Ü‚Å‚Í‚Ý‚È‚¢B
    // backlay ‚ª true ‚Ì‚Æ‚«‚Í— Afalse ‚ÌŽž‚Í•\‚̃ŒƒCƒ„‚ð•Ô‚·B
    // elm.layer ‚ª void ‚ÌŽž‚Í”wŒiƒŒƒCƒ„‚ð‹A‚·
    var base = backlay?back:fore;
    var layer = elm.layer;
    if(layer === void || layer == 'base') return base.base; // ”wŒi
    if(layer[0] == 'm')
    {
    if(layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }
    return base.layers[+layer];
    }

    function getMessageLayerPageFromElm(elm)
    {
    // elm ‚*‚çŠY“–‚·‚é•\/— ‰æ–ʂ̃ƒbƒZ[ƒWƒŒƒCƒ„”z—ñ‚ð•Ô‚·
    if(elm.page == 'back') return 1; else return 0;
    }

    function getMessageLayerNumberFromElm(elm)
    {
    // elm ‚Ì layer ‘®«‚ÌŽ¦‚·ƒƒbƒZ[ƒWƒŒƒCƒ„”ԍ†‚ð•Ô‚·
    var layer = elm.layer;
    if(layer === void || layer == 'message') return currentNum;
    return +layer.substr(7);
    }

    function getMessageLayerObjectFromElm(elm)
    {
    // elm ‚Ì layer ‘®«‚ÌŽ¦‚·ƒƒbƒZ[ƒWƒŒƒCƒ„‚ð•Ô‚·
    var page = elm.page;
    var layer = elm.layer;
    if(page === void && layer === void) return current;
    var base;
    if(page == 'back') base = back; else base = fore;
    if(layer === void || layer == 'message') return base.messages[currentNum];
    return base.messages[+layer.substr(7)];
    }

    function getMessageLayerObjectFromPageAndNumber(page, num)
    {
    return (page?back:fore).messages[num];
    }

    //----------------------------------------------------- ƒŒƒCƒ„ƒRƒs[ŠÖ˜A --

    function backupLayer(elm, toback)
    {
    // ƒŒƒCƒ„‚Ì•\*¨— ŠÔ‚̃Rƒs[‚ðs‚¤
    // toback = true ‚̏ꍇ‚Í•\¨— Afalse ‚̏ꍇ‚Í— ¨•\
    if(elm.layer !== void)
    {
    // ƒŒƒCƒ„Žw’肪‚ ‚é
    getLayerPageFromElm(elm, toback).assignComp(); // ‘΂̃ŒƒCƒ„‚Ì“à—e‚ðƒRƒs[
    }
    else
    {
    // ƒŒƒCƒ„Žw’肪–³‚¢‚Ì‚Å‘S•”‚̃ŒƒCƒ„‚ðƒRƒs[
    var base = toback ? back:fore;
    base.base.assignComp();
    var layers = base.layers, messages = base.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].assignComp();
    for(var i = messages.count-1; i >= 0; i--) messages[i].assignComp();

    forEachEventHook('onCopyLayer',
    function(handler, f) { handler(f.toback); } incontextof this,
    %[toback:toback]);
    }
    }

    function copyLayer(elm)
    {
    // elm ‚ɏ]‚Á‚Ä“¯Ží‚̃ŒƒCƒ„ŠÔ‚̃Rƒs[‚ðs‚¤
    var src = getLayerFromElm(elm, 'src');
    var dest = getLayerFromElm(elm, 'dest');
    dest.assign(src);
    }

    //--------------------------------------------------- ƒAƒjƒ[ƒVƒ‡ƒ“ŠÖ˜A --

    function onAnimationStopped(name, segment)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚ª’âŽ~‚µ‚½
    conductor.trigger('anim:' + name + ':' + segment);
    }

    function waitAnimation(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‚ð‚Ü‚Â
    var layer = getLayerFromElm(elm);
    var seg = +elm.seg;
    if(!layer.canWaitAnimStop(seg)) return 0; // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‚ð‘Ò‚Â
    conductor.wait(%[
    'anim:' + layer.name + ':' + seg => function
    {
    } incontextof this
    ]);
    return -2;
    }

    //--------------------------------------------------- ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ŠÖ˜A --

    function onLayerTransitionCompleted(layer, dest, src)
    {
    // ƒŒƒCƒ„‚Ńgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ªI—¹‚µ‚½‚Æ‚«‚ɌĂ΂ê‚é
    conductor.trigger('trans'); // 'trans' ‚ð‘—‚é
    }

    function waitTransition(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Â
    if(transCount == 0) return 0; // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Ä‚È‚¢
    if((elm.canskip === void || +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    stopAllTransitions();
    return 0; // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚³‚¹‚Ä‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    updateBeforeCh = 1;
    stopAllTransitions(); // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚Í’âŽ~
    } incontextof this,
    trans : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    trans : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    return -2;
    }

    function stopAllTransitions()
    {
    // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚³‚¹‚é
    var layers, messages;
    fore.base.stopTransition();
    layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopTransition();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopTransition();
    back.base.stopTransition();
    layers = back.layers, messages = back.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopTransition();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopTransition();
    transCount = 0; // ˆê‰ž
    }

    function callExchangeInfo()
    {
    // ‚·‚ׂĂ̔wŒiƒŒƒCƒ„‚ð‚Ì‚¼‚­•\ƒŒƒCƒ„‚ɑ΂µ‚Ä
    // exchangeInfo ‚ðŒÄ‚Ô
    var layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].exchangeInfo();
    for(var i = messages.count-1; i >= 0; i--) messages[i].exchangeInfo();
    }

    function callAssignTransSrc()
    {
    // ‚·‚ׂĂ̔wŒiƒŒƒCƒ„‚ð‚Ì‚¼‚­•\ƒŒƒCƒ„‚ɑ΂µ‚Ä
    // assignTransSrc ‚ðŒÄ‚Ô
    var layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].assignTransSrc();
    for(var i = messages.count-1; i >= 0; i--) messages[i].assignTransSrc();
    forEachEventHook('onCopyLayer',
    function(handler, f) { handler(f.toback); } incontextof this,
    %[toback:false]);
    }

    function exchangeForeBack()
    {
    // ƒŒƒCƒ„‚Ì— ‚Æ•\‚ðŽæ‚è‘Ö‚¦‚é
    var tmp = fore;
    fore = back;
    back = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    forEachEventHook('onExchangeForeBack',
    function(handler, f) { handler(); } incontextof this);
    }

    function swapBaseLayer()
    {
    // ”wŒiƒŒƒCƒ„‚Ì‚Ý‚ðŽæ‚è‘Ö‚¦‚é
    var tmp = fore.base;
    fore.base = back.base;
    back.base = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    }

    function swapCharacterLayer(id)
    {
    // ‘OŒiƒŒƒCƒ„‚Ì•\‚Æ— ‚ðŽæ‚è‘Ö‚¦‚é
    var fl = fore.layers, bl = back.layers;
    var tmp = fl[id];
    fl[id] = bl[id];
    bl[id] = tmp;
    }

    function swapMessageLayer(id)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚Ì•\‚Æ— ‚ðŽæ‚è‘Ö‚¦‚é
    var fl = fore.messages, bl = back.messages;
    var tmp = fl[id];
    fl[id] = bl[id];
    bl[id] = tmp;
    current = (currentPage?back:fore).messages[currentNum]; // current ‚͐ݒ肵’¼‚µ
    }

    //--------------------------------------------------------- Ž*“®ˆÚ“®ŠÖ˜A --

    function onLayerMoveStop()
    {
    // ƒŒƒCƒ„‚ÌŽ*“®ˆÚ“®‚ªI—¹‚µ‚½
    conductor.trigger('move');
    }

    function waitMove(elm)
    {
    // Ž*“®ˆÚ“®‚ð‘Ò‚Â
    if(moveCount == 0) return 0; // Ž*“®ˆÚ“®‚ð‘Ò‚Ä‚È‚¢
    if((elm.canskip === void || +elm.canskip) && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv“®ì’†
    stopAllMoves();
    return 0; // Ž*“®ˆÚ“®‚ð’âŽ~‚³‚¹‚Ä‚·‚®‚É•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    updateBeforeCh = 1;
    stopAllMoves(); // ‚·‚ׂẴgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚Í’âŽ~
    } incontextof this,
    move : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    else
    {
    conductor.wait(%[
    move : function
    {
    updateBeforeCh = 1;
    } incontextof this
    ]);
    }
    return -2;
    }

    function stopAllMoves()
    {
    // ‚·‚ׂĂ̎*“®ˆÚ“®‚ð’âŽ~‚³‚¹‚é
    var layers, messages;
    fore.base.stopMove();
    back.base.stopMove();
    layers = fore.layers, messages = fore.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopMove();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopMove();
    layers = back.layers, messages = back.messages;
    for(var i = layers.count-1; i >= 0; i--) layers[i].stopMove();
    for(var i = messages.count-1; i >= 0; i--) messages[i].stopMove();
    moveCount = 0; // ˆê‰ž
    }

    //------------------------------------------------ ƒfƒBƒŒƒC/ƒXƒLƒbƒvŠÖ˜A --

    function setDelay(elm)
    {
    // delay ƒ^ƒO‚̏ˆ—
    var speed = elm.speed;
    if(speed == 'nowait')
    {
    chSpeed = 0;
    chUserMode = false;
    }
    else if(speed == 'user')
    {
    chUserMode = true;
    setUserSpeed();
    }
    else
    {
    chSpeed = +speed;
    chUserMode = false;
    }
    if(!skipMode) actualChSpeed = chSpeed;
    }

    function getCurrentRead()
    {
    // Œ»Ý‚̃VƒiƒŠƒI•”•ª‚ªŠù“Ç‚*‚Ç‚¤‚*‚ð”»’è‚·‚é
    return autoRecordPageShowing && currentRecordName != "" &&
    +sflags[currentRecordName] || !autoRecordPageShowing;
    }

    function setUserSpeed()
    {
    // ƒ†[ƒU‚Ì‘I‘ð‚µ‚½•¶Žš•\Ž¦ƒXƒs[ƒh‚ðÝ’è
    // ‚±‚̊֐”‚ð“Ç‚ñ‚¾Žž“_‚Å‚·‚Å‚É userChSpeed ‚É‚Í
    // ‚ ‚½‚炵‚¢’l‚ªÝ’肳‚ê‚Ä‚¢‚é‚Æ‚Ý‚È‚·B
    // ‚ ‚é‚¢‚́Aƒ‰ƒxƒ‹‚²‚ƂɁA‚»‚Ì‹æˆæ‚ªŠù“Ç‚*–¢“Ç‚*‚Å
    // •\Ž¦ƒXƒs[ƒh‚ð•Ï‚¦‚é–Ú“I‚ŌĂ΂ê‚é
    if(chUserMode)
    {
    if(getCurrentRead())
    chSpeed = userCh2ndSpeed==-1?userChSpeed:userCh2ndSpeed; // Šù“Ç
    else
    chSpeed = userChSpeed; // Т҂
    }
    if(!skipMode) actualChSpeed = chSpeed;
    }

    function skipToClick()
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚܂ŃXƒLƒbƒv
    skipMode = 1;
    actualChSpeed = 0;
    }

    function skipToPage()
    {
    // ‰üƒy[ƒW‘Ò‚¿‹L†‚܂ŃXƒLƒbƒv
    skipMode = 2;
    actualChSpeed = 0;
    }

    function skipToStop()
    {
    // ŽŸ‚Ì’âŽ~‚܂ŃXƒLƒbƒv
    onPrimaryClick(); // ƒNƒŠƒbƒN‚Ì“®ì‚ðƒGƒ~ƒ…ƒŒ[ƒg‚·‚é
    skipMode = 3;
    actualChSpeed = 0;
    }

    function skipToStop2()
    {
    // ŽŸ‚Ì’âŽ~‚܂ŃXƒLƒbƒv(‘‘—‚胂[ƒh)
    onPrimaryClick();
    skipMode = 4;
    actualChSpeed = 0;
    }

    function cancelSkip()
    {
    // ƒXƒLƒbƒv“®ì‚ðƒLƒƒƒ“ƒZƒ‹
    skipMode = 0;
    skipKeyRepressed = false;
    actualChSpeed = chSpeed;
    }

    function enterNoWait()
    {
    // nowait ƒ^ƒO‚̏ˆ—
    beforeNoWaitActualChSpeed = actualChSpeed;
    beforeNoWaitChUserMode = chUserMode;
    actualChSpeed = 0;
    }

    function leaveNoWait()
    {
    // endnowait ƒ^ƒO‚̏ˆ—
    actualChSpeed = beforeNoWaitActualChSpeed;
    chUserMode = beforeNoWaitChUserMode;
    }

    function setAutoWait(elm)
    {
    // Ž*“®ƒEƒFƒCƒg‚ðÝ’è‚·‚é
    autoWCEnabled = +elm.enabled if elm.enabled !== void;
    autoWCChars = elm.ch if elm.ch !== void;
    autoWCWaits = [].split(",", elm.time) if elm.time !== void;
    }

    function cancelAutoMode()
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚̃Lƒƒƒ“ƒZƒ‹
    if(autoMode)
    {
    autoMode = false;
    if(typeof this.autoModeMenuItem !== "undefined")
    autoModeMenuItem.checked = false;
    var t = conductor.lastTagName;
    if(t == 'p'){
    showPageBreak();
    }
    else if(t == 'l'){
    showLineBreak(%[canskip: false]);
    }
    }
    }

    function enterAutoMode()
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݃‚[ƒh‚É“ü‚é
    if(typeof this.autoModeMenuItem !== "undefined")
    autoModeMenuItem.checked = true;
    if(inStable)
    onPrimaryClick();
    autoMode = true;
    }

    //--------------------------------------------------------- ƒEƒFƒCƒgŠÖ˜A --

    function resetWait()
    {
    // ŽžŠÔŒ´“_‚̃ŠƒZƒbƒg
    timeOrigin = System.getTickCount();
    }

    function waitTime(waittime, canskip)
    {
    // waittime •ª‘Ò‚Â
    if(waittime == 0) return 0;
    if(canskip)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚Í‚È‚É‚à‚¹‚¸‚É•Ô‚é
    }
    conductor.waitWithTimeOut(%[
    click : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    timeout : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ], waittime);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.waitWithTimeOut(%[
    timeout : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ], waittime);
    }
    return -2; // break

    }

    function doWait(elm)
    {
    // wait ƒ^ƒO‚̏ˆ—
    var waittime;
    if(elm.mode == 'until')
    {
    // until ƒ‚[ƒh
    waittime = timeOrigin + +elm.time - System.getTickCount();
    if(waittime < 0) { lastWaitTime = 0; return 0; } // ‚·‚Å‚ÉŽžŠÔ‚ªŒo‰ß‚µ‚Ä‚¢‚é
    lastWaitTime = waittime;
    if(waittime < 6) return 0; // ‚ ‚Ü‚è‚É‘Ò‚¿ŽžŠÔ‚ª’Z‚¢‚Ì‚Å‘Ò‚½‚È‚¢
    }
    else
    {
    waittime = +elm.time;
    }
    return waitTime(waittime, (elm.canskip === void || +elm.canskip) && clickSkipEnabled);
    }

    function doWaitCh(elm)
    {
    // +elm.time ‚̃JƒEƒ“ƒg•ªA‘Ò‚Â
    var t = elm.time;
    return waitTime(actualChSpeed * (t === void ? 1 : +t),
    (elm.canskip === void || +elm.canskip) && clickSkipEnabled);
    }

    //------------------------------------------------------------ quakeŠÖ˜A --

    function doQuake(elm)
    {
    // elm ‚ɏ]‚Á‚Ä quake ‚ðŠJŽn
    if(elm.time !== void)
    {
    if(defaultQuakeTimeInChUnit)
    {
    if(elm.timemode == 'ms')
    quakeEndTick = System.getTickCount() + +elm.time;
    else
    quakeEndTick = System.getTickCount() + +elm.time * chSpeed;
    }
    else
    {
    if(elm.timemode == 'delay')
    quakeEndTick = System.getTickCount() + +elm.time * chSpeed;
    else
    quakeEndTick = System.getTickCount() + +elm.time;
    }
    }
    else
    {
    quakeEndTick = -1;
    }

    if(elm.hmax !== void) quakeHorzMax = +elm.hmax; else quakeHorzMax = 10;
    if(elm.vmax !== void) quakeVertMax = +elm.vmax; else quakeVertMax = 10;

    quakeTimer.enabled = true;
    quaking = true;
    }

    function restoreQuake()
    {
    // restore ‚*‚çŒÄ‚΂êAžx‚ð•Û‘¶‚µ‚½‚Æ‚«‚É—h‚ê‚Ä‚¢‚½ê‡‚Í—h‚ç‚·
    if(quaking && quakeEndTick == -1)
    quakeTimer.enabled =true;
    }

    function stopQuake()
    {
    // —h‚ê‚ð’âŽ~
    setLayerPos(0, 0);
    quakeTimer.enabled = false;
    quaking = false;
    conductor.trigger('quake');
    }

    function onQuakeTimerInterval()
    {
    // quakeTimer ‚É‚æ‚èŒÄ‚΂ê‚é
    if(quakeEndTick != -1 && System.getTickCount() > quakeEndTick) { stopQuake(); return; }
    if(historyShowing)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„•\Ž¦’†‚Í‚³‚·‚ª‚É—h‚ê‚Ä‚¢‚ç‚ê‚È‚¢
    setLayerPos(0, 0);
    return;
    }
    var x, y;
    if(quakeHorzMax == quakeVertMax)
    {
    // ‚¾‚¢‚½‚¢“¯‚¶
    x = int(Math.random() * quakeHorzMax - quakeHorzMax);
    y = int(Math.random() * quakeVertMax - quakeVertMax);
    }
    else if(quakeHorzMax < quakeVertMax)
    {
    // c—h‚ê
    x = int(Math.random() * quakeHorzMax - quakeHorzMax);
    y = int((quakePhase ? Math.random() : -Math.random()) * quakeVertMax);
    }
    else
    {
    // ‰¡—h‚ê
    x = int((quakePhase ? Math.random() : -Math.random()) * quakeHorzMax);
    y = int(Math.random() * quakeVertMax - quakeVertMax);
    }
    quakePhase = !quakePhase;
    setLayerPos(x, y);
    }

    function waitQuake(elm)
    {
    // —h‚ꂪI—¹‚·‚é‚Ü‚Å‚Ü‚Â
    if(!quaking || quakeEndTick == -1) return 0; // —h‚ê‚Ä‚¢‚È‚¯‚ê‚Α҂½‚È‚¢
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    stopQuake();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚Í—h‚ê‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    stopQuake(); // —h‚ê‚Í’âŽ~‚·‚é
    } incontextof this,

    quake : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    quake : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    //------------------------------------------------------------- ƒNƒŠƒbƒN --

    function onPrimaryClick()
    {
    // ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ŁuƒNƒŠƒbƒN‚Ì“®ìv‚ª‚È‚É‚àƒtƒBƒ‹ƒ^ƒŠƒ“ƒO‚³‚ê‚È‚*‚Á‚½
    // ‚Æ‚«Aƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚*‚çŒÄ‚΂ê‚éB
    clickCount ++;
    if(!callHook(leftClickHook))
    {
    if(messageLayerHiding)
    {
    showMessageLayerByUser(); // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ð•\Ž¦‚·‚é
    }
    else
    {
    var st = conductor.status;
    var runst = conductor.mRun;
    var stopst = conductor.mStop;

    if(st != stopst && autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    cancelAutoMode();
    }
    else if(st != stopst && canCancelSkipByClick && skipMode && skipMode != 4)
    {
    // ƒNƒŠƒbƒN‚É‚æ‚éƒXƒLƒbƒv‚Ì‰ðœ‚ª‰Â”\
    cancelSkip();
    }
    else
    {
    // ‚±‚ÌŽž“_‚ŃtƒBƒ‹ƒ^ƒŠƒ“ƒO‚³‚ê‚È‚¢ƒƒbƒZ[ƒW‚Í‘Ò‚¿ó‘Ԃ̃NƒŠƒA‚È‚Ì‚Å
    // conductor ‚É 'click' ‚ð‘—‚è‰ðœ‚ð“`‚¦‚éB

    if(!conductor.trigger('click')) // ‘Ò‚¿ó‘Ô‚Å‚È‚¢ê‡‚Í’P‚É–³Ž‹‚³‚ê‚é
    {
    // ƒnƒ“ƒhƒ‰‚ªŒ*‚‚*‚ç‚È‚¢‚ȂǁAˆ—‚³‚ê‚È‚*‚Á‚½ê‡
    if(st == runst && clickSkipEnabled && skipMode == 0)
    {
    // ƒNƒŠƒbƒN‚É‚æ‚éƒXƒLƒbƒv‚ª‰Â”\
    skipToClick();
    }
    }
    }
    }
    }
    }

    function onPrimaryClickByKey()
    {
    // ƒL[‚ª‰Ÿ‚³‚ꂽ‚Æ‚«ƒvƒ‰ƒCƒ}ƒŠƒŒƒCƒ„‚ðƒNƒŠƒbƒN‚µ‚½‚Ì‚Æ
    // “¯‚¶“®ì‚ð‚·‚é‚ªA‚³‚ç‚Ɉꎞ“I‚Ƀ}ƒEƒXƒJ[ƒ\ƒ‹‚ð‰B‚·
    onPrimaryClick();
    hideMouseCursor();
    }

    function waitClick(elm)
    {
    // ƒNƒŠƒbƒN‚ð‘Ò‚Â
    conductor.wait(%[
    click : function
    {
    } incontextof this]);
    return -2;
    }

    function onMouseDown(x, y)
    {
    lastMouseDownX = x;
    lastMouseDownY = y;
    super.onMouseDown(...);
    }

    //------------------------------------------------------- ƒL[ƒ{[ƒh‘€ì --

    function processKeys(key, shift)
    {
    if(checkProceedingKey(key, shift)) return;

    if(key == #'F')
    {
    // ŽŸ‚Ì‘I‘ðŽˆ/–¢“ǂ܂Ői‚Þ
    skipToNextStopByKey();
    return;
    }

    if(key == #'B')
    {
    // ‘O‚É–ß‚é
    goBackByKey();
    return;
    }

    if(key == #'A')
    {
    // Ž*“®“I‚ɓǂݐi‚ß‚é
    switchAutoModeByKey();
    return;
    }

    if(freeSaveDataMode)
    {
    if(key == #'S')
    {
    // žx‚ð‚Í‚³‚Þ
    if(typeof this.storeMenu != "undefined" && storeMenu.enabled)
    storeMenu.click();
    return;
    }

    if(key == #'L')
    {
    // žx‚ð‚½‚Ç‚é
    if(typeof this.restoreMenu != "undefined" && restoreMenu.enabled)
    restoreMenu.click();
    return;
    }
    }

    if(key == #'R' || (key == VK_UP && (shift & ssShift)))
    {
    // ƒƒbƒZ[ƒW—š—ð‚ð•\Ž¦
    showHistoryByKey();
    return;
    }

    if(key == VK_ESCAPE)
    {
    // ƒƒbƒZ[ƒW‚ðÁ‚·
    if(typeof this.rightClickMenuItem != "undefined" &&
    rightClickMenuItem.enabled)
    {
    rightClickMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    return;
    }
    }
    }

    function preProcessKeys(key, shift)
    {
    return callHook(keyDownHook, key, shift);
    }

    function internalOnKeyDown(key, shift)
    {
    if(!preProcessKeys(key, shift)) processKeys(key, shift);
    }

    function checkProceedingKey(key, shift)
    {
    // key ‚ª“Ç‚Ý‚·‚·‚݂̃L[ ( ƒXƒy[ƒXƒL[‚*ReturnƒL[ ) ‚̏ꍇ‚Í
    // ƒL[‚ðˆ—‚µAtrue ‚ð•Ô‚·B‚»‚¤‚Å‚È‚¯‚ê‚Î false ‚ð•Ô‚·
    if(key == VK_RETURN || key == VK_SPACE)
    {
    // ƒL[‚ªƒƒbƒZ[ƒWƒLƒ…[‚É—­‚Ü‚Á‚Ä‚éê‡‚ª‚ ‚é‚Ì‚Å
    // ŽÀÛ‚É‚»‚̃L[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚Ì‚*‚Ç‚¤‚*‚ð
    // getKeyState ‚ð—p‚¢‚Ä’²‚ׂé
    var sg = getKeyState;
    if(sg(VK_RETURN) || sg(VK_SPACE))
    {
    // ƒL[‚ª‰Ÿ‚³‚ê‚Ä‚½
    if((shift & ssRepeat) && clickSkipEnabled &&
    conductor.status == conductor.mRun)
    {
    // ƒL[ƒŠƒs[ƒg
    if(skipMode != 4 && skipKeyRepressed)
    skipToStop2(); // ‚Ü‚¾skipMode 4‚É“ü‚Á‚Ä‚¢‚È‚¢ê‡‚Í‘‘—‚胂[ƒh‚É“ü‚é
    // skipKeyRepressed ‚ðƒ`ƒFƒbƒN‚·‚é‚Ì‚Í
    // ˜A‘±‚µ‚ăL[ƒŠƒs[ƒg‚ª”­¶‚µ‚Ä‚¢‚é‚Æ‚«‚É
    // cancelSkip Œã‚ɃXƒLƒbƒv‚É“Ë“ü‚·‚é‚Ì‚ð–h‚®‚½‚ß
    }
    else
    {
    skipKeyRepressed = true;
    onPrimaryClickByKey();
    }
    return true;
    }
    }

    return false;
    }

    function skipCancelKeyPressing()
    {
    // ƒXƒLƒbƒv‚ð‰ðœ‚·‚é—vˆö‚Æ‚È‚éƒL[‚ ‚é‚¢‚̓}ƒEƒXƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚*
    var sg = getKeyState;
    return sg(VK_RETURN) || sg(VK_SPACE) || sg(VK_LBUTTON);
    }

    function skipKeyPressing()
    {
    // VK_RETURN ‚ ‚é‚¢‚Í VK_SPACE ‚ª‰Ÿ‚³‚ê‚Ä‚¢‚é‚*‚Ç‚¤‚*
    var sg = getKeyState;
    return sg(VK_RETURN) || sg(VK_SPACE);
    }

    function goBackByKey()
    {
    if(typeof this.goBackMenuItem != "undefined" &&
    goBackMenuItem.enabled)
    goBackMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function skipToNextStopByKey()
    {
    if(typeof this.skipToNextStopMenuItem != "undefined" &&
    skipToNextStopMenuItem.enabled)
    skipToNextStopMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function showHistoryByKey()
    {
    if(typeof this.showHistoryMenuItem != "undefined" &&
    showHistoryMenuItem.enabled)
    showHistoryMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function switchAutoModeByKey()
    {
    if(typeof this.autoModeMenuItem != "undefined" &&
    autoModeMenuItem.enabled)
    autoModeMenuItem.click(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    }

    function onKeyDown(key, shift)
    {
    if(focusedLayer === null)
    internalOnKeyDown(key, shift);
    super.onKeyDown(...);
    }

    function onMouseWheel(shift, delta, x, y)
    {
    // ƒzƒC[ƒ‹‚ª‰ñ“]‚µ‚½
    super.onMouseWheel(...);
    if(!historyLayer.visible)
    {
    if(delta > 0)
    showHistoryByKey(); // ƒƒbƒZ[ƒW—š—ð‚ð•\Ž¦
    else if(System.getTickCount() - lastHistoryHiddenTick > 150)
    onPrimaryClick(); // ƒNƒŠƒbƒN‚ðƒGƒ~ƒ…ƒŒ[ƒg
    // ª tick ‚ð”äŠr‚µ‚Ä‚¢‚é‚̂́AƒƒbƒZ[ƒW—š—ð‚ð‰B‚·‘€ì‚ƃzƒC[ƒ‹‚ð
    // Žè‘O‚ɉñ‚·‘€ì‚ª˜A‘±‚µ‚½ê‡‚ɏŸŽè‚ɓǂݐi‚Þ‚Ì‚ð‚ ‚é’ö“x–h‚®ŽdŠ|‚¯
    }
    else
    {
    // ƒƒbƒZ[ƒW—š—ð‚ɃCƒxƒ“ƒg‚𐂂ꗬ‚·
    historyLayer.windowMouseWheel(shift, delta, x, y);
    }
    }

    //------------------------------------------------- ƒNƒŠƒbƒN‘Ò‚¿‹L†ˆ— --

    function hideClickGlyphs()
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ð”ñ•\Ž¦‚É
    lineBreak.visible = false;
    pageBreak.visible = false;
    if(conductor == mainConductor)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏ó‘Ô‚ð‹L˜^
    lastClickGlyphVisible = false;
    }
    }

    function storeClickGlyphState(which)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏î•ñ‚ðˆêŽž“I‚É‘Ò”ð
    // ‚±‚̃f[ƒ^‚͉EƒNƒŠƒbƒNƒTƒuƒ‹[ƒ`ƒ“‚âextraConductorƒTƒuƒ‹[ƒ`ƒ“‚*‚ç–ß‚é‚Æ‚«‚ÉŽQÆ‚·‚é
    if(conductor == mainConductor)
    {
    lastClickGlyphVisible = true;
    lastClickGlyphMessagePage = currentPage;
    lastClickGlyphMessageNum = currentNum;
    lastClickGlyphWhich = which;
    }
    }

    function restoreClickGlyphState()
    {
    // lastClickGlyph *** ‚Ɉꎞ“I‚É‘Ò”ð‚µ‚½ƒNƒŠƒbƒN‘Ò‚¿‹L†‚̏î•ñ
    // ‚ÉŠî‚¢‚ăNƒŠƒbƒN‘Ò‚¿‹L†‚ðÝ’è‚·‚é
    if(lastClickGlyphVisible)
    {
    var layer = getMessageLayerObjectFromPageAndNumber
    (lastClickGlyphMessagePage, lastClickGlyphMessageNum);
    if(layer !== void)
    {
    switch(lastClickGlyphWhich)
    {
    case 'line':
    layer.showLineBreakGlyph(lineBreak);
    break;
    case 'page':
    layer.showPageBreakGlyph(pageBreak);
    break;
    }
    }
    }
    }

    function canIgnoreL()
    {
    // L ƒ^ƒO‚𖳎‹‚Å‚«‚é‚*‚Ç‚¤‚*
    return chNonStopToPageBreak || (getCurrentRead() && ch2ndNonStopToPageBreak);
    }

    function showLineBreak(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚ɍs‘Ò‚¿‹L†‚ð•\Ž¦‚·‚é
    stablePosibility = true;
    if(canIgnoreL())
    {
    // l ƒ^ƒO‚Ì–³Ž‹
    if(elm.canskip === void || !+elm.canskip)
    return (skipMode==3 || skipMode==4) ? 0 : -4;
    }
    if(autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    return autoModeLineWait;
    }
    if(skipMode == 1) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    if(skipMode == 4) return -4;
    if(skipMode) return skipCancelKeyPressing()?-4:0;
    // ƒXƒLƒbƒv’†(ƒXƒLƒbƒv‚ðƒLƒƒƒ“ƒZƒ‹‚·‚é‚悤‚ȃL[‚ª‚ ‚ê‚΃XƒLƒbƒv‰ðœ
    // ‚Ì‚½‚߂̃Cƒxƒ“ƒgˆ—‚Ì‹@‰ï‚ð—^‚¦‚é)

    current.showLineBreakGlyph(lineBreak);
    storeClickGlyphState("line");

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚ōsƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -2;
    }

    function showPageBreak(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚Ƀy[ƒW‘Ò‚¿‹L†‚ð•\Ž¦‚·‚é
    stablePosibility = true;
    if(skipMode == 1 || skipMode == 2) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    if(skipMode) return -4; // ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—
    if(autoMode)
    {
    // Ž*“®“Ç‚Ý‚·‚·‚݂̏ꍇ
    return autoModePageWait;
    }

    current.showPageBreakGlyph(pageBreak);
    storeClickGlyphState("page");

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚Ńy[ƒWƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -2;
    }

    function showPageBreakAndClear()
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚ªÅIs‚Ü‚Å’B‚µ‚ÄŽ*“®‰üƒy[ƒW‚ª‚³‚ê‚é‚Æ‚«‚É
    // ŒÄ‚΂ê‚éBŒ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚Ƀy[ƒW‘Ò‚¿‹L†‚ð•\Ž¦‚µA
    // ŽÀsÄŠJŽž‚É‚Í MessageLayer.clear2 ‚ðŒÄ‚Ô
    stablePosibility = true;
    if(skipMode == 1 || skipMode == 2) cancelSkip();
    if(skipMode == 4 && !skipKeyPressing()) cancelSkip();
    var lasttagname = conductor.lastTagName;
    if(!autoMode && ((!canIgnoreL() && lasttagname == 'l') || lasttagname == 'p'))
    { current.clear2(); return -5; }// ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—(ƒ^ƒO‚ÍŒã‰ñ‚µ)
    if(skipMode) { current.clear2(); return -5; }// ‚¢‚Á‚½‚ñƒCƒxƒ“ƒg‚ðˆ—(ƒ^ƒO‚ÍŒã‰ñ‚µ)

    if(!current.nodeVisible)
    {
    dm("Œx : ”ñ•\Ž¦‚É‚È‚Á‚Ä‚¢‚é" +
    (currentPage ? "— " : "•\") + "ƒƒbƒZ[ƒWƒŒƒCƒ„" + currentNum +
    "‚ÅŽ*“®‰üƒy[ƒWƒNƒŠƒbƒN‘Ò‚¿‚É‚È‚è‚Ü‚µ‚½");
    }

    if(autoMode)
    {
    conductor.waitWithTimeOut(%[ // ƒ^ƒCƒ€ƒAƒEƒg•t‚«ƒEƒFƒCƒg
    click : function
    {
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    cancelAutoMode();
    } incontextof this,
    timeout : function
    {
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    } incontextof this
    ], autoModePageWait <= 0 ? 1 : autoModePageWait);
    return -3;
    }
    else
    {
    current.showPageBreakGlyph(pageBreak);
    storeClickGlyphState("page");

    // conductor ‚ð 'click' ‚Ü‚Å‘Ò‚¿ó‘Ô‚É
    conductor.wait(%[
    click : function
    {
    clickWaiting = false;
    fore.base.cursor = cursorDefault;
    current.clear2(); // clear2 ‚ðŒÄ‚Ô
    notifyRun();
    } incontextof this
    ]);
    clickWaiting = true;
    fore.base.cursor = cursorWaitingClick;
    notifyStable();
    return -3;
    }
    }

    //------------------------------------------------------------- BGM ˆ— --

    function onBGMFadeCompleted()
    {
    // BGM ‚̃tƒF[ƒh‚ªŠ®—¹‚µ‚½
    conductor.trigger('bgmfade');
    }

    function onBGMStop()
    {
    // BGM ‚ª’âŽ~‚µ‚½
    conductor.trigger('bgmstop');
    }

    function waitBGMFade(elm)
    {
    // BGM ‚̃tƒF[ƒhI—¹‚ð‘Ò‚Â
    if(!bgm.inFading) return 0; // ƒtƒF[ƒh’†‚Å‚È‚¯‚ê‚Α҂½‚È‚¢
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    bgm.stopFade();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚̓tƒF[ƒh‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    bgm.stopFade(); // ƒtƒF[ƒfƒBƒ“ƒO‚Í’âŽ~‚·‚é
    } incontextof this,

    bgmfade : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    bgmfade : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    function waitBGMStop(elm)
    {
    // BGM ‚̍жI—¹‚ð‘Ò‚Â
    if(!bgm.canWaitStop) return 0; // BGM Ä¶I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    bgm.stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function
    {
    bgm.stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    bgmstop : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    bgmstop : function
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this
    ]);
    }
    return -2;
    }

    //----------------------------------------------------------- Œø‰Ê‰¹ˆ— --

    function onSESoundBufferFadeCompleted(id)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh‚ªI—¹‚µ‚½
    conductor.trigger('sefade' + id);
    }

    function onSESoundBufferStop(id)
    {
    // Œø‰Ê‰¹‚̍ж‚ªI—¹‚µ‚½
    conductor.trigger('sestop' + id);
    }

    function waitSEFade(elm)
    {
    var id = +elm.buf;
    var buf = se[id];
    if(!buf.inFading) return 0; // ƒtƒF[ƒh’†‚Å‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    buf.stopFade();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚̓tƒF[ƒh‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    se[id].stopFade(); // ƒtƒF[ƒh‚ðI—¹‚·‚é
    } incontextof this,

    click_arg : id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'sefade'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sefade'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'sefade'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sefade'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    function waitSEStop(elm)
    {
    var id = +elm.buf;
    var buf = se[id];
    if(!buf.canWaitStop()) return 0; // I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü•Ô‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    buf.stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    se[id].stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    'click_arg' => id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'sestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'sestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'sestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    //--------------------------------------------------------- ƒ€[ƒr[ŠÖ˜A --

    function onMovieStop(id)
    {
    // ƒ€[ƒr[‚̍ж‚ªI—¹‚µ‚½
    conductor.trigger('moviestop'+id);
    }

    function waitMovieStop(elm)
    {
    var id = +elm.slot;

    // ƒ€[ƒr[‚̍жI—¹‚ð‘Ò‚Â
    if(!movies[id].canWaitStop) return 0; // ƒ€[ƒr[Ä¶I—¹‚ð‘Ò‚Ä‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if(elm.canskip !== void && +elm.canskip && clickSkipEnabled)
    {
    // ƒXƒLƒbƒv‚Å‚«‚éê‡
    if(skipMode)
    {
    // ƒXƒLƒbƒv’†‚̏ꍇ
    movies[id].stop();
    return 0; // ƒXƒLƒbƒv’†‚̏ꍇ‚͍ж‚ð’âŽ~‚³‚¹‚Ä•Ô‚é
    }
    conductor.wait(%[
    click : function (id)
    {
    movies[id].stop(); // Ä¶‚ðI—¹‚·‚é
    } incontextof this,

    'click_arg' => id, // ƒnƒ“ƒhƒ‰‚ւ̈ø”

    'moviestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'moviestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    // ƒXƒLƒbƒv‚Å‚«‚È‚¢ê‡
    conductor.wait(%[
    'moviestop'+id =>
    function (id)
    {
    // ‚â‚邱‚Æ‚È‚µ
    } incontextof this,

    'moviestop'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    return -2;
    }

    function onMoviePeriod(id,type)
    {
    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ª”­¶‚µ‚½
    if( isLeavePeriodEvent != false )
    {
    holdPeriodEventQueue.add( 'movieperiod'+id+'_'+type );
    }
    else
    {
    conductor.trigger('movieperiod'+id+'_'+type);
    }
    }

    function waitMoviePeriod(elm)
    {
    isWaitPeriodEvent = true;
    waitedPeriodEventStorageName = conductor.curStorage;

    var id = +elm.slot;

    stablePosibility = true;

    if( holdPeriodEventQueue.count > 0 )
    {
    var triggered = false;
    for( var i = 0; i < holdPeriodEventQueue.count; i++ )
    {
    if( elm.for !== void )
    {
    if( elm.for == 'loop' )
    {
    if( ('movieperiod'+id+'_'+perLoop) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'period' )
    {
    if( ('movieperiod'+id+'_'+perPeriod) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'prepare' )
    {
    if( ('movieperiod'+id+'_'+perPrepare) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else if( elm.for == 'segLoop' )
    {
    if( ('movieperiod'+id+'_'+perSegLoop) == holdPeriodEventQueue[i] )
    triggered = true;
    }
    else
    {
    triggered == true;
    }
    }
    else
    {
    triggered == true;
    }
    }
    holdPeriodEventQueue.clear();
    if( triggered == true )
    {
    isWaitPeriodEvent = false;
    return 0;
    }
    }

    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð‘Ò‚Â
    if(!movies[id].canWaitStop) return 0; // ƒ€[ƒr[‚ªÄ¶’†‚Å‚È‚¯‚ê‚΂»‚Ì‚Ü‚Ü–ß‚é
    if( elm.for !== void )
    {
    if( elm.for == 'loop' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'period' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perPeriod => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'prepare' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perPrepare => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else if( elm.for == 'segLoop' )
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perSegLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    else
    {
    return 0; // ˆø”‚ª•Ï
    }
    }
    else
    {
    conductor.wait(%[
    'movieperiod'+id+'_'+perLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perPeriod => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perPrepare => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_'+perSegLoop => function (id) { notifyRun(); isWaitPeriodEvent = false;} incontextof this,
    'movieperiod'+id+'_arg' => id // ƒnƒ“ƒhƒ‰‚ւ̈ø”
    ]);
    }
    notifyStable();
    return -2;
    }

    //------------------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ --

    function getHandlers()
    {
    return %[ // Ž«‘”z—ñƒIƒuƒWƒFƒNƒg

    /*
    ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ‚́A–¼‘O‚Æ‚»‚ê‚ɑΉž‚·‚éŠÖ”‚̃yƒA‚ð—ñ‹“‚·‚é‚à‚̂ŁA
    ŠÖ”–¼ : function(elm)
    {
    // ŠÖ”‚Ì’†g
    } incontextof this,
    ‚̏‘Ž®‚ð—p‚¢‚éB‚½‚¾‚µAŠÖ”–¼‚ª—\–ñŒê‚̏ꍇ‚́AuŠÖ”–¼ : v‚Å‚Í‚È‚­
    u"ŠÖ”–¼" => v‚ð—p‚¢‚éB
    incontextof this ‚́AŠÖ”‚ª³‚µ‚­ ‚±‚̃Nƒ‰ƒX‚Ì
    ƒIƒuƒWƒFƒNƒg‚̃Rƒ“ƒeƒLƒXƒgã‚Å“®‚­‚悤‚É‚·‚邽‚ß‚É•K—vB
    */

    //--------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒƒbƒZ[ƒW‘€ì) --

    ch : function(elm)
    {
    // •¶Žš•\Ž¦
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    var text = elm.text;
    if(currentWithBack) current.comp.processCh(text);
    if(current.processCh(text))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled) historyLayer.store(text);
    if(autoWCEnabled)
    {
    // Ž*“®ƒEƒFƒCƒg
    var ind;
    if((ind = autoWCChars.indexOf(text)) != -1)
    {
    return int(acs * autoWCWaits[ind]);
    }
    }
    return acs;
    } incontextof this,

    graph : function(elm)
    {
    // ƒOƒ‰ƒtƒBƒbƒN‚𕶎š‚Æ‚µ‚Ä•\Ž¦
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    if(currentWithBack) current.comp.processGraph(elm);
    if(current.processGraph(elm))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled && elm.alt !== void) historyLayer.store(elm.alt);
    return acs;
    } incontextof this,

    hch : function(elm)
    {
    // c’†‰¡
    var acs = actualChSpeed;
    if(updateBeforeCh)
    {
    if(acs) { updateBeforeCh--; return -5; } else { updateBeforeCh--; }
    }
    var text = elm.text;
    var expand = elm.expand !== void && +elm.expand;
    if(currentWithBack) current.comp.putHorizonCh(text, expand);
    if(current.putHorizonCh(text, expand))
    {
    return showPageBreakAndClear();
    }
    if(historyWriteEnabled) historyLayer.store(text);
    return acs;
    } incontextof this,

    r : function(elm)
    {
    // ‰üs
    if(historyWriteEnabled) historyLayer.reline();
    if(currentWithBack) current.comp.processReturn();
    if(current.processReturn())
    {
    var ret = showPageBreakAndClear();
    // ‰üs‚Ípending‚µ‚È‚¢
    if(ret == -5)
    ret = -4;
    else if(ret == -3)
    ret = -2;
    return ret;
    }
    return actualChSpeed;
    } incontextof this,

    ruby : function(elm)
    {
    // ŽŸ‚Ì•¶Žš‚ɑ΂·‚郋ƒrÝ’è
    if(currentWithBack) current.comp.setRuby(elm.text);
    current.setRuby(elm.text);
    return 0;
    } incontextof this,

    font : function(elm)
    {
    // ƒtƒHƒ“ƒgÝ’è
    if(currentWithBack) current.comp.setFont(elm);
    current.setFont(elm);
    return 0;
    } incontextof this,

    deffont : function(elm)
    {
    // ƒfƒtƒHƒ‹ƒg‚̃tƒHƒ“ƒgÝ’è
    if(currentWithBack) current.comp.setDefaultFont(elm);
    current.setDefaultFont(elm);
    return 0;
    } incontextof this,

    resetfont : function(elm)
    {
    // ƒtƒHƒ“ƒg‚̃ŠƒZƒbƒg
    if(currentWithBack) current.comp.resetFont();
    current.resetFont();
    return 0;
    } incontextof this,

    style : function(elm)
    {
    // ƒXƒ^ƒCƒ‹Ý’è
    if(currentWithBack) current.comp.setStyle(elm);
    current.setStyle(elm);
    return 0;
    } incontextof this,

    defstyle : function(elm)
    {
    // ƒfƒtƒHƒ‹ƒg‚̃Xƒ^ƒCƒ‹Ý’è
    if(currentWithBack) current.comp.setDefaultStyle(elm);
    current.setDefaultStyle(elm);
    return 0;
    } incontextof this,

    resetstyle : function(elm)
    {
    // ƒXƒ^ƒCƒ‹‚̃ŠƒZƒbƒg
    if(currentWithBack) current.comp.resetStyle();
    current.resetStyle();
    return 0;
    } incontextof this,

    link : function(elm)
    {
    // ƒnƒCƒp[ƒŠƒ“ƒN‚ÌŠJŽn
    if(currentWithBack) current.comp.beginHyperLink(elm);
    current.beginHyperLink(elm);
    return 0;
    } incontextof this,

    endlink : function(elm)
    {
    // ƒnƒCƒp[ƒŠƒ“ƒN‚̏I—¹
    if(currentWithBack) current.comp.endHyperLink(elm);
    current.endHyperLink(elm);
    return 0;
    } incontextof this,

    button : function(elm)
    {
    // ƒOƒ‰ƒtƒBƒJƒ‹ƒ{ƒ^ƒ“
    if(currentWithBack) current.comp.addButton(elm);
    current.addButton(elm);
    return 0;
    } incontextof this,

    edit : function(elm)
    {
    // ’Pˆês•ÒW
    if(currentWithBack) current.comp.addEdit(elm);
    current.addEdit(elm);
    return 0;
    } incontextof this,

    checkbox : function(elm)
    {
    // ’Pˆês•ÒW
    if(currentWithBack) current.comp.addCheckBox(elm);
    current.addCheckBox(elm);
    return 0;
    } incontextof this,

    commit : function(elm)
    {
    // ƒtƒH[ƒ€—v‘f‚̃Rƒ~ƒbƒg
    current.commit();
    return 0;
    } incontextof this,

    l : function(elm)
    {
    // sƒNƒŠƒbƒN‘Ò‚¿
    return showLineBreak(elm);
    } incontextof this,

    p : function(elm)
    {
    // ƒy[ƒWƒNƒŠƒbƒN‘Ò‚¿
    if(historyWriteEnabled) historyLayer.reline();
    return showPageBreak(elm);
    } incontextof this,

    current : function(elm)
    {
    // ‘€ì‘Ώۂ̃ƒbƒZ[ƒWƒŒƒCƒ„‚ÌŽw’è
    setCurrentMessageLayer(elm);
    return 0;
    } incontextof this,

    position : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̈ʒuA‘®«‚ðÝ’è
    getMessageLayerObjectFromElm(elm).setPosition(elm);
    return 0;
    } incontextof this,

    ct : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃ŠƒZƒbƒg(‚·‚ׂẴƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA‚Æ
    // current ‚̃ŠƒZƒbƒg)
    if(historyWriteEnabled) historyLayer.repage();
    clearMessageLayers(true);
    return 0;
    } incontextof this,

    cm : function(elm)
    {
    // ƒƒbƒZ[ƒWƒŒƒCƒ„‚̃ŠƒZƒbƒg‚ðs‚¤‚ªAct ‚̂悤‚É
    // current ‚̃ŠƒZƒbƒg‚͍s‚í‚È‚¢‚à‚Ì
    if(historyWriteEnabled) historyLayer.repage();
    clearMessageLayers(false);
    return 0;
    } incontextof this,

    er : function(elm)
    {
    // Œ»Ý‚̃ƒbƒZ[ƒWƒŒƒCƒ„‚̃NƒŠƒA
    if(historyWriteEnabled) historyLayer.repage();
    if(currentWithBack) current.comp.clear();
    current.clear();
    return 0;
    } incontextof this,

    indent : function(elm)
    {
    // ƒCƒ“ƒfƒ“ƒg‚̐ݒè
    if(currentWithBack) current.comp.setIndent();
    current.setIndent();
    if(historyWriteEnabled) historyLayer.beginIndent();
    return 0;
    } incontextof this,

    endindent : function(elm)
    {
    // ƒCƒ“ƒfƒ“ƒg‚̉ðœ
    if(currentWithBack) current.comp.resetIndent();
    current.resetIndent();
    if(historyWriteEnabled) historyLayer.endIndent();
    return 0;
    } incontextof this,

    delay : function(elm)
    {
    // •¶Žš•\Ž¦‘¬“x‚ÌŽw’è
    setDelay(elm);
    return 0;
    } incontextof this,

    nowait : function(elm)
    {
    // ˆêŽž“I‚Ƀm[ƒEƒFƒCƒg‚ÅŽÀs
    enterNoWait();
    return 0;
    } incontextof this,

    endnowait : function(elm)
    {
    // nowait ‚̉ðœ
    leaveNoWait();
    return 0;
    } incontextof this,

    locate : function(elm)
    {
    // •¶Žš•\Ž¦ˆÊ’u‚ðŽw’è
    if(currentWithBack) current.comp.locate(elm.x, elm.y);
    current.locate(elm.x, elm.y);
    return 0;
    } incontextof this,

    glyph : function(elm)
    {
    // ƒNƒŠƒbƒN‘Ò‚¿‹L†‚ðŽw’è
    current.setGlyph(elm);
    return 0;
    } incontextof this,

    locklink : function(elm)
    {
    // ƒŠƒ“ƒN‚̃ƒbƒN
    lockMessageLayerSelProcess();
    return 0;
    } incontextof this,

    unlocklink : function(elm)
    {
    // ƒŠƒ“ƒN‚̃Aƒ“ƒƒbƒN
    unlockMessageLayerSelProcess();
    return 0;
    } incontextof this,

    //----------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒVƒXƒeƒ€‘€ì) --

    loadplugin : function(elm)
    {
    // ƒvƒ‰ƒOƒCƒ“‚̓ǂݍž‚Ý
    Plugins.link(elm.module);
    dm("ƒvƒ‰ƒOƒCƒ“‚ð“ǂݍž‚Ý‚Ü‚µ‚½ : " + elm.module);
    return 0;
    } incontextof this,

    title : function(elm)
    {
    // ƒ^ƒCƒgƒ‹‚̐ݒè
    setTitle(elm.name);
    return 0;
    } incontextof this,

    s : function(elm)
    {
    // ŽÀs’âŽ~
    stablePosibility = true;
    cancelSkip();
    if(!usingExtraConductor) incRecordLabel(true);
    inSleep = true;
    if(recordHistoryOfStore == 2) // 2 : ‘I‘ðŽˆ ( @s ƒ^ƒO ) ‚²‚Æ
    setToRecordHistory();
    notifyStable();
    return -1;
    } incontextof this,

    clickskip : function(elm)
    {
    // ƒNƒŠƒbƒNƒXƒLƒbƒv‚̐ݒè
    clickSkipEnabled = +elm.enabled;
    return 0;
    } incontextof this,

    nextskip : function(elm)
    {
    // ŽŸ‚Ì‘I‘ðŽˆ(/–¢“Ç)‚܂Ői‚ނ̐ݒè
    nextSkipEnabled = +elm.enabled;
    return 0;
    } incontextof this,

    cancelskip : function(elm)
    {
    // ƒXƒLƒbƒv‚̉ðœ
    cancelSkip();
    return 0;
    } incontextof this,

    cancelautomode : function(elm)
    {
    // uŽ*“®“I‚ɓǂݐi‚ށv‚̉ðœ
    cancelAutoMode();
    return 0;
    } incontextof this,

    resetwait : function(elm)
    {
    // ŽžŠÔŒ´“_‚̐ݒè
    resetWait();
    return 0;
    } incontextof this,

    wait : function(elm)
    {
    // ƒEƒFƒCƒg
    return doWait(elm);
    } incontextof this,

    wc : function(elm)
    {
    // Žw’蕶Žš•ª‚̃EƒFƒCƒg
    return doWaitCh(elm);
    } incontextof this,

    waitclick : function(elm)
    {
    // ƒNƒŠƒbƒN‚ð‘Ò‚Â
    return waitClick(elm);
    } incontextof this,

    rclick : function(elm)
    {
    // ‰EƒNƒŠƒbƒN‚Ì“®ìÝ’è
    setRightClickOptions(elm);
    return 0;
    } incontextof this,

    history : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚̐ݒè
    setHistoryOptions(elm);
    return 0;
    } incontextof this,

    showhistory : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚Ì•\Ž¦
    return showHistoryByScenario(elm);
    } incontextof this,

    hr : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ðƒŒƒCƒ„‚ɉüs‚ðo—Í
    if(historyWriteEnabled)
    {
    if(elm.repage !== void && +elm.repage)
    historyLayer.repage();
    else
    historyLayer.reline();
    }
    return 0;
    } incontextof this,

    hact : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚ɃAƒNƒVƒ‡ƒ“‚ðÝ’è
    if(historyWriteEnabled)
    historyLayer.setNewAction(elm.exp);
    return 0;
    } incontextof this,

    endhact : function(elm)
    {
    // ƒƒbƒZ[ƒW—š—ð‚̃AƒNƒVƒ‡ƒ“‚ðƒNƒŠƒA
    if(historyWriteEnabled)
    historyLayer.clearAction();
    return 0;
    } incontextof this,

    hidemessage : function(elm)
    {
    // ƒƒbƒZ[ƒW‚ðˆêŽž“I‚ɉB‚·
    return hideMessageLayerByScenario(elm);
    } incontextof this,

    quake : function(elm)
    {
    // —h‚ê
    doQuake(elm);
    return 0;
    } incontextof this,

    stopquake : function(elm)
    {
    // —h‚ê‚Ì’âŽ~
    stopQuake();
    return 0;
    } incontextof this,

    wq : function(elm)
    {
    // —h‚ê‚Ì’âŽ~‚ð‘Ò‚Â
    return waitQuake(elm);
    } incontextof this,

    autowc : function(elm)
    {
    // Ž*“®ƒEƒFƒCƒg
    setAutoWait(elm);
    return 0;
    } incontextof this,

    cursor : function(elm)
    {
    // ƒ}ƒEƒXƒJ[ƒ\ƒ‹‚̕ύX
    setCursor(elm);
    return 0;
    } incontextof this,

    close : function(elm)
    {
    // ƒEƒBƒ“ƒhƒE‚ð•Â‚¶‚é
    closeByScript(elm);
    return -2;
    } incontextof this,

    copybookmark : function(elm)
    {
    // žx‚ðƒRƒs[
    copyBookMark(+elm.from, +elm.to);
    return 0;
    } incontextof this,

    erasebookmark : function(elm)
    {
    // žx‚ðíœ
    eraseBookMark(+elm.place);
    return 0;
    } incontextof this,

    disablestore : function(elm)
    {
    // žx‚ðˆêŽž“I‚ÉŽg—p•s‰Â‚É
    tempDisableStore(elm);
    return 0;
    } incontextof this,

    store : function(elm)
    {
    // žx‚ÌŽg—p•s‰ÂEŽg—p‰Â‚ðÝ’è‚·‚é
    setStoreEnabled(+elm.enabled);
    return 0;
    } incontextof this,

    load : function(elm)
    {
    // žx‚̓ǂݍž‚Ý
    if(elm.ask !== void && +elm.ask)
    loadBookMarkWithAsk(+elm.place);
    else
    loadBookMark(+elm.place);
    return -4;
    } incontextof this,

    save : function(elm)
    {
    // žx‚̓ǂݍž‚Ý
    if(elm.ask !== void && +elm.ask)
    saveBookMarkWithAsk(+elm.place);
    else
    saveBookMark(+elm.place);
    return -4;
    } incontextof this,

    startanchor : function(elm)
    {
    // uÅ‰‚É–ß‚év‚ÌŽg—p•s‰ÂEŽg—p‰Â‚ðÝ’è‚·‚é
    setStartAnchorEnabled(elm.enabled === void || +elm.enabled);
    return 0;
    } incontextof this,

    gotostart : function(elm)
    {
    // uÅ‰‚É–ß‚év
    if(elm.ask !== void && +elm.ask)
    goToStartWithAsk();
    else
    goToStart();
    return -4;
    } incontextof this,

    goback : function(elm)
    {
    // ’ʉߋL˜^‚ð–ß‚é
    if(elm.ask !== void && +elm.ask)
    goBackHistory(true);
    else
    goBackHistory(false);
    return -4;
    } incontextof this,

    record : function(elm)
    {
    // ’ʉߋL˜^‚ð‚·‚é
    setToRecordHistory();
    return 0;
    } incontextof this,

    tempsave : function(elm)
    {
    // ó‘Ԃ̃ƒ‚ƒŠ‚Ö‚Ì•Û‘¶
    tempSave(+elm.place);
    return 0;
    } incontextof this,

    tempload : function(elm)
    {
    // ó‘Ԃ̃ƒ‚ƒŠ‚Ö‚Ì•Û‘¶
    tempLoad(+elm.place, elm);
    //elm.se === void || +elm.se, elm.bgm === void || +elm.bgm,
    //elm.backlay !== void && +elm.backlay);
    return 0;
    } incontextof this,

    mappfont : function(elm)
    {
    // ƒŒƒ“ƒ_ƒŠƒ“ƒOÏ‚݃tƒHƒ“ƒg‚ðŒ»Ý‚ÌƒtƒHƒ“ƒg‚Ƀ}ƒbƒsƒ“ƒO
    mapPrerenderedFont(elm.storage);
    return 0;
    } incontextof this,

    locksnapshot : function(elm)
    {
    // ‰æ–ʂ̃XƒiƒbƒvƒVƒ‡ƒbƒg‚ðƒƒbƒN‚·‚é
    lockSnapshot();
    return 0;
    } incontextof this,

    unlocksnapshot : function(elm)
    {
    // ‰æ–ʂ̃XƒiƒbƒvƒVƒ‡ƒbƒg‚̃ƒbƒN‚ð‰ðœ‚·‚é
    unlockSnapshot();
    return 0;
    } incontextof this,

    //------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(ƒŒƒCƒ„‘€ì) --

    image : function(elm)
    {
    // ‰æ‘œ“ǂݍž‚Ý
    updateBeforeCh = 1;
    var start = System.getTickCount();
    getLayerFromElm(elm).loadImages(elm);
    dm(elm.storage + " ‚̓ǂݍž‚Ý‚É " + (System.getTickCount() - start) + "ms ‚*‚*‚è‚Ü‚µ‚½");
    return 0;
    } incontextof this,

    img : function(elm)
    {
    // ‰æ‘œ“ǂݍž‚Ý(image‚Æ‚¨‚È‚¶)
    updateBeforeCh = 1;
    var start = System.getTickCount();
    getLayerFromElm(elm).loadImages(elm);
    dm(elm.storage + " ‚̓ǂݍž‚Ý‚É " + (System.getTickCount() - start) + "ms ‚*‚*‚è‚Ü‚µ‚½");
    return 0;
    } incontextof this,

    pimage : function(elm)
    {
    // •”•ª’ljÁ‰æ‘œ“ǂݍž‚Ý
    getLayerFromElm(elm).loadPartialImage(elm);
    return 0;
    } incontextof this,

    ptext : function(elm)
    {
    // ”wŒi/‘OŒiƒŒƒCƒ„‚Ö‚Ì•¶Žš•`‰æ
    getLayerFromElm(elm).drawReconstructibleText(elm);
    return 0;
    } incontextof this,

    freeimage : function(elm)
    {
    // ‰æ‘œ‚̃NƒŠƒA
    updateBeforeCh = 1;
    getLayerFromElm(elm).freeImage(elm);
    return 0;
    } incontextof this,

    animstart : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚ÌŠJŽn
    updateBeforeCh = 1;
    getLayerFromElm(elm).startAnim(elm);
    return 0;
    } incontextof this,

    animstop : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~
    updateBeforeCh = 1;
    getLayerFromElm(elm).stopAnim(+elm.seg);
    return 0;
    } incontextof this,

    wa : function(elm)
    {
    // ƒAƒjƒ[ƒVƒ‡ƒ“‚Ì’âŽ~‘Ò‚¿
    return waitAnimation(elm);
    } incontextof this,

    mapimage : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚̗̈æ‰æ‘œ‚ð“ǂݍž‚Þ
    getLayerFromElm(elm).loadProvinceImage(elm.storage);
    return 0;
    } incontextof this,

    mapaction : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚̗̈æƒAƒNƒVƒ‡ƒ“’è‹`‚ð“ǂݍž‚Þ
    getLayerFromElm(elm).loadProvinceActions(elm.storage);
    return 0;
    } incontextof this,

    mapdisable : function(elm)
    {
    // ƒNƒŠƒbƒJƒuƒ‹ƒ}ƒbƒv‚𖳌ø‚É‚·‚é
    getLayerFromElm(elm).clearProvinceActions();
    return 0;
    } incontextof this,

    backlay : function(elm)
    {
    // ƒŒƒCƒ„‚ð— ‰æ–ʂɃRƒs[
    updateBeforeCh = 1;
    backupLayer(elm, true);
    return 0;
    } incontextof this,

    forelay : function(elm)
    {
    // ƒŒƒCƒ„‚ð•\‰æ–ʂɃRƒs[
    updateBeforeCh = 1;
    backupLayer(elm, false);
    return 0;
    } incontextof this,

    copylay : function(elm)
    {
    // “¯Ží‚̃ŒƒCƒ„“¯Žm‚̃Rƒs[
    updateBeforeCh = 1;
    copyLayer(elm);
    return 0;
    } incontextof this,

    layopt : function(elm)
    {
    // ƒŒƒCƒ„‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è
    updateBeforeCh = 1;
    getLayerFromElm(elm).setOptions(elm);
    return 0;
    } incontextof this,

    trans : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ÌŠJŽn
    getLayerPageFromElm(elm, false).beginTransition(elm);
    return 0;
    } incontextof this,

    wt : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð‘Ò‚Â
    return waitTransition(elm);
    } incontextof this,

    stoptrans : function(elm)
    {
    // ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“‚ð’âŽ~‚·‚é
    stopAllTransitions();
    return 0;
    } incontextof this,

    move : function(elm)
    {
    // Ž*“®ˆÚ“®‚ÌŠJŽn
    getLayerFromElm(elm).beginMove(elm);
    return 0;
    } incontextof this,

    wm : function(elm)
    {
    // Ž*“®ˆÚ“®‚ð‘Ò‚Â
    return waitMove(elm);
    } incontextof this,

    stopmove : function(elm)
    {
    // Ž*“®ˆÚ“®‚ð’âŽ~‚·‚é
    stopAllMoves();
    return 0;
    } incontextof this,

    laycount : function(elm)
    {
    updateBeforeCh = 1;
    allocateCharacterLayers(+elm.layers) if elm.layers !== void;
    allocateMessageLayers(+elm.messages) if elm.messages !== void;
    return 0;
    } incontextof this,

    //------------------------------ ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(Œø‰Ê‰¹EBGMEƒrƒfƒI‘€ì) --

    playbgm : function(elm)
    {
    // BGM ‚̉‰‘t
    bgm.play(elm);
    return 0;
    } incontextof this,

    stopbgm : function(elm)
    {
    // BGM ‚Ì’âŽ~
    bgm.stop();
    return 0;
    } incontextof this,

    pausebgm : function(elm)
    {
    // BGM ‚̈ꎞ’âŽ~
    bgm.pause();
    return 0;
    } incontextof this,

    resumebgm : function(elm)
    {
    // BGM ‚̍ĊJ
    bgm.resume();
    return 0;
    } incontextof this,

    fadeinbgm : function(elm)
    {
    // BGM ‚̃tƒF[ƒhƒCƒ“
    bgm.fadeIn(elm);
    return 0;
    } incontextof this,

    fadeoutbgm : function(elm)
    {
    // BGM ‚̃tƒF[ƒhƒAƒEƒg
    bgm.fadeOut(elm);
    return 0;
    } incontextof this,

    fadebgm : function(elm)
    {
    // BGM ‚ÌŽw’艹—ʂ܂ł̃tƒF[ƒh
    bgm.fade(elm);
    return 0;
    } incontextof this,

    xchgbgm : function(elm)
    {
    // BGM ‚Ì“ü‚ê‘Ö‚¦/ƒNƒƒXƒtƒF[ƒh
    bgm.exchange(elm);
    return 0;
    } incontextof this,

    bgmopt : function(elm)
    {
    // BGM ‚̃IƒvƒVƒ‡ƒ“Ý’è
    bgm.setOptions(elm);
    return 0;
    } incontextof this,

    wb : function(elm)
    {
    // BGM ‚̃tƒF[ƒhI—¹‘Ò‚¿
    return waitBGMFade(elm);
    } incontextof this,

    wl : function(elm)
    {
    // BGM ‚̍жI—¹‘Ò‚¿
    return waitBGMStop(elm);
    } incontextof this,

    playse : function(elm)
    {
    // Œø‰Ê‰¹‚̍ж
    se[+elm.buf].play(elm);
    return 0;
    } incontextof this,

    stopse : function(elm)
    {
    // Œø‰Ê‰¹‚Ì’âŽ~
    se[+elm.buf].stop();
    return 0;
    } incontextof this,

    fadeinse : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhƒCƒ“Ä¶
    se[+elm.buf].fadeIn(elm);
    return 0;
    } incontextof this,

    fadeoutse : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhƒAƒEƒg
    se[+elm.buf].fadeOut(elm);
    return 0;
    } incontextof this,

    fadese : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh
    se[+elm.buf].fade(elm);
    return 0;
    } incontextof this,

    seopt : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒh
    se[+elm.buf].setOptions(elm);
    return 0;
    } incontextof this,

    wf : function(elm)
    {
    // Œø‰Ê‰¹‚̃tƒF[ƒhI—¹‘Ò‚¿
    return waitSEFade(elm);
    } incontextof this,

    ws : function(elm)
    {
    // Œø‰Ê‰¹‚̍жI—¹‘Ò‚¿
    return waitSEStop(elm);
    } incontextof this,

    video : function(elm)
    {
    // ƒ€[ƒr[‚̃IƒvƒVƒ‡ƒ“‚ðÝ’è‚·‚é
    movies[+elm.slot].setOptions(elm);
    return 0;
    } incontextof this,

    playvideo : function(elm)
    {
    // ƒ€[ƒr[‚ðÄ¶‚·‚é
    movies[+elm.slot].play(elm.storage);
    return 0;
    } incontextof this,

    stopvideo : function(elm)
    {
    // ƒ€[ƒr[‚ð’âŽ~‚·‚é
    movies[+elm.slot].stop();
    return 0;
    } incontextof this,

    openvideo : function(elm)
    {
    // ƒ€[ƒr[Ä¶‚̏€”õ‚ð‚·‚é
    movies[+elm.slot].open(elm.storage);
    return 0;
    } incontextof this,

    wv : function(elm)
    {
    // ƒ€[ƒr[‚̍жI—¹‚ð‘Ò‚Â
    return waitMovieStop(elm);
    } incontextof this,

    // Start: Add: T.Imoto
    wp : function(elm)
    {
    // ƒ€[ƒr[‚̃sƒŠƒIƒhƒCƒxƒ“ƒg‚ð‘Ò‚Â
    return waitMoviePeriod(elm);
    } incontextof this,

    pausevideo : function(elm)
    {
    movies[+elm.slot].pause();
    return 0;
    } incontextof this,

    resumevideo : function(elm)
    {
    movies[+elm.slot].resume();
    return 0;
    } incontextof this,

    preparevideo : function(elm)
    {
    movies[+elm.slot].prepare();
    return 0;
    } incontextof this,

    rewindvideo : function(elm)
    {
    movies[+elm.slot].rewind();
    return 0;
    } incontextof this,

    videolayer : function(elm)
    {
    movies[+elm.slot].storeLayer( elm.layer, elm.page, elm.channel );
    movies[+elm.slot].setVideoLayer(getLayerFromElm(elm),elm);
    return 0;
    } incontextof this,

    clearvideolayer : function(elm)
    {
    movies[+elm.slot].cancelLayer( elm.channel );
    movies[+elm.slot].setVideoLayer(null,elm);
    return 0;
    } incontextof this,

    videosegloop : function(elm)
    {
    movies[+elm.slot].setSegment(elm);
    return 0;
    } incontextof this,

    cancelvideosegloop : function(elm)
    {
    movies[+elm.slot].cancelSegmentLoop();
    return 0;
    } incontextof this,

    videoevent : function(elm)
    {
    movies[+elm.slot].setPeriod(elm);
    return 0;
    } incontextof this,

    cancelvideoevent : function(elm)
    {
    movies[+elm.slot].cancelPeriodEvent();
    return 0;
    } incontextof this,
    // End: Add: T.Imoto

    //--------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ(•Ï”ETJS ‘€ì) --

    eval : function(elm)
    {
    // Ž®‚Ì•]‰¿
    Scripts.eval(elm.exp);
    return 0;
    } incontextof this,

    trace : function(elm)
    {
    // Ž®‚̃gƒŒ[ƒX•\Ž¦
    var exp = elm.exp;
    var result = Scripts.eval(exp);
    dm("¥[trace] expression=\"" + exp + "\" type of result=" + typeof result +
    " result=" + result);
    return 0;
    } incontextof this,

    input : function(elm)
    {
    // •¶Žš—ñ‚Ì“ü—Í
    inputString(elm);
    return 0;
    } incontextof this,

    clearsysvar : function(elm)
    {
    // ƒVƒXƒeƒ€•Ï”‚̃NƒŠƒA
    clearSystemVariables();
    return 0;
    } incontextof this,

    clearvar : function(elm)
    {
    // ƒQ[ƒ€•Ï”‚̃NƒŠƒA
    clearVariables();
    return 0;
    } incontextof this,

    waittrig : function(elm)
    {
    // ƒgƒŠƒK‚ð‘Ò‚Â
    return waitTrigger(elm);
    } incontextof this,

    //----------------------------------------------- ƒ^ƒOƒnƒ“ƒhƒ‰ŒQ‚̏I‚í‚è --

    interrupt : function(elm) { return -2; } incontextof this ];
    }
    }



    // TJS ƒXƒNƒŠƒvƒg‚Í‚±‚±‚ŏI‚í‚è
    "
    END_OF_TJS_SCRIPT
    # "; /*

    # assign ‚ŃRƒs[‚·‚ׂ«•Ï”‚̍ж¬‚ðs‚¤ perl ƒXƒNƒŠƒvƒg

    open FH, "MainWindow.tjs" or die;
    undef($/);
    $content = <FH>;

    $list_store = '';
    $list_restore = '';
    while($content =~ /\/\*C\*\/var\s+(\w+)/gs)
    {
    $list_store .= "\t\tf.$1 = $1;\n";
    $list_restore .= "\t\t$1 = f.$1 if f.$1 !== void;\n";
    }

    $content =~
    s/\t\t\/\/ \[start_store_vars\]\n.*?\t\t\/\/ \[end_store_vars\]/\t\t\/\/ \[start_store_vars\]\n$list_store\t\t\/\/ \[end_store_vars\]/s;
    $content =~
    s/\t\t\/\/ \[start_restore_vars\]\n.*?\t\t\/\/ \[end_restore_vars\]/\t\t\/\/ \[start_restore_vars\]\n$list_restore\t\t\/\/ \[end_restore_vars\]/s;

    open FH, ">MainWindow.tjs" or die;
    print FH $content;


    # */
    Wanted you a VN to play or it to install...? Well if yeah, then seem it very that your PC not to Japanese localisation set have...
    Ignore This Signature
      Spoiler: ASF's contest  
    [/CENTER]
    Notice: The following banners/notices are to their contests/threads linked, if you wanna to there join then click it!!

  4. #3
    Your Nii-chan Yee199's Avatar
    Join Date
    Jan 2013
    Location
    U.S.A.
    Age
    21
    Posts
    706
    Thanks
    32
    Thanked 18 Times in 10 Posts
    Points: 4,165, Level: 41
    Points: 4,165, Level: 41
    Overall activity: 3.0%
    Overall activity: 3.0%
    Achievements:
    1000 Experience PointsThree Friends3 months registered

    Re: Errr....

    I am gonna walk away slowly now.
    Ignore This Signature

  5. #4
    Senior Member
    Join Date
    Oct 2012
    Posts
    197
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Points: 1,077, Level: 17
    Points: 1,077, Level: 17
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    3 months registeredThree Friends1000 Experience Points

    Re: Errr....

    Quote Originally Posted by nanashi1 View Post
    Wanted you a VN to play or it to install...? Well if yeah, then seem it very that your PC not to Japanese localisation set have...
    But it's in English... ;~;
    Ignore This Signature

  6. #5
    One of countless souls... nanashi1's Avatar
    Join Date
    Jul 2012
    Location
    Somewhere in a point of the universe
    Age
    31
    Posts
    78,872
    Thanks
    2,043
    Thanked 4,219 Times in 3,085 Posts
    Points: 242,917, Level: 100
    Points: 242,917, Level: 100
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Your first GroupThree FriendsOverdriveTagger First Class50000 Experience PointsRecommendation Second Class
    Awards:
    SOTM #29 WinnerSOTM #54 WinnerSOTM #56 WinnerSOTM #59 WinnerSOTM #60 Winner

    Re: Errr....

    Quote Originally Posted by Ichiko View Post
    But it's in English... ;~;
    Well is that a english game or in english translated game...?
    Ignore This Signature
      Spoiler: ASF's contest  
    [/CENTER]
    Notice: The following banners/notices are to their contests/threads linked, if you wanna to there join then click it!!

  7. #6
    Valkyria Selvaria Bles's Avatar
    Join Date
    Jun 2012
    Location
    Empire
    Posts
    18,238
    Thanks
    57
    Thanked 852 Times in 589 Posts
    Points: 69,032, Level: 100
    Points: 69,032, Level: 100
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Three FriendsYour first GroupTagger First ClassRecommendation Second Class50000 Experience PointsVeteran

    Re: Errr....

    Maybe the file is corrupted.

  8. #7
    Senior Member
    Join Date
    Oct 2012
    Posts
    197
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Points: 1,077, Level: 17
    Points: 1,077, Level: 17
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    3 months registeredThree Friends1000 Experience Points

    Re: Errr....

    Wait what?
    Ignore This Signature

  9. #8
    One of countless souls... nanashi1's Avatar
    Join Date
    Jul 2012
    Location
    Somewhere in a point of the universe
    Age
    31
    Posts
    78,872
    Thanks
    2,043
    Thanked 4,219 Times in 3,085 Posts
    Points: 242,917, Level: 100
    Points: 242,917, Level: 100
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Your first GroupThree FriendsOverdriveTagger First Class50000 Experience PointsRecommendation Second Class
    Awards:
    SOTM #29 WinnerSOTM #54 WinnerSOTM #56 WinnerSOTM #59 WinnerSOTM #60 Winner

    Re: Errr....

    Maybe the file is corrupted.
    Quote Originally Posted by Ichiko View Post
    Wait what?
    He mean that it at downloading of the games a error given has...
    Ignore This Signature
      Spoiler: ASF's contest  
    [/CENTER]
    Notice: The following banners/notices are to their contests/threads linked, if you wanna to there join then click it!!

  10. #9
    Art of Spam~ Ghost Kitty~'s Avatar
    Join Date
    Oct 2011
    Location
    Afterlife Battlefront
    Age
    26
    Posts
    147,723
    Thanks
    411
    Thanked 2,569 Times in 2,225 Posts
    Points: 359,790, Level: 100
    Points: 359,790, Level: 100
    Overall activity: 1.0%
    Overall activity: 1.0%
    Achievements:
    OverdriveThree Friends50000 Experience PointsTagger Second ClassRecommendation First ClassYour first Group
    Awards:
    WOW #1 WinnerWOW #3 ParticipantWOW #4 ParticipantWOW #5 ParticipantWOW #5 ParticipantWOW #4 ParticipantWOW #6 Participant

    Re: Errr....

    Well trying japanese locale should probably be your first step?
    Ignore This Signature

    ~Do you have a wish?~

    To the many friends that have come and gone...
    We shall miss you..~ Do drop by if you find yourself nearby..~


    Made by an odd neko~
      Spoiler: Test your video editing skills or try a random game~ 

  11. #10
    One of countless souls... nanashi1's Avatar
    Join Date
    Jul 2012
    Location
    Somewhere in a point of the universe
    Age
    31
    Posts
    78,872
    Thanks
    2,043
    Thanked 4,219 Times in 3,085 Posts
    Points: 242,917, Level: 100
    Points: 242,917, Level: 100
    Overall activity: 0%
    Overall activity: 0%
    Achievements:
    Your first GroupThree FriendsOverdriveTagger First Class50000 Experience PointsRecommendation Second Class
    Awards:
    SOTM #29 WinnerSOTM #54 WinnerSOTM #56 WinnerSOTM #59 WinnerSOTM #60 Winner

    Re: Errr....

    Yeah, how Samy already say, you must at such case the/your PC to Japanese locale set up... But mention me if you not know how, okay...?
    Ignore This Signature
      Spoiler: ASF's contest  
    [/CENTER]
    Notice: The following banners/notices are to their contests/threads linked, if you wanna to there join then click it!!

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •