// //var debugmode = Storages.extractStorageName(System.exeName)==='krkr.exe'; var debugmode = Storages.isExistentStorage(System.exePath+'!debug.txt'); var debugalert = Storages.isExistentStorage(System.exePath+'!alert.txt'); var appendVersion = [void,void,void,void,void,void]; //appendチェック用です、appendバージョンに合った添え字のデータにアペンドタイトルを入れてね //アペンドタイトルは'append1'とかでいいです(タイトルバーに ~ + append1 とか出ます //なお、[不定,アペンド1,...]なので注意してね //--------------------------------------- //*getExtPath //拡張子を補完してexistを調べます //--------------------------------------- function getImageExtPath(name) { if(Storages.isExistentStorage(name)) return name; if(Storages.isExistentStorage(name+'.asd')) return name; //+'.asd'するとダメっぽい if(Storages.isExistentStorage(name+'.tlg')) return name+'.tlg'; if(Storages.isExistentStorage(name+'.png')) return name+'.png'; return ''; } function getSoundExtPath(name) { if(Storages.isExistentStorage(name)) return name; if(Storages.isExistentStorage(name+'.ogg')) return name+'.ogg'; if(Storages.isExistentStorage(name+'.wav')) return name+'.wav'; return ''; } function getMovieExtPath(name) { if(Storages.isExistentStorage(name)) return name; if(sf.moviePlayType<0) return ''; for( var i=0 ; i // Initialize.tjs - システムの初期化 // Copyright (C)2001-2009, W.Dee and contributors 改変・配布は自由です // システムバージョン var kagVersion = "3.32 stable rev. 2"; /* Debug.message へのショートカット */ var dm = Debug.message; // これで dm("message"); でコンソールに message を表示できる /* デフォルトの「捕捉されない例外」ハンドラ */ System.exceptionHandler = function (e) { // どこにも捕捉されない例外がシステム側で捕捉された場合、この関数が // 呼ばれる。e は例外オブジェクト。 if(e instanceof "ConductorException") { // コンダクタの投げた例外の場合 Debug.logAsError(); // ログのファイルへの書き出し動作の開始など var event_disabled = System.eventDisabled; System.eventDisabled = true; // エラーの理由を表示させている間にイベントが発生すると // やっかいなのでいったんイベント発生を停止させる System.inform(e.message); System.eventDisabled = event_disabled; // イベントを発生するかどうかを元の状態に return true; // true を返すと本体側で例外の処理は行わなくなる } else { return false; // false を返すと通常の例外処理 } }; /* パスの設定 後に指定した物が、より優先されて使用される */ function useArchiveIfExists(name) { // name が存在していたらそのアーカイブを使う var arcname; if(Storages.isExistentStorage(arcname = System.exePath + name)) Storages.addAutoPath(arcname + ">"); } Storages.addAutoPath(System.exePath + "video/"); // exePath 以下の video/ Storages.addAutoPath("brand/"); Storages.addAutoPath("option/"); Storages.addAutoPath("font/"); Storages.addAutoPath("others/"); // その他 Storages.addAutoPath("face/"); // 前景画像フォルダ Storages.addAutoPath("staffroll/"); Storages.addAutoPath("image/"); // そのほかの画像フォルダ Storages.addAutoPath("title/"); Storages.addAutoPath("movieselect/"); Storages.addAutoPath("sceneselect/"); Storages.addAutoPath("event/"); // イベント画像フォルダ Storages.addAutoPath("rule/"); // ルール画像フォルダ Storages.addAutoPath("back/"); // 背景画像フォルダ Storages.addAutoPath("bgm/"); // BGM フォルダ Storages.addAutoPath("sound/"); // 効果音フォルダ Storages.addAutoPath("se/"); // 抽送音 Storages.addAutoPath("map/"); Storages.addAutoPath("video/"); // video フォルダ Storages.addAutoPath("video2/"); // video フォルダ Storages.addAutoPath("voice/"); Storages.addAutoPath("word/"); Storages.addAutoPath("scenario/"); // シナリオフォルダ Storages.addAutoPath("system/"); // システムフォルダ Storages.addAutoPath("exp/"); // シナリオフォルダ Storages.addAutoPath("exp2/"); Storages.addAutoPath("appended/"); // アペンド用(前回のアペンドに追加した古いものはここに入れてしまう) Storages.addAutoPath("appended_exp/"); Storages.addAutoPath("appended_exp2/"); Storages.addAutoPath("append/"); // アペンド用(新しいアペンドの内容) Storages.addAutoPath("append_exp/"); Storages.addAutoPath("append_exp2/"); Storages.addAutoPath("addition/"); //一部タイプなどで修正するもの(パッチとは別の修正) Storages.addAutoPath("test/"); Storages.addAutoPath("patch/"); // Scripts.execStorage("version.tjs"); // // パッチアーカイブの検索と使用 // もしこれらの名前を持ったアーカイブが実行可能ファイルと // 同じ場所にあった場合、それを優先して使う useArchiveIfExists("mako_event.xp3"); useArchiveIfExists("mako_video.xp3"); useArchiveIfExists("mako_video2.xp3"); useArchiveIfExists("mako_system.xp3"); useArchiveIfExists("mako_exp.xp3"); useArchiveIfExists("mako_exp2.xp3"); useArchiveIfExists("mako_append.xp3"); useArchiveIfExists("mako_append_exp.xp3"); useArchiveIfExists("mako_append_exp2.xp3"); for(var i = 2; ; i++) { var f = true; if(Storages.isExistentStorage(System.exePath + "mako_append" + i + ".xp3")){ Storages.addAutoPath(System.exePath + "mako_append" + i + ".xp3>"); f=false; } if(Storages.isExistentStorage(System.exePath + "mako_append" + i + "_exp.xp3")){ Storages.addAutoPath(System.exePath + "mako_append" + i + "_exp.xp3>"); f=false; } if(Storages.isExistentStorage(System.exePath + "mako_append" + i + "_exp2.xp3")){ Storages.addAutoPath(System.exePath + "mako_append" + i + "_exp2.xp3>"); f=false; } if(f) break; } useArchiveIfExists("mako_special.xp3"); //個別修正 useArchiveIfExists("mako_addition.xp3"); useArchiveIfExists("mako_patch.xp3"); // 追加のパッチ用アーカイブの検索 for(var i = 2; ; i++) { // パッチ用アーカイブ patch2.xp3, patch3.xp3 ... がある場合はそちらを // 優先して読み込むように if(Storages.isExistentStorage(System.exePath + "mako_patch" + i + ".xp3")) Storages.addAutoPath(System.exePath + "mako_patch" + i + ".xp3>"); else break; } delete useArchiveIfExists; // useArchiveIfExists は使い終わったので一応消しておく /* システムバージョン */ Debug.notice("OS : " + System.osName + " (" + System.platformName + ")"); Debug.notice("KAG : " + kagVersion); Debug.notice("Kirikiri : " + System.versionString); /* ( デバッグ ) 時間計測 */ var parseStartTick = System.getTickCount(); /* スクリプト読み込みラッパー */ function KAGLoadScript(name) { var start = System.getTickCount(); Scripts.execStorage(name); dm(name + " を読み込みました(" + (System.getTickCount() - start) + "ms)"); } var loaded_scripts = %[]; function KAGLoadScriptOnce(name) { // 指定したスクリプトを読み込むが、一回しか読み込まない if(global.loaded_scripts[name] === true) return; // 既に読み込んでいる global.KAGLoadScript(name); global.loaded_scripts[name] = true; } // KAGLoadScript("exp.tjs"); KAGLoadScript("append.tjs") if Storages.isExistentStorage("append.tjs"); KAGLoadScript("append2.tjs") if Storages.isExistentStorage("append2.tjs"); KAGLoadScript("append3.tjs") if Storages.isExistentStorage("append3.tjs"); KAGLoadScript("append4.tjs") if Storages.isExistentStorage("append4.tjs"); KAGLoadScript("append5.tjs") if Storages.isExistentStorage("append5.tjs"); for( var i=6 ;; i++ ) { if(Storages.isExistentStorage("append%d.tjs".sprintf(i))) KAGLoadScript("append%d.tjs".sprintf(i)); else break; } // /* Config.tjs 読み込み */ if(Storages.isExistentStorage("Config.tjs")) { KAGLoadScript("Config.tjs"); } else if(Storages.isExistentStorage("Config.~new")) { System.inform("Config.tjs が見つかりません。\nsystem フォルダにある " "Config.~new ファイルを Config.tjs に改名してください。"); System.exit(); } else { throw new Exception("Config.tjs が見つかりません。"); } // //configで読み込んだtitleに、append情報を付加 for( var i=1 ; i /* Config.tjs バージョンチェック */ if(typeof global.config_version == "undefined" || config_version != kagVersion) { KAGLoadScript("UpdateConfig.tjs"); } /* 二重起動のチェック */ // 実行可能ファイルのパスをキーにしてロックを行う if(!System.createAppLock(System.exePath.replace(/[^A-Za-z]/g, '_'))) { // すでに起動している System.inform(System.title + "はすでに起動しています"); System.exit(); } /* オン・デマンド・ローディングを行うための定義 */ property askYesNo { getter() { KAGLoadScript("YesNoDialog.tjs"); return global.askYesNo; } } property CheckBoxLayer { getter() { KAGLoadScript("CheckBoxLayer.tjs"); return global.CheckBoxLayer; } } property ButtonLayer { getter() { KAGLoadScript("ButtonLayer.tjs"); return global.ButtonLayer; } } property EditLayer { getter() { KAGLoadScript("EditLayer.tjs"); return global.EditLayer; } } property KAGPlugin { getter() { KAGLoadScript("Plugin.tjs"); return global.KAGPlugin; } } /* 各システム読み込み */ dm("KAG System スクリプトを読み込んでいます..."); KAGLoadScript("Utils.tjs"); KAGLoadScript("KAGLayer.tjs"); KAGLoadScript("HistoryLayer.tjs"); KAGLoadScript("BGM.tjs"); KAGLoadScript("SE.tjs"); KAGLoadScript("Movie.tjs"); KAGLoadScript("Conductor.tjs"); KAGLoadScript("AnimationLayer.tjs"); KAGLoadScript("GraphicLayer.tjs"); KAGLoadScript("RotateLayer.tjs"); KAGLoadScript("MessageLayer.tjs"); KAGLoadScript("Menus.tjs"); KAGLoadScript("DefaultMover.tjs"); KAGLoadScript("MainWindow.tjs"); if(Storages.isExistentStorage("Override.tjs")) KAGLoadScript("Override.tjs"); if(Storages.isExistentStorage(System.exePath + "Override2.tjs")) KAGLoadScript(System.exePath + "Override2.tjs"); /* ( デバッグ ) 時間計測 */ dm("スクリプトの読み込みに " + (System.getTickCount() - parseStartTick) + "ms かかりました"); parseStartTick = System.getTickCount(); /* ( デバッグ ) VM コードのダンプ */ // Scripts.dump(); /* ( デバッグ ) 時間計測 */ parseStartTick = System.getTickCount(); /* KAG メインウィンドウの作成 グローバルメンバ kag が存在しなければ KAGWindow クラスの オブジェクトを作成して入れる */ @if(kirikiriz) Plugins.link("plugin/KAGParser.dll"); //Plugins.link("plugin/menu.dll"); @endif global.kag = new KAGWindow() if typeof global.kag == "undefined"; /* グローバルから簡単にアクセスできるように、いくつかの 変数の別名を作成 */ var f = kag.flags; // ユーザ変数 (フラグ) var sf = kag.sflags; // システム変数 (システム) var tf = kag.tflags; // 一時変数 (一時フラグ) property mp { getter { return kag.conductor.macroParams; } } /* ( デバッグ ) 時間計測 */ dm("KAGMainWindow のコンストラクタで " + (System.getTickCount() - parseStartTick) + "ms かかりました"); delete parseStartTick; /* AfterInit.tjs が存在すれば実行 */ if(Storages.isExistentStorage("AfterInit.tjs")) KAGLoadScript("AfterInit.tjs"); if(Storages.isExistentStorage(System.exePath + "AfterInit2.tjs")) KAGLoadScript(System.exePath + "AfterInit2.tjs"); /* コマンドラインパラメータとして -ovr が指定されていれば そのパラメータを TJS 式として実行 */ { var ovr = System.getArgument('-ovr'); if(ovr !== void && ovr != 'yes') Scripts.eval(ovr); } /* first.ks の実行 */ kag.process("first.ks");