diff --git a/.gitignore b/.gitignore index 7ae4cf2d..d742b1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.vscode + # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 diff --git a/[start server.cmd b/[start server.cmd new file mode 100644 index 00000000..814d7527 --- /dev/null +++ b/[start server.cmd @@ -0,0 +1 @@ +python _server.py \ No newline at end of file diff --git a/_server.py b/_server.py new file mode 100644 index 00000000..e2955bc1 --- /dev/null +++ b/_server.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +import json +import socket +import threading +import os +import time + +def httpserver(port = 7945): + import http.server + http.server.test(http.server.SimpleHTTPRequestHandler,port=port) + +def voidfunc(*a,**k): + pass +sysecho=print +mecho=voidfunc + +homepage='homepage' +strtemplate='HTTP/1.0 302 Move temporarily\r\nContent-Length: 0\r\nLocation: {urlstr}\r\n\r\n' #{urlstr} + +def mainget(urlstr): + funcAfter=lambda:0 + if False and urlstr == '/': + sysecho(''.join([ + 'GET / ',addr[0],':',str(addr[1]) + ])) + return (200,homepage,funcAfter) + if True: + return (strtemplate.format(urlstr='//127.0.0.1:7945'+urlstr),'',funcAfter) + return (404,'404') + +def mainpost(urlstr,body): + funcAfter=lambda:0 + if urlstr == '/': + out='name not match' + try: + op=json.loads(body) + name=op['name'] + op['func'] + op['args'] + except Exception as e: + return (200,'error format') + if name=='readUTF8file' and op['func']=='open': + with open('./'+op['args'][0],encoding='utf-8') as fid: + out=fid.read() + if name=='writeUTF8file' and op['func']=='open': + with open('./'+op['args'][0],'w',encoding='utf-8') as fid: + out=str(fid.write(op['args'][1])) + return (200,out,funcAfter) + return (403,'no service this url') + +def mainparse(header,body): + funcAfter=lambda:0 + for _tmp in [1]: + if header[:3]=='GET': + urlstr=header.split(' ',2)[1] + mainre = mainget(urlstr) + if len(mainre)==2: + header,body=mainre + else: + header,body,funcAfter=mainre + break + if header[:4]=='POST': + urlstr=header.split(' ',2)[1] + mainre = mainpost(urlstr,body) + if len(mainre)==2: + header,body=mainre + else: + header,body,funcAfter=mainre + break + if header=='': + header,body= (403,'') + break + header,body= (403,'') + body=body.encode('utf-8') + if type(header)==int: + codeDict={200:'200 OK',302:'302 Move temporarily',403:'403 Forbidden',404:'404 Not Found'} + header=('HTTP/1.0 {statu}\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: '.format(statu=codeDict[header])+str(len(body))+'\r\nAccess-Control-Allow-Origin: *\r\n\r\n') + #\r\nAccess-Control-Allow-Origin: * null : to test in chrome + header=header.encode('utf-8') + return (header,body,funcAfter) + +def tcplink(sock, addr): + mecho('\n\nAccept new connection from %s:%s...' % addr) + tempbuffer = [''] + data='' + header='' + body='' + while True: + d = sock.recv(512) + if d: + d=d.decode('utf-8') + tempbuffer.append(d) + tempend=tempbuffer[-1][-4:]+d + if '\r\n\r\n' in tempend: + headend=True + data=''.join(tempbuffer) + header, body = data.split('\r\n\r\n', 1) + if header[:3]=='GET': + tempbuffer=[] + break + tempbuffer=[body] + a=int(header.split('Content-Length:',1)[1].split('\r\n',1)[0])-len(body.encode('utf-8'))#str.len not equal byte.len + while a>0: + tempbuffer.append(sock.recv(min(a,512)).decode('utf-8')) + a=a-min(a,512) + break + else: + break + mecho('recv end\n===') + body = ''.join(tempbuffer) + mecho(header) + mecho('---') + if len(body)>250: + mecho(body[:100]) + mecho('...\n') + mecho(body[-100:]) + else: + mecho(body) + if True: + header,body,funcAfter=mainparse(header,body) + mecho('===\nsend start\n') + sock.send(header) + sock.send(body) + mecho('\nsend end\n===') + sock.close() + mecho('Connection from %s:%s closed.' % addr) + funcAfter() + +if __name__ == '__main__': + out = threading.Thread(target=httpserver) + out.start() + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind(('127.0.0.1', 80)) + s.listen(500) + sysecho('Waiting for connection...') + os.popen('explorer http://127.0.0.1:7945/drawMapGUI.html') + while True: + sock, addr = s.accept() + t = threading.Thread(target=tcplink, args=(sock, addr)) + t.start() \ No newline at end of file diff --git a/docs/event.md b/docs/event.md index 39deb83c..a64a5d09 100644 --- a/docs/event.md +++ b/docs/event.md @@ -745,10 +745,10 @@ core.insertAction(list) //往当前事件列表中插入一系列事件。使用 {"text": "攻击+4", "effect": "status:atk+=4"}, {"text": "防御+4", "effect": "status:def+=4"}, {"text": "魔防+10", "effect": "status:mdef+=10"} - // effect只能对status和items进行操作,不能修改flag值。且其中间只能用+=符号(也就是只能增加某个属性或道具) + // effect只能对status和item进行操作,不能修改flag值。且其中间只能用+=符号(也就是只能增加某个属性或道具) // 其他effect样例: - // "items:yellowKey+=1" 黄钥匙+1 - // "items:pickaxe+=3" 破墙镐+3 + // "item:yellowKey+=1" 黄钥匙+1 + // "item:pickaxe+=3" 破墙镐+3 ] }, "expShop1": { // 商店唯一ID diff --git a/drawMapGUI.html b/drawMapGUI.html new file mode 100644 index 00000000..574817a8 --- /dev/null +++ b/drawMapGUI.html @@ -0,0 +1,617 @@ + + + + + + + +
+
+ +

可以在console中通过printf(str)来改变这里的值

+ +
+
+
+ + + + +
+
+ + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/images/animates.png b/images/animates.png index 01ff9157..c1c1cb1a 100644 Binary files a/images/animates.png and b/images/animates.png differ diff --git a/libs/core.js b/libs/core.js index ea87f19e..db2560fc 100644 --- a/libs/core.js +++ b/libs/core.js @@ -3033,8 +3033,9 @@ core.prototype.resize = function(clientWidth, clientHeight) { var BASE_LINEHEIGHT = 32; var SPACE = 3; var DEFAULT_FONT_SIZE = 16; - //适配宽度阈值 + //适配宽度 422 var ADAPT_WIDTH = DEFAULT_CANVAS_WIDTH; + var CHANGE_WIDTH = DEFAULT_CANVAS_WIDTH+DEFAULT_BAR_WIDTH; //判断横竖屏 var width = clientWidth; var isHorizontal = false; @@ -3057,23 +3058,30 @@ core.prototype.resize = function(clientWidth, clientHeight) { if (!core.flags.enableDebuff) count--; var statusLineHeight = BASE_LINEHEIGHT * 9/count; - + var shopDisplay, mdefDisplay, expDisplay; mdefDisplay = core.flags.enableMDef ? 'block' : 'none'; expDisplay = core.flags.enableExperience ? 'block' : 'none'; statusBarBorder = '3px #fff solid'; toolBarBorder = '3px #fff solid'; + var zoom = (ADAPT_WIDTH - width) / 4.22; + var aScale = 1 - zoom / 100; + // 移动端 - if (width < ADAPT_WIDTH) { - var zoom = (ADAPT_WIDTH - width) / 4.22; - var scale = 1 - zoom / 100; - - core.domStyle.scale = scale; - - canvasWidth = width; + if (width < CHANGE_WIDTH) { + if(width < ADAPT_WIDTH){ + + core.domStyle.scale = aScale; + canvasWidth = width; + }else{ + canvasWidth = DEFAULT_CANVAS_WIDTH; + core.domStyle.scale = 1; + } + + var scale = core.domStyle.scale + var tempWidth = DEFAULT_CANVAS_WIDTH * scale; fontSize = DEFAULT_FONT_SIZE * scale; - if(!isHorizontal){ //竖屏 core.domStyle.screenMode = 'vertical'; //显示快捷商店图标 @@ -3083,14 +3091,14 @@ core.prototype.resize = function(clientWidth, clientHeight) { var tempTopBarH = scale * (BASE_LINEHEIGHT * col + SPACE * 2) + 6; var tempBotBarH = scale * (BASE_LINEHEIGHT + SPACE * 4) + 6; - - gameGroupHeight = width + tempTopBarH + tempBotBarH; - gameGroupWidth = width + gameGroupHeight = tempWidth + tempTopBarH + tempBotBarH; + + gameGroupWidth = tempWidth canvasTop = tempTopBarH; // canvasLeft = 0; - toolBarWidth = statusBarWidth = width; - statusBarHeight = tempTopBarH; //一共有3行加上两个padding空隙 + toolBarWidth = statusBarWidth = canvasWidth; + statusBarHeight = tempTopBarH; statusBarBorder = '3px #fff solid'; statusHeight = scale*BASE_LINEHEIGHT * .8; @@ -3098,7 +3106,7 @@ core.prototype.resize = function(clientWidth, clientHeight) { statusMaxWidth = scale * DEFAULT_BAR_WIDTH * .95; toolBarHeight = tempBotBarH; - toolBarTop = statusBarHeight + width; + toolBarTop = statusBarHeight + canvasWidth; toolBarBorder = '3px #fff solid'; toolsHeight = scale * BASE_LINEHEIGHT; toolsPMaxwidth = scale * DEFAULT_BAR_WIDTH * .4; @@ -3109,8 +3117,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { }else { //横屏 core.domStyle.screenMode = 'horizontal'; shopDisplay = 'none'; - gameGroupWidth = width + DEFAULT_BAR_WIDTH * scale; - gameGroupHeight = width; + gameGroupWidth = tempWidth + DEFAULT_BAR_WIDTH * scale; + gameGroupHeight = tempWidth; canvasTop = 0; // canvasLeft = DEFAULT_BAR_WIDTH * scale; toolBarWidth = statusBarWidth = DEFAULT_BAR_WIDTH * scale; @@ -3119,7 +3127,7 @@ core.prototype.resize = function(clientWidth, clientHeight) { statusHeight = scale*statusLineHeight * .8; statusLabelsLH = .8 * statusLineHeight *scale; - toolBarHeight = width - statusBarHeight; + toolBarHeight = canvasWidth - statusBarHeight; toolBarTop = scale*statusLineHeight * count + SPACE * 2; toolBarBorder = '3px #fff solid'; toolsHeight = scale * BASE_LINEHEIGHT; diff --git a/libs/data.js b/libs/data.js index 7916671f..f298e063 100644 --- a/libs/data.js +++ b/libs/data.js @@ -56,11 +56,11 @@ data.prototype.init = function() { {"text": "攻击+4", "effect": "status:atk+=4"}, {"text": "防御+4", "effect": "status:def+=4"}, {"text": "魔防+10", "effect": "status:mdef+=10"} - // effect只能对status和items进行操作,不能修改flag值。 + // effect只能对status和item进行操作,不能修改flag值。 // 中间只能用+=符号(也就是只能增加某个属性或道具) // 其他effect样例: - // "items:yellowKey+=1" 黄钥匙+1 - // "items:pickaxe+=3" 破墙镐+3 + // "item:yellowKey+=1" 黄钥匙+1 + // "item:pickaxe+=3" 破墙镐+3 ] }, "expShop1": { // 商店唯一ID