From: ttwilb Date: Wed, 21 Aug 2013 11:05:59 +0000 (+0900) Subject: PCDSLEditorのアップデートとゲームのポータブル実行の対応 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7ebd4cffb4a9b032b6f774ed14451c092c5a7208;p=h58pcdgame%2FGameScriptCoreLibrary.git PCDSLEditorのアップデートとゲームのポータブル実行の対応 (具体的には... www内の各ディレクトリをコピーしたディレクトリにhtmlファイルを置き、header.jsをインクルードし、用意したdiv要素に対してInitGameManager(StageName)を実行) --- diff --git a/www/corelib/classes/GameStageClass.js b/www/corelib/classes/GameStageClass.js index c9fc46d..7c92a1b 100644 --- a/www/corelib/classes/GameStageClass.js +++ b/www/corelib/classes/GameStageClass.js @@ -114,7 +114,7 @@ GameStage.prototype = { //ƒXƒe[ƒW‰Šú‰»ˆ— this.tickCount = 0; //Õ“˃}ƒbƒv‰Šú‰» - this.collisionMapCanvas = createCanvas("collisionMapCanvas", this.mainCanvas.width, this.mainCanvas.height, this.mainCanvas.width, 0, 1, "MainArea"); + this.collisionMapCanvas = createCanvas("collisionMapCanvas", this.mainCanvas.width, this.mainCanvas.height, this.mainCanvas.width, 0, 1, this.manager.mainArea); this.collisionMapContext = this.collisionMapCanvas.getContext('2d'); this.collisionMapContext.fillStyle = "rgba(0,0,0, 0.2)"; this.collisionMapContext.strokeStyle = "rgba(0,0,0, 0.2)"; diff --git a/www/corelib/classes/UserStateWidgetClass.js b/www/corelib/classes/UserStateWidgetClass.js index 0ec16dd..50dc030 100644 --- a/www/corelib/classes/UserStateWidgetClass.js +++ b/www/corelib/classes/UserStateWidgetClass.js @@ -7,7 +7,7 @@ var UserStateWidgetClass = function(manager, args) }.extend(WidgetClass, { attach: function(){ - this.wCanvas = createCanvas("UserStateWidgetCanvas", 240, 80, 395, 5, 8, "MainArea"); + this.wCanvas = createCanvas("UserStateWidgetCanvas", 240, 80, 395, 5, 8, this.manager.mainArea); this.gContext = this.wCanvas.getContext('2d'); this.gContext.globalAlpha = 0.25; this.gContext.fillStyle = "rgba(255,240,200,0.5)"; diff --git a/www/corelib/core.js b/www/corelib/core.js index 589dcfa..5ec96c9 100644 --- a/www/corelib/core.js +++ b/www/corelib/core.js @@ -34,21 +34,48 @@ var URL_PCD_Auth = URL_PCD_Root + "auth.php"; var URL_PCD_Audio = URL_PCD_Root + "audio/"; var URL_PCD_Stage = URL_PCD_Root + "stage/"; +// ゲームを呼び出す関数 適切なdiv要素で呼び出すとゲームを初期化できる。 +// つまり、自作ゲームをしたい場合 +// audio, corelib, images, stageの各フォルダをコピーしたdirにhtmlを置き、
.InitGameManager() と実行するスクリプトを書く +// stageName == nullだとステージを開始しない。指定する時は.jsおよびパスを省く + +HTMLDivElement.prototype.InitGameManager = function(stageName) +{ + if(this instanceof HTMLDivElement) + { + var man = new GameManager(this, null); + if(stageName) man.loadStageFromNetwork.apply(man, [stageName]); + return man; + }else + { + throw new TypeError("InitGameManager はdiv要素にしか実行できません"); + } +}; + // //ゲームマネージャー // -function GameManager(){ +function GameManager(parent, debugTextName){ + + //引数チェック + if(debugTextName == undefined) debugTextName = "DebugText"; + if(parent == undefined) parent = document.getElementById("MainArea"); + this.userID = 0; //サブマネージャーの設定 this.networkManager = new NetworkManager(this); this.UIManager = new UIManager(this); this.userManager = new UserManager(this); + this.mainArea = parent; //必要最低限のCanvasとコンテキストの設定 - this.mainCanvas = createCanvas("MainCanvas", 640, 480, 0, 0, 1, "MainArea"); + this.mainCanvas = createCanvas("MainCanvas", 640, 480, 0, 0, 1, parent); this.mainCanvas.style.border = "solid 1px"; this.mainContext = this.mainCanvas.getContext('2d'); - this.debugText = document.getElementById('DebugText'); + this.debugText = document.getElementById(debugTextName); //要素が存在しないとnullになり、デバッグが無効になる + if(!this.debugText) this.debugText = null; + + //ブラウザチェック this.isIE = false; if(!this.isAvailableBrowser()){ @@ -209,13 +236,16 @@ GameManager.prototype = { } }, debugOut: function(str){ - if(this.isIE) + if(this.debugText != null) { - //CRLF - this.debugText.value = str.replace(/\n/g,"\r\n") + this.debugText.value; - } else{ - //LF - this.debugText.innerHTML = str + this.debugText.value; + if(this.isIE) + { + //CRLF + this.debugText.value = str.replace(/\n/g,"\r\n") + this.debugText.value; + } else{ + //LF + this.debugText.innerHTML = str + this.debugText.value; + } } }, isAvailableBrowser: function(){ diff --git a/www/corelib/coresubf.js b/www/corelib/coresubf.js index 060488e..eb5d1e4 100644 --- a/www/corelib/coresubf.js +++ b/www/corelib/coresubf.js @@ -12,10 +12,9 @@ function createCanvas(id, width, height, x, y, z, parent) //(x,y,z)に生成する。 //parentには、Canvasタグを包含することになるDOMオブジェクトのidを指定する。 canvas = document.createElement("canvas"); - parent = document.getElementById(parent); canvas.id = id; - + parent.appendChild(canvas); canvas.style.position = "absolute"; diff --git a/www/editor/editor.html b/www/editor/index.html similarity index 86% rename from www/editor/editor.html rename to www/editor/index.html index 5fe31ff..944a8d0 100644 --- a/www/editor/editor.html +++ b/www/editor/index.html @@ -33,6 +33,7 @@ html,body{ height: 100%; padding-bottom: 36px; margin-bottom: -36px; + overflow: hidden; } @@ -103,6 +104,12 @@ window.onload = function(){ initDrop(); resize(); + var oldData = localStorage.getItem("savedat"); + if(oldData) + { + $('#textarea textarea').val(oldData); + } + $('#textarea textarea').change(function(){ isModified = true; }); @@ -188,6 +195,32 @@ function run() window.open("../index_local_debug.html"); } +function editInTextEditor() +{ + if(!_guiMode) return; + $('#guiWindow').fadeOut(); + $('#textWindow').fadeIn(); + _guiMode = false; +} + +function editInGui() +{ + if(_guiMode) return; + textToGui(); + $('#guiWindow').fadeIn(); + $('#textWindow').fadeOut(); + _guiMode = true; +} + +var _guiStageInfo = null; +var _guiMode = false; +function textToGui() +{ + //eval($("#textarea textarea").val()); + //_guiStageInfo = stgInfo; + //$('#editorMessageBox').text("Stage Size : (" + stgInfo.width + ", " + stgInfo.height + ") "); +} + $(window).bind("resize", resize); @@ -199,13 +232,23 @@ $(window).bind("resize", resize); 名前を付けて保存 ブラウザから開く ブラウザに保存 - GUI編集 - テキスト編集 + GUI編集 + テキスト編集 実行 ヘルプ
- +
+ テンプレート
+
+ ステージ
+
+
+
+ エディット +
+
+
@@ -316,7 +359,8 @@ stage;

開く項目の選択

操作する項目:

- +
+ ※savedat という名前の項目は次回起動時に自動的に開かれます
\ No newline at end of file diff --git a/www/editor/readme.txt b/www/editor/readme.txt index 031ff6b..24a3c48 100644 --- a/www/editor/readme.txt +++ b/www/editor/readme.txt @@ -1,6 +1,9 @@ PCDSLを快適に編集できるエディタです ※UTF-8専用 +※ブラウザに保存する時「savedat」という名前で保存すると次回起動時に自動で読み込まれます +※(「savedat」の削除は「ブラウザから開く」で行えます) + コマンド一覧 ・開く diff --git a/www/index_local_debug.html b/www/index_local_debug.html index 3dc9435..fdaca0d 100644 --- a/www/index_local_debug.html +++ b/www/index_local_debug.html @@ -18,6 +18,7 @@ @@ -60,102 +72,9 @@ function save()
-
-
-
- -
- ※すべてのコードを消したうえでセーブし更新すると最初のコードに戻ります。 -
+
+
+
\ No newline at end of file