OSDN Git Service

微調整完了!もう
[h58pcdgame/GameScriptCoreLibrary.git] / www / index_local_debug.html
index a45fd8c..e7a4092 100644 (file)
@@ -4,10 +4,21 @@
 <meta http-equiv="X-UA-Compatible" content="IE=9">
 <meta charset="UTF-8">
 <title>HTML5Test</title>
-
+<style type="text/css">
+       h1, h2, h3 {
+               margin:0px;
+       }
+       body, textarea {
+               font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
+               font-size: 11px;
+               line-height: 1.2;
+       }
+</style>
 <script type="text/javascript" src="./corelib/header.js" charset="UTF-8"></script>
 <script type="text/javascript">
 
+var mainManager = null;
+var dbg = null;
 onload = function()
 {
        var val = localStorage.getItem("savedat");
@@ -15,90 +26,76 @@ onload = function()
        {
                document.getElementById("stageCode").value = val;
        }
-};
-
-var mainManager = null;
-var run = function() {
        
        //ゲームマネージャー初期化
-       mainManager = new GameManager();
+       //mainManager = new GameManager();
+       mainManager = document.getElementById('MainArea').InitGameManager();
+       dbg = mainManager.debugText;
+       //最初はグローバルデバッグモードはオフ
+       mainManager.debugText = null;
+       
+       //コールバック指定
+       mainManager.stageStartedEvent = function(stage)
+       {
+               document.getElementById('MainArea').style.visibility = 'visible';
+       };
+       mainManager.stageStoppedEvent = function(stage)
+       {
+               document.getElementById('MainArea').style.visibility = 'hidden';
+       };
+       
+       var prev;
+       if(prev = localStorage.getItem("previewStage"))
+       {
+               localStorage.removeItem("previewStage");
+               document.getElementById('stageCode').value = (prev);
+               run();
+       }else
+       {
+               location.href="editor/index.html";
+       }
+       
+};
+
+var run = function(){
+
        var stage = document.getElementById("stageCode").value;
-       mainManager.loadStageFromLocal(stage, null);
+       mainManager.loadStageFromLocal(stage);
 };
 
-function reset(){
-       obj=document.getElementById("MainArea");
-       for(var item in obj.childNodes)
+function stop(){
+       mainManager.stopStage();
+}
+
+function switchDebug()
+{
+       if(mainManager.debugText == null)
        {
-               obj.removeChild(item);
+               mainManager.debugText = dbg;
+               mainManager.runningStage.debugMode = true;
+               mainManager.debugOut("Debug enabled.\n");
+       } else{
+               mainManager.debugOut("Debug disabled.\n");
+               mainManager.debugText = null;
+               mainManager.runningStage.debugMode = false
        }
 }
 
-function save()
+function reload()
 {
-       localStorage.setItem('savedat', document.getElementById('stageCode').value);
+       localStorage.setItem("previewStage", document.getElementById('stageCode').value);
+       location.reload();
 }
 
 </script>
 </head>
 <body>
-       <div id="MainArea" style="position: inline"></div>
+       <div id="MainArea" style="width: 640px; height: 480px; visibility: hidden"></div>
        <div id="Resources"></div>
-       <div style="z-index: 1; top: 520px; position: absolute; left: 0;">
-       <form><textarea id="DebugText" rows="8" cols="64"></textarea></form></div>
-       <div style="position: absolute; left: 650px; top: 0; right: 0; z-index: 1">
-               <form>
-               <textarea id="stageCode" rows="60" style="width: 100%; height: 90%">
-               //ステージの設定
-//     グローバル名前空間にmainManagerがすでに存在する状況下で呼ばれる。
-//     最初の行で新たなインスタンスを生成し、最後のreturnでそれを返す。
-
-stage = new GameStage();
-
-stage.moveForce = 50;
-
-//関数のオーバーライド
-stage.runStage = function(){
-       //元々定義されていた、疑似スーパークラス(prototype)の関数を呼び出す。
-       GameStage.prototype.runStage.apply(this, []);
-       for(i = 0; i < 2; i++){
-               aCircle = new CharacterClass(this);
-               aCircle.origin.x = 16 + 16 * i;
-               aCircle.origin.y = 16 + 16 * i;
-               aCircle.frame.origin.x = - (8 + i);
-               aCircle.frame.origin.y = - (8 + i);
-               aCircle.frame.size.x = 2 * (8 + i);
-               aCircle.frame.size.y = 2 * (8 + i);
-               
-               this.addStageObject(aCircle);
-       }
-};
-stage.timerTick = function(){
-       GameStage.prototype.timerTick.apply(stage, []);
-       if(this.manager.keyState.upArrow){
-               //上カーソル
-               stage.eachStageObject(function(item){item.movingSpeed.y -= stage.moveForce; });
-       }
-       if(this.manager.keyState.downArrow){
-               //下カーソル
-               stage.eachStageObject(function(item){item.movingSpeed.y += stage.moveForce;});
-       }
-       if(this.manager.keyState.leftArrow){
-               stage.eachStageObject(function(item){item.movingSpeed.x -= stage.moveForce;});
-       }
-       if(this.manager.keyState.rightArrow){
-               //右カーソル
-                stage.eachStageObject(function(item){item.movingSpeed.x += stage.moveForce;});
-       }
-};
-
-stage;
-
-               
-               </textarea>
-               <input type="button" onclick="run(); return false;" value="run"><!--<input type="button" onclick="reset(); return false;" value="reset">--><input type="button" onclick="save(); return false;" value="save"><br>
-               ※すべてのコードを消したうえでセーブし更新すると最初のコードに戻ります。
-               </form>
+       <div style="z-index: 1;">
+               <form><textarea id="DebugText" rows="8" cols="64"></textarea></form>
+               <input type="button" onclick="run(); return false;" value="ステージの実行/再実行"><input type="button" onclick="stop(); return false;" value="ステージの停止"><input type="button" onclick="switchDebug(); return false;" value="デバッグの有効/無効"><input type="button" onclick="reload(); return false;" value="ページの再読み込み">
        </div>
+       <div style="display: none;"><form><textarea id="stageCode"></textarea></form></div>
 </body>
 </html>
\ No newline at end of file