#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
#-------------------------------------------------------------------------------
|
#
|
|
import mylog
|
from DBCommon import error
|
import GameWorld
|
import time
|
|
def EncodingToUnicode(srcEncoding, input):
|
try:
|
result = unicode(input, srcEncoding) #translate to utf-8
|
except:
|
msg = error.formatMsg('error', error.ERROR_NO_5, 'encode error!srcEncoding = %s input = %s'%(srcEncoding, repr(input)))
|
mylog.error(msg)
|
return False, "error"
|
return True, result
|
|
def UnicodeToEncoding(dstEncoding, input):
|
try:
|
result = input.encode(dstEncoding)
|
except:
|
msg = error.formatMsg('error', error.ERROR_NO_6, 'encode error!dstEncoding = %s input = %s'%(dstEncoding, repr(input)))
|
mylog.error(msg)
|
return False, "Error"
|
return True, result
|
|
#²éÕÒStructure¶ÔÏóµÄ×Ö¶Î,´óСдÃô¸Ð
|
def hasField(structObj, name):
|
for field in structObj._fields_:
|
fieldName = field[0]
|
if fieldName == name:
|
return True
|
return False
|
|
def LoadLibraryEx(DllName):
|
"DLL Load ,return the handle of the dll or None"
|
from ctypes import windll
|
try:
|
return windll.LoadLibrary(DllName)
|
except WindowsError:
|
return None
|
return None
|
|
#µ¯¿òÀàÐÍ
|
MB_OK = 0
|
MB_OKCANCEL = 1
|
MB_ABORTRETRYIGNORE = 2
|
MB_YESNOCANCEL = 3
|
MB_YESNO = 4
|
MB_RETRYCANCEL = 5
|
MB_ICONHAND = 16
|
MB_ICONQUESTION = 32
|
MB_ICONEXCLAMATION = 48
|
MB_ICONASTERISK = 64
|
MB_ICONWARNING = MB_ICONEXCLAMATION
|
MB_ICONERROR = MB_ICONHAND
|
MB_ICONINFORMATION = MB_ICONASTERISK
|
MB_ICONSTOP = MB_ICONHAND
|
MB_DEFBUTTON1 = 0
|
MB_DEFBUTTON2 = 256
|
MB_DEFBUTTON3 = 512
|
MB_DEFBUTTON4 = 768
|
MB_APPLMODAL = 0
|
MB_SYSTEMMODAL = 4096
|
MB_TASKMODAL = 8192
|
MB_HELP = 16384
|
MB_NOFOCUS = 32768
|
MB_SETFOREGROUND = 65536
|
MB_DEFAULT_DESKTOP_ONLY = 131072
|
MB_TOPMOST = 262144
|
MB_RIGHT = 524288
|
MB_RTLREADING = 1048576
|
MB_SERVICE_NOTIFICATION = 2097152
|
MB_TYPEMASK = 15
|
MB_USERICON = 128
|
MB_ICONMASK = 240
|
MB_DEFMASK = 3840
|
MB_MODEMASK = 12288
|
MB_MISCMASK = 49152
|
# def MessageBox(title,msg,stype):
|
# # import win32api,win32gui
|
# # import win32con,winerror,win32event,pywintypes
|
# # ct = win32api.GetConsoleTitle()
|
# # hd = win32gui.FindWindow(0,ct)
|
# # win32api.MessageBox(hd,msg,title,win32con.MB_OK)
|
# hd = LoadLibraryEx("user32.dll")
|
# if hd is not None:
|
# return hd.MessageBoxA(0,msg,title,stype)
|
|
#½«¸¡µãÊýת»¯³É×Ö·û´®¸ñʽ
|
g_dllTDateTimeFunc = None
|
def TDateTimeToString(dTime):
|
return GameWorld.ChangeTimeNumToStr(dTime)
|
|
|
#·µ»ØÖµÎªDelphiµÄTDateTime£¬¼´doubleÀàÐ͵ÄNow()º¯Êý
|
def TDateTime_Now():
|
return time.time()
|
|
|
|
|