Skip to content

Instantly share code, notes, and snippets.

@lvzixun
Forked from xebecnan/.vimrc
Last active December 28, 2016 08:06
Show Gist options
  • Save lvzixun/b240054bef9de534c21eb08a64ec1ffc to your computer and use it in GitHub Desktop.
Save lvzixun/b240054bef9de534c21eb08a64ec1ffc to your computer and use it in GitHub Desktop.
"HYDRA : OPEN LR UI RES EDITOR {
nmap <C-k> yiw:silent !call-hydra.sh <C-r>"<CR>
"}
#!/bin/bash
echo $LR_ARNAN_HYDRA_WORD:$* | nc -u -w1 $LR_ARNAN_HYDRA_HOST $LR_ARNAN_HYDRA_PORT
# coding: utf8
import os
import time
import socket
from subprocess import Popen
from openui import openui
HOST = '0.0.0.0'
PORT = 20127
# CWD = r'..\client\platform\mingw\build'
CWD = r'build'
BIN = r'lr.exe'
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))
print 'waiting on port:', PORT
while 1:
data, addr = s.recvfrom(1024)
if len(data) < 512 and data.startswith('hydrarnan:'):
print time.strftime('%Y-%m-%d %H:%M:%S'), '**** recv command ****'
head, body = data.strip().split(':', 1)
print body
openui(body)
else:
print time.strftime('%Y-%m-%d %H:%M:%S'), 'ERROR'
print data
os.system('pause')
if __name__ == '__main__':
main()
# coding: utf8
import os
import sys
import re
from subprocess import Popen
DATA_ROOT = r'D:\dev\lr\rawres\res_ui\data\editor_data' + '\\'
EDITOR_ROOT = ur'D:\dev\dev_coco\设计文档\svn\editors'.encode('cp936')
LOCAL_DIR = r'..\rawres\res_ui\output\pc\ui.lua'
def call_editor(exe, arg):
cwd = os.getcwd()
os.chdir(EDITOR_ROOT)
Popen([exe, arg])
os.chdir(cwd)
def openui(name):
with open(LOCAL_DIR, 'r') as f:
c = f.read()
cex = re.compile(r'\n\texport = "{}"'.format(name))
cfi = re.compile(r'\n\t-- file: (.*?)\n')
for m in re.finditer(r'\n{\n.*?\n},', c, re.S):
e = m.group()
mex = cex.search(e)
if not mex:
continue
mfi = cfi.search(e)
if not mfi:
continue
path = mfi.group(1)
# easyui
mui = re.match(r'^(.*)_wrapper_complex\[gen\]\.json$', path)
if mui:
final = DATA_ROOT + mui.group(1) + '_uiwnd.json'
call_editor('easyui.exe', final)
break
# easycomplex
mcx = re.match(r'^(.*)_complex\.json$', path)
if mcx:
final = DATA_ROOT + path
call_editor('easycomplex.exe', final)
break
# TODO: anim json
print 'unknown path type:', path
break
else:
print 'not found:', name
if __name__ == '__main__':
if len(sys.argv) == 2:
openui(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment