From: hikarupsp Date: Wed, 21 Aug 2013 17:08:28 +0000 (+0900) Subject: Merge commit 'c0ecce88cd8ecb7817b7283945e9f3e7315ccf5d' X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=076fc683a9a51943aafc52141c639e131575aa7e;hp=f1fc785c58bb54e108d19ae54cced0a00b0214f9;p=h58pcdgame%2FGameScriptCoreLibrary.git Merge commit 'c0ecce88cd8ecb7817b7283945e9f3e7315ccf5d' Conflicts: www/corelib/classes/BlockClass.js www/corelib/classes/StageObjectClass.js --- diff --git a/www/corelib/classes/GameStageClass.js b/www/corelib/classes/GameStageClass.js index 5104f82..55a21c8 100644 --- a/www/corelib/classes/GameStageClass.js +++ b/www/corelib/classes/GameStageClass.js @@ -112,7 +112,10 @@ GameStage.prototype = { //ƒLƒƒƒ“ƒoƒX‚ð‘SÁ‹Ž this.mainContext.clearRect(0, 0, this.mainCanvas.width, this.mainCanvas.height); } - this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height); + if(this.collisionMapContext) + { + this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height); + } }, runStage: function(){ //ƒXƒe[ƒW‰Šú‰»ˆ— @@ -122,7 +125,6 @@ GameStage.prototype = { this.collisionMapContext = this.collisionMapCanvas.getContext('2d'); this.collisionMapContext.fillStyle = "rgba(0,0,0, 0.2)"; this.collisionMapContext.strokeStyle = "rgba(0,0,0, 0.2)"; - this.collisionMapContext.scale(1, 1); }, stopStage: function(){ //ƒXƒe[ƒWI—¹ˆ— diff --git a/www/corelib/classes/HorizonalScrollStageClass.js b/www/corelib/classes/HorizonalScrollStageClass.js index b32fba6..97e914d 100644 --- a/www/corelib/classes/HorizonalScrollStageClass.js +++ b/www/corelib/classes/HorizonalScrollStageClass.js @@ -46,12 +46,14 @@ var HorizonalScrollStageClass = function() { this.mainContext.drawImage(this.background, pos, 0, 640, 480); } - }else - { + } else{ //ƒLƒƒƒ“ƒoƒX‚ð‘SÁ‹Ž this.mainContext.clearRect(0, 0, this.mainCanvas.width, this.mainCanvas.height); } - this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height); + if(this.collisionMapContext) + { + this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height); + } }, //ƒXƒNƒ[ƒ‹‚µ‚½‚¢‚Æ‚«‚ɁAtick–ˆ‚ɌĂԁB diff --git a/www/corelib/classes/OperatedCharacterClass.js b/www/corelib/classes/OperatedCharacterClass.js index 4132c5f..66325de 100644 --- a/www/corelib/classes/OperatedCharacterClass.js +++ b/www/corelib/classes/OperatedCharacterClass.js @@ -34,6 +34,7 @@ var OperatedCharacterClass = function(ownerStage, args){ }, //’ʏíƒWƒƒƒ“ƒv‚·‚é‚Æ‚«‚ɌĂ΂ê‚éBƒWƒƒƒ“ƒvƒL[‚ð‰Ÿ‚µ‚Ä‚¢‚éŠÔ‚Í‚¸‚Á‚ƌĂ΂ê‚é + //ƒWƒƒƒ“ƒvƒL[‚ð‰Ÿ‚µ‚Ä‚¢‚鎞ŠÔ‚Ì’·‚³‚ɉž‚¶‚ăWƒƒƒ“ƒv‚̍‚‚³‚ª•Ï‰»‚·‚éB jump : function(){ if((this.collideFlag & 4) != 0) { @@ -50,6 +51,8 @@ var OperatedCharacterClass = function(ownerStage, args){ } }, jumpEnd: function(){ + //ƒWƒƒƒ“ƒvƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚È‚¢ŠÔ‚Í‚±‚¿‚炪ŒÄ‚яo‚³‚ê‚éB + //ƒWƒƒƒ“ƒvƒL[‚ð‚²‚­’ZŽžŠÔ‰Ÿ‚µ‚½ê‡‚Å‚àA‚ ‚éˆê’è‚̍‚‚³‚܂ł̓Wƒƒƒ“ƒv‚·‚é‚悤‚É‚·‚邽‚߁B if(this.jumpPower_tickCount < this.jumpPower_tickCountBase - this.jumpPower_tickCountAtLeast){ this.jumpPower_tickCount = 0; } else{ diff --git a/www/corelib/core.js b/www/corelib/core.js index ab784ed..91b992b 100644 --- a/www/corelib/core.js +++ b/www/corelib/core.js @@ -66,6 +66,9 @@ function GameManager(parent, debugTextName){ if(debugTextName == undefined) debugTextName = "DebugText"; if(parent == undefined) parent = document.getElementById("MainArea"); + //parentの初期設定 + if(parent.style.position != 'absolute') parent.style.position = 'relative'; + this.userID = 0; //サブマネージャーの設定 this.networkManager = new NetworkManager(this); @@ -78,7 +81,6 @@ function GameManager(parent, debugTextName){ this.mainContext = this.mainCanvas.getContext('2d'); this.debugText = document.getElementById(debugTextName); //要素が存在しないとnullになり、デバッグが無効になる if(!this.debugText) this.debugText = null; - //ブラウザチェック this.isIE = false; diff --git a/www/editor/index.html b/www/editor/index.html index d6389c1..aacaf58 100644 --- a/www/editor/index.html +++ b/www/editor/index.html @@ -116,6 +116,14 @@ window.onload = function(){ }; +window.onbeforeunload = function(e) { + if(isModified) + { + e = e || window.event; + return e.returnValue = '変更が保存されていません。破棄されますが続行しますか?'; + } +}; + function openFile() { if(isModified) @@ -206,21 +214,176 @@ function editInTextEditor() function editInGui() { if(_guiMode) return; - textToGui(); - $('#guiWindow').fadeIn(); - $('#textWindow').fadeOut(); - _guiMode = true; + if(textToGui()) //gui移行に成功したら + { + $('#guiWindow').fadeIn(); + $('#textWindow').fadeOut(); + _guiMode = true; + } } var _guiStageInfo = null; +var _guiTbl = null; +var _guiElements = null; var _guiMode = false; function textToGui() { - //eval($("#textarea textarea").val()); - //_guiStageInfo = stgInfo; - //$('#editorMessageBox').text("Stage Size : (" + stgInfo.width + ", " + stgInfo.height + ") "); + try{ + var code = $("#textarea textarea").val(); + + // tblの取得 + var tblStart = code.indexOf("with(stgObjects)") + 16; + if(tblStart == -1) return false; + var tblLength = exploreEndParen(code.slice(tblStart)); + if(tblLength == -1) return false; + var tblCode = "with(stgObjects)" + code.slice(tblStart, tblStart + tblLength); + + // evalのための定義 + var stgObjects = {a:"a",b:"b",c:"c",d:"d",e:"e",f:"f",g:"g",h:"h",i:"i",j:"j",k:"k",l:"l",m:"m",n:"n",o:"o",p:"p",q:"q",r:"r",s:"s",t:"t",u:"u",v:"v",w:"w",x:"x",y:"y",z:"z",_:"_"}; + eval(tblCode); //これでtblにテーブルデータが入る + if(!tbl) return false; + _guiTbl = tbl; //_guiTbl に代入 + + // stgInfoの取得 + var infoStart = code.indexOf("var stgInfo"); + if(infoStart == -1) return false; + var infoLength = exploreEndParen(code.slice(infoStart)); + if(infoLength == -1) return false; + var infoCode = code.slice(infoStart, infoStart + infoLength); + eval(infoCode); + if(!stgInfo) return false; + _guiStageInfo = stgInfo; + if(!stgInfo.width) return false; + if(!stgInfo.height) return false; + + + //作業領域の描画 + var area = document.getElementById("editorBox"); + $('#editorBox > div').remove(); + _guiElements = []; + for(var y = 0; y < stgInfo.height / 32; y++) + { + _guiElements[y] = []; + for(var x = 0; x < stgInfo.width / 32; x++) + { + var element = document.createElement('div'); + element.style.position = "absolute"; + element.style.top = (y * 32) + "px"; + element.style.left = (x * 32) + "px"; + element.style.width = element.style.height = "32px"; + element.style.border = "1px white solid"; + element.style.backgroundColor = "black"; + element.style.color = "white"; + + _guiElements[y][x] = element; + area.appendChild(element); + eval("func = function(){guiElementClickEvent(" + x + ", " + y + ");};"); + element.addEventListener("click", func); + } + } + + for(var y = 0; y < _guiTbl.length; y++) + { + for(var x = 0; x < _guiTbl[y].length; x++) + { + if(_guiElements[y] && _guiElements[y][x]) + { + $(_guiElements[y][x]).text(_guiTbl[y][x] != "_" ? _guiTbl[y][x] : ""); + }else + { + window.alert("tbl[]のサイズがステージのサイズをオーバーしています"); + return false; + } + } + } + + + + + return true; + }catch(e) + { + window.alert("error : " + e); + return false; + } +} + +function guiElementClickEvent(x,y) +{ + var val = $('#stageBox input:radio:checked').val(); + if(val == "addr") + { + window.alert("位置(" + x + ", " + y + ")\n座標(" + (x * 32) + ", " + (y * 32) + ")"); + }else + { + $(_guiElements[y][x]).text(val); + _guiTbl[y][x] = val; + GuiToText(); + } +} + +function GuiToText() +{ + var code = $("#textarea textarea").val(); + var tblCode = "with(stgObjects){\n\tvar tbl = [\n"; + for(var y = 0; y < _guiStageInfo.height / 32; y++) + { + tblCode += "\t\t["; + if(_guiTbl[y]) + { + for(var x = 0; x < _guiStageInfo.width / 32; x++) + { + if(_guiTbl[y][x]) + { + tblCode += _guiTbl[y][x]; + }else + { + tblCode += " "; + } + tblCode += ","; + } + if(tblCode.slice(tblCode.length - 1) == ",") tblCode = tblCode.slice(0, tblCode.length - 1); + } + tblCode += "],\n"; + } + if(tblCode.slice(tblCode.length - 3) == "],\n") tblCode = tblCode.slice(0, tblCode.length - 2) + "\n"; + tblCode += "\t];\n"; + tblCode += "}"; + var tblStart = code.indexOf("with(stgObjects)"); + if(tblStart == -1) return false; + var tblLength = exploreEndParen(code.slice(tblStart + 16)) + 16; + if(tblLength == 15) return false; + + code = code.slice(0, tblStart) + tblCode + code.slice(tblStart + tblLength); + $("#textarea textarea").val(code); + + isModified = true; + return true; } +// 最後にカッコが閉じて最初と同じレベルに到達するまでのインデックスを返す。カッコが閉じられずに終わったら(もしくは急に閉じかっこが出てきたら)-1 +function exploreEndParen(text) +{ + var nest = 0; + + for(var i = 0; i < text.length; i++) + { + if(text[i] == '{' || text[i] == '(' || text[i] == '[') nest++; + else if(text[i] == '}' || text[i] == ')' || text[i] == ']') + { + nest--; + if(nest < 0) //開始カッコがないのに急に終了カッコが出てきた + { + return -1; + }else if(nest == 0) + { + return i + 1; //カッコの後ろまで含める + } + } + } + + return nest != 0 ? -1 : i; +} $(window).bind("resize", resize); @@ -232,7 +395,7 @@ $(window).bind("resize", resize); 名前を付けて保存 ブラウザから開く ブラウザに保存 - GUI編集 + GUI編集 テキスト編集 実行 ヘルプ @@ -243,11 +406,40 @@ $(window).bind("resize", resize); テンプレート
ステージ
-
+
+ (座標の取得)
+ _
+ a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
+ j
+ k
+ l
+ m
+ n
+ o
+ p
+ q
+ r
+ s
+ t
+ u
+ v
+ w
+ x
+ y
+ z
+
エディット -
+
diff --git a/www/index.html b/www/index.html index cbfbe30..91281ce 100755 --- a/www/index.html +++ b/www/index.html @@ -20,10 +20,10 @@ onload = function() { -
+
- +
\ No newline at end of file diff --git a/www/index_local_debug.html b/www/index_local_debug.html index de31e7c..e5f38db 100644 --- a/www/index_local_debug.html +++ b/www/index_local_debug.html @@ -74,9 +74,9 @@ function switchDebug() -
+
-
+