rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if waited < timeout: waited += wait_interval time.sleep(wait_interval)
waited = time.time() - start if waited < timeout: time.sleep(min(wait_interval, timeout - waited))
def _resolve_control(criteria_, timeout = 0, wait_interval = .2): """Find a control using criteria :criteria: - a list that contains 1 or 2 dictionaries 1st element is search criteria for the dialog 2nd element is the search criteria for a control of the dialog :timeout: - maximum length of time to try to find the co...
self.start_(*args, **kwargs)
return self.start_(*args, **kwargs)
def _start(self, *args, **kwargs): "start_ used to be named _start" message = "_start and _connect are deprecated " \ "please use start_ and connect_" warnings.warn(message, DeprecationWarning) self.start_(*args, **kwargs)
self.connect_(*args, **kwargs)
return self.connect_(*args, **kwargs)
def _connect(self, *args, **kwargs): "connect_ used to be named _connect" message = "_start and _connect are deprecated " \ "please use start_ and connect_" warnings.warn(message, DeprecationWarning) self.connect_(*args, **kwargs)
'Error returned by CreateProcess: ' + str(ctypes.WinError())
'Error returned by CreateProcess: '%(cmd_line) \ + str(ctypes.WinError())
def start_(self, cmd_line, timeout = app_start_timeout): "Starts the application giving in cmd_line"
raise AttributeError(self.criteria[-1]['best_match'])
raise AttributeError( "WindowSpecification class has no '%s' method" % self.criteria[-1]['best_match'])
def __call__(self, *args, **kwargs): "No __call__ so return a usefull error"
if len(self.criteria) < 2: self.criteria.append(criteria) else: self.criteria[1] = criteria return self
new_item = WindowSpecification(self.criteria[0]) new_item.criteria.append(criteria) return new_item
def window_(self, **criteria): "Add the criteria that will be matched when we resolve the control"
self.app1.UntitledNotepad.SetFocus()
def testBug1452832(self): "Failing test for sourceforge bug 1452832" typetext(self.app1, "some text") self.app1.UntitledNotepad.SetFocus() copytext(self.app1)
data = GetData() self.assertEquals(data, "some text")
def testBug1452832(self): "Failing test for sourceforge bug 1452832" typetext(self.app1, "some text") self.app1.UntitledNotepad.SetFocus() copytext(self.app1)
self.app2.UntitledNotepad.SetFocus() self.app2.UntitledNotepad.SetFocus()
def testBug1452832(self): "Failing test for sourceforge bug 1452832" typetext(self.app1, "some text") self.app1.UntitledNotepad.SetFocus() copytext(self.app1)
ret = win32functions.VirtualFreeEx( self.process, self.memAddress, 0, win32defines.MEM_RELEASE) if not ret: raise ctypes.WinError()
if self.process: ret = win32functions.VirtualFreeEx( self.process, self.memAddress, 0, win32defines.MEM_RELEASE) if not ret: raise ctypes.WinError()
def __del__(self): "Ensure that the memory is Freed" # Free the memory in the remote process's address space ret = win32functions.VirtualFreeEx( self.process, self.memAddress, 0, win32defines.MEM_RELEASE)
print self.SendMessage(
self.SendMessage(
def PressButton(self, button_identifier): "Find where the button is and click it"
remote_mem = _RemoteMemoryBlock(self) tipinfo = win32structures.TOOLINFOW() tipinfo.cbSize = ctypes.sizeof(tipinfo) ret = self.SendMessage( win32defines.TTM_ENUMTOOLSW, tip_index, remote_mem) if not ret: raise ctypes.WinError() remote_mem.Read(tipinfo) print tipinfo tipinfo.lpszText = remote_mem.Address() + \ ctyp...
return ToolTip(self, tip_index).text
def GetTipText(self, tip_index): "Return the text of the tooltip" remote_mem = _RemoteMemoryBlock(self) tipinfo = win32structures.TOOLINFOW() tipinfo.cbSize = ctypes.sizeof(tipinfo)
props['ItemCount'] = self.ItemCount() props['ColumnCount'] = self.ColumnCount() if props['ColumnCount'] == 0: props['ColumnCount'] = 1 props['ColumnWidths'] = [999, ]
def GetProperties(self): "Return the properties of the control as a dictionary" props = HwndWrapper.HwndWrapper.GetProperties(self)
remote_mem.Write(lvitem))
remote_mem.Address())
def Select(self, item): "Mark the item as selected"
def PartWidths(self):
def PartRightEdges(self):
def PartWidths(self): "Return the widths of the parts" remote_mem = _RemoteMemoryBlock(self)
def GetProperties(self): "Return the properties fo the StatusBar" props = HwndWrapper.GetProperties(self) props['BorderWidths'] = self.BorderWidths()
def Texts(self): "Return the texts for the control" texts = [self.Text()]
friendlyclassname = "ToolTips" windowclasses = ["tooltips_class32", ]
def GetProperties(self): "Return the properties for the ReBar" props = HwndWrapper.HwndWrapper.GetProperties(self) props['BandCount'] = self.NumBands()
super(ToolTipsWrapper, self).__init__(hwnd)
HwndWrapper.HwndWrapper.__init__(self, hwnd)
def __init__(self, hwnd): "Initialize the instance" super(ToolTipsWrapper, self).__init__(hwnd)
count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT, 0, 0)
count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT)
def _PlayWithToolTipControls(self): "Just playing for now!" # get the number of tooltips associated with the control count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT, 0, 0)
for i2 in range(0, count): tipinfo = win32structures.TOOLINFOW() tipinfo.cbSize = ctypes.sizeof(tipinfo) tipinfo.lpszText = remote_mem.Address() + \
tipinfo = win32structures.TOOLINFOW() tipinfo.cbSize = ctypes.sizeof(tipinfo) remote_mem.Write(tipinfo) ret = self.SendMessage( win32defines.TTM_ENUMTOOLSW, i, remote_mem.Address()) if not ret: raise ctypes.WinError() else: remote_mem.Read(tipinfo) tipinfo.lpszText = remote_mem.Address() + \
def _PlayWithToolTipControls(self): "Just playing for now!" # get the number of tooltips associated with the control count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT, 0, 0)
tipinfo.uId = i2
def _PlayWithToolTipControls(self): "Just playing for now!" # get the number of tooltips associated with the control count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT, 0, 0)
ret = self.SendMessage( win32defines.TTM_ENUMTOOLSW, i, remote_mem.Address()) if not ret: raise ctypes.WinError() else: remote_mem.Read(tipinfo) if tipinfo.lpszText in ( win32defines.LPSTR_TEXTCALLBACKW, 0, -1): pass else: try: text = ctypes.create_unicode_buffer(2000) remote_mem.Read(text, tipinfo.lpszText) ...
self.SendMessage(win32defines.TTM_GETTEXTW, 0, remote_mem.Address()) text = ctypes.create_unicode_buffer(200) remote_mem.Read(text, tipinfo.lpszText)
def _PlayWithToolTipControls(self): "Just playing for now!" # get the number of tooltips associated with the control count = self.SendMessage(win32defines.TTM_GETTOOLCOUNT, 0, 0)
if attr in self.__default_timing: return self._timings[attr]
if attr in TimeConfig.__default_timing: return TimeConfig._timings[attr]
def __getattr__(self, attr): "Get the value for a particular timing" if attr in self.__default_timing: return self._timings[attr] else: raise KeyError( "Unknown timing setting: %s" % attr)
if attr in self.__default_timing: self._timings[attr] = value
if attr in TimeConfig.__default_timing: TimeConfig._timings[attr] = value
def __setattr__(self, attr, value): "Set a particular timing" if attr in self.__default_timing: self._timings[attr] = value else: raise KeyError( "Unknown timing setting: %s" % attr)
for setting in self.__default_timing:
for setting in TimeConfig.__default_timing:
def Fast(self): """Set fast timing values
self._timings[setting] = min(1, self._timings[setting])
TimeConfig._timings[setting] = min(1, TimeConfig._timings[setting])
def Fast(self): """Set fast timing values
self._timings[setting] = 0
TimeConfig._timings[setting] = 0
def Fast(self): """Set fast timing values
self._timings[setting] = 0.001
TimeConfig._timings[setting] = 0.001
def Fast(self): """Set fast timing values
for setting in self.__default_timing:
for setting in TimeConfig.__default_timing:
def Slow(self): """Set slow timing values
self._timings[setting] = max( self.__default_timing[setting] * 10, self._timings[setting])
TimeConfig._timings[setting] = max( TimeConfig.__default_timing[setting] * 10, TimeConfig._timings[setting])
def Slow(self): """Set slow timing values
self._timings[setting] = max( self.__default_timing[setting] * 3, self._timings[setting])
TimeConfig._timings[setting] = max( TimeConfig.__default_timing[setting] * 3, TimeConfig._timings[setting])
def Slow(self): """Set slow timing values
self._timings[setting] = max( self.__default_timing[setting] * 3, self._timings[setting]) if self._timings[setting] < .2: self._timings[setting]= .2
TimeConfig._timings[setting] = max( TimeConfig.__default_timing[setting] * 3, TimeConfig._timings[setting]) if TimeConfig._timings[setting] < .2: TimeConfig._timings[setting]= .2
def Slow(self): """Set slow timing values
self._timings = self.__default_timing.copy()
TimeConfig._timings = TimeConfig.__default_timing.copy()
def Defaults(self): "Set all timings to the default time" self._timings = self.__default_timing.copy()
win32defines.TB_GETITEMRECT,
win32defines.TB_GETRECT,
def GetButtonRect(self, button_index): "Get the rectangle of a button on the toolbar"
band_info.pszText = remote_mem.Address() + \ ctypes.sizeof(band_info)
band_info.pszText = ctypes.c_long(remote_mem.Address() + \ ctypes.sizeof(band_info))
def GetBand(self, band_index): "Get a band of the ReBar control" remote_mem = _RemoteMemoryBlock(self)
remote_mem.Read(band_info.pszText, remote_mem.Address() + \
remote_mem.Read(band_info.text, remote_mem.Address() + \
def GetBand(self, band_index): "Get a band of the ReBar control" remote_mem = _RemoteMemoryBlock(self)
def Rectangle(self): "Return the rectangle of the item"
def Rectangle(self, text_area_rect = True): """Return the rectangle of the item If text_area_rect is set to False then it will return the rectangle for the whole item (usually left if 0). Defaults to True - which returns just the rectangle of the text of the item """
def Rectangle(self): "Return the rectangle of the item" remote_mem = _RemoteMemoryBlock(self.tree_ctrl)
win32defines.TVM_GETITEMRECT, 0, remote_mem)
win32defines.TVM_GETITEMRECT, text_area_rect, remote_mem)
def Rectangle(self): "Return the rectangle of the item" remote_mem = _RemoteMemoryBlock(self.tree_ctrl)
self.SendMessageTimeout( win32defines.TVM_EXPAND, win32defines.TVE_EXPAND, current_elem)
def GetItem(self, path): "Read the TreeView item"
def _make_valid_filename(filename): r"""Return a valid file name for the string passed in. Replaces any character in ``:\/*?"<>|`` with ``' for char in (' filename = filename.replace(char, ' return filename
def set_timing( win_find = 3, win_retry =.09, app_start = 10, exists = .5, exists_retry = .3, after_click = 0, after_menu = 0, after_sendkeys = .03, after_button_click = 0, after_close = .2): """Set the timing for various things :win_find: = 3 Max time to look for a window :win_retry: =.09 Retry interval when fin...
exists_criteria, exists_timeout, exists_retry_interval)
exists_criteria, timeout, exists_retry_interval)
def Exists(self, timeout = exists_timeout): "Check if the window exists"
findwindows.WindowNotFoundError, findbestmatch.MatchError), e:
findwindows.WindowNotFoundError, findbestmatch.MatchError):
def WaitNotEnabled(self, timeout = window_find_timeout, wait_interval = window_retry_interval): "Wait for the control to be disabled or not exist"
def ctrl_(self): "Allow the calling code to get the HwndWrapper object" return _resolve_control(self.criteria) def window_(self, **criteria): "Add the criteria that will be matched when we resolve the control" new_item = WindowSpecification(self.criteria[0]) new_item.criteria.append(criteria) return new_item def __...
def ctrl_(self): "Allow the calling code to get the HwndWrapper object" return _resolve_control(self.criteria)
ctrls = ctrl.Children() visible_text_ctrls = [ctrl for ctrl in ctrls if ctrl.IsVisible() and ctrl.WindowText()]
ctrls_to_print = ctrl.Children() dialog_controls = ctrl.Children()
def print_control_identifiers(self): """Prints the 'identifiers'
visible_text_ctrls = [ctrl for ctrl in ctrl.Parent().Children() if ctrl.IsVisible() and ctrl.WindowText()] ctrls = [ctrl] for ctrl in ctrls:
dialog_controls = ctrl.TopLevelParent().Children() ctrls_to_print = [ctrl] ctrls_to_print = [ctrl for ctrl in ctrls_to_print if ctrl.IsVisible()] for ctrl in ctrls_to_print:
def print_control_identifiers(self): """Prints the 'identifiers'
ctrl, visible_text_ctrls):
ctrl, dialog_controls):
def print_control_identifiers(self): """Prints the 'identifiers'
raise AppStartError("CreateProcess: " + str(ctypes.WinError()))
message = 'Could not create the process "%s"\n'\ 'Error returned by CreateProcess: ' + str(ctypes.WinError()) raise AppStartError(message)
def start_(self, cmd_line, timeout = app_start_timeout): "Starts the application giving in cmd_line"
if self.app_windows_():
if self.windows_():
def start_(self, cmd_line, timeout = app_start_timeout): "Starts the application giving in cmd_line"
else:
elif kwargs:
def connect_(self, **kwargs): "Connects to an already running process"
process_handle = win32functions.OpenProcess( 0x400 | 0x010, 0, process_id)
process_handle = AssertValidProcess(process_id)
def process_module(process_id): "Return the string module name of this process" # Set instance variable _module if not already set process_handle = win32functions.OpenProcess( 0x400 | 0x010, 0, process_id) # read and query info # get module name from process handle filename = (ctypes.c_wchar * 2000)() win32functions.G...
:ctrl: The dialog or control that owns this menu :menu: The menu that this item is on :index: The Index of this menuitem on the menu :on_main_menu: True if the item is on the main menu
* **ctrl** The dialog or control that owns this menu * **menu** The menu that this item is on * **index** The Index of this menuitem on the menu * **on_main_menu** True if the item is on the main menu
def __init__(self, ctrl, menu, index, on_main_menu = False): """Initalize the menu item
self.ctrl.NotifyMenuSelect(self.ID())
self.ctrl.SetFocus() self.ctrl.SendMessageTimeout( win32defines.WM_COMMAND, win32functions.MakeLong(0, self.ID()))
def Select(self): """Select the menu item
:owner_ctrl: is the Control that owns this menu :menuhandle: is the menu handle of the menu :is_main_menu: we have to track whether it is the main menu or a popup menu :owner_item: The item that contains this menu - this will be None for the main menu, it will be a MenuItem instance for a submenu.
* **owner_ctrl** is the Control that owns this menu * **menuhandle** is the menu handle of the menu * **is_main_menu** we have to track whether it is the main menu or a popup menu * **owner_item** The item that contains this menu - this will be None for the main menu, it will be a MenuItem instance for a submenu.
def __init__( self, owner_ctrl, menuhandle, is_main_menu = True, owner_item = None): """Initialize the class.
:index: is the 0 based index of the menu item you want
* **index** is the 0 based index of the menu item you want
def Item(self, index): """Return a specific menu item
closest = abs(text_r.left - ctrl_r.left)
def GetNonTextControlName(ctrl, text_ctrls): """return the name for this control by finding the closest text control above and to its left""" name = '' closest = distance_cuttoff # now for each of the visible text controls for text_ctrl in text_ctrls: # get aliases to the control rectangles text_r = text_ctrl.Rectang...
fontHandle = win32functions.SendMessage(handle, WM_GETFONT, 0, 0) if not fontHandle: fontHandle = win32functions.GetStockObject(SYSTEM_FONT);
fontHandle = win32functions.SendMessage(handle, WM_GETFONT, 0, 0) if not fontHandle: fontHandle = win32functions.GetStockObject(SYSTEM_FONT); font = win32structures.LOGFONTW() ret = win32functions.GetObject(fontHandle, sizeof(font), byref(font)) if not ret:
def font(handle): # set the font fontHandle = win32functions.SendMessage(handle, WM_GETFONT, 0, 0) # if the fondUsed is 0 then the control is using the # system font if not fontHandle: fontHandle = win32functions.GetStockObject(SYSTEM_FONT); # Get the Logfont structure of the font of the control font = win32structur...
ret = win32functions.GetObject(fontHandle, sizeof(font), byref(font)) if not ret: font = win32structures.LOGFONTW() if (has_style(handle, WS_OVERLAPPED) or \ has_style(handle, WS_CAPTION)) and \ not has_style(handle, WS_CHILD): if "MS Shell Dlg" in font.lfFaceName or font.lfFaceName == "System": ncms = win3...
if (has_style(handle, WS_OVERLAPPED) or \ has_style(handle, WS_CAPTION)) and \ not has_style(handle, WS_CHILD): if "MS Shell Dlg" in font.lfFaceName or font.lfFaceName == "System": ncms = win32structures.NONCLIENTMETRICSW() ncms.cbSize = sizeof(ncms) win32functions.SystemParametersInfo( SPI_GETNONCLIENTMETRICS, s...
def font(handle): # set the font fontHandle = win32functions.SendMessage(handle, WM_GETFONT, 0, 0) # if the fondUsed is 0 then the control is using the # system font if not fontHandle: fontHandle = win32functions.GetStockObject(SYSTEM_FONT); # Get the Logfont structure of the font of the control font = win32structur...
timeout = Timings.window_find_timout
timeout = Timings.window_find_timeout
def _resolve_from_appdata( criteria_, app, timeout = None, retry_interval = None): "Should not be used at the moment!" if timeout is None: timeout = Timings.window_find_timout if retry_interval is None: retry_interval = Timings.window_find_retry global cur_item # get the stored item corresponding to this request matc...
defaultOptionsDlg._write("DefaultOptions_%1.xml"%x)
defaultOptionsDlg._write("DefaultOptions_%d.xml"%x)
def get_winrar_dlgs(rar_dlg, x): rar_dlg.MenuSelect(t["Options->Configure"][x]) optionsdlg = rar_dlg.app[t['Configure'][x]] optionsdlg._write("Options_%d.xml"%x) optionsdlg.CaptureAsImage().save("Options_%d.png"%x) optionsdlg[t['Buttons'][x]].Click() contextMenuDlg = rar_dlg.app[t['PeronnaliseToolbars'][x]] contextMe...
itemVal = getattr(value, propName) if isinstance(itemVal, (int, long)):
item_val = getattr(value, propName) if isinstance(item_val, (int, long)):
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
itemVal = unicode(itemVal) structElem.set(propName, _EscapeSpecials(itemVal))
item_val = unicode(item_val) structElem.set(propName, _EscapeSpecials(item_val))
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
imageData = value.tostring().encode("bz2").encode("base64")
image_data = value.tostring().encode("bz2").encode("base64")
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
{"mode": value.mode, "size":value.size, "data":imageData})
{"mode": value.mode, "size":value.size, "data":image_data})
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
listElem = SubElement(element, name + "_LIST")
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
_SetNodeProps(element, "%s_%05d"%(name, i), attrVal)
_SetNodeProps(listElem, "%s_%05d"%(name, i), attrVal)
def _SetNodeProps(element, name, value): "Set the properties of the node based on the type of object" # if it is a ctypes structure if isinstance(value, ctypes.Structure): # create an element for the structure structElem = SubElement(element, name) #clsModule = value.__class__.__module__ clsName = value.__class__.__n...
def WriteDialogToFile(fileName, props):
def WriteDialogToFile(filename, props):
def WriteDialogToFile(fileName, props): """Write the props to the file props can be either a dialog of a dictionary """ # if we are passed in a wrapped handle then # get the properties try: props[0].keys() except AttributeError: props = controls.GetDialogPropsFromHandle(props) # build a tree structure root = Element(...
tree.write(fileName, encoding="utf-8")
tree.write(filename, encoding="utf-8")
def WriteDialogToFile(fileName, props): """Write the props to the file props can be either a dialog of a dictionary """ # if we are passed in a wrapped handle then # get the properties try: props[0].keys() except AttributeError: props = controls.GetDialogPropsFromHandle(props) # build a tree structure root = Element(...
for i in range(0, 31):
for i in range(0, 32):
def _EscapeSpecials(s): "Ensure that some characters are escaped before writing to XML" # ensure it is unicode s = unicode(s) # escape backslashs s = s.replace('\\', r'\\') # escape non printable characters (chars below 30) for i in range(0, 31): s = s.replace(unichr(i), "\\%02d"%i) return s
for i in range(0, 31):
for i in range(0, 32):
def _UnEscapeSpecials(s): "Replace escaped characters with real character" # Unescape all the escape characters for i in range(0, 31): s = s.replace("\\%02d"%i, unichr(i)) # convert doubled backslashes to a single backslash s = s.replace(r'\\', '\\') return unicode(s)
def _unittests(): "Perform some simple unit testing" import sys props = ReadPropertiesFromFile(sys.argv[1]) WriteDialogToFile(sys.argv[1] + "__", props) import pprint pprint.pprint(props)
import unittest class XMLHelperTestCases(unittest.TestCase): "Unit tests for the ListViewWrapper class" def setUp(self): """Actually does nothing!""" pass def tearDown(self): "delete the file we have created" import os os.unlink("__unittests.xml") def assertReadWriteSame(self, props): "Make sure that roundtripping...
def ReadPropertiesFromFile(filename): """Return an list of controls from XML file filename""" # parse the file parsed = ElementTree().parse(filename) # Return the list that has been stored under 'CONTROL' props = _ReadXMLStructure(parsed)['CONTROL'] # it is an old XML so let's fix it up a little if not parsed.attri...
_unittests()
unittest.main()
def _unittests(): "Perform some simple unit testing" import sys props = ReadPropertiesFromFile(sys.argv[1]) WriteDialogToFile(sys.argv[1] + "__", props) import pprint pprint.pprint(props)
path = self.listM.get_path(iter)
def xload(self, fname): self.clear() line = os.popen("xfce-get-background", "r").readline() if line.endswith("\r"): line = line[:-1] if line.endswith("\n"): line = line[:-1] if line.endswith("\n"): line = line[:-1] if line.endswith("\r"): line = line[:-1]
Inventory._db = itemdatabase.ItemDatabase()
Inventory._db = xi.itemdatabase.ItemDatabase()
def __init__(self): if Inventory._db is None: # Convenience only. Inventory._db = itemdatabase.ItemDatabase() # List of InventoryEntry objects. self.items = []
trans = Transition() trans.AddWindowReverse(self.portraitwindow, (-self.portraitwindow.width, self.portraitwindow.y)) trans.AddWindowReverse(self.statwindow, (ika.Video.xres, self.statwindow.y)) trans.AddWindowReverse(self.equipwindow, (self.equipwindow.x, -self.equipwindow.height)) trans.AddWindowReverse(self.skillwin...
transition = Transition() transition.AddWindowReverse(self.portraitwindow, (-self.portraitwindow.width, self.portraitwindow.y)) transition.AddWindowReverse(self.statwindow, (ika.Video.xres, self.statwindow.y)) transition.AddWindowReverse(self.equipwindow, (self.equipwindow.x, -self.equipwindow.height)) transition.AddWi...
def StartShow(self): self.Refresh(self.CurChar) trans = Transition() trans.AddWindowReverse(self.portraitwindow, (-self.portraitwindow.width, self.portraitwindow.y)) trans.AddWindowReverse(self.statwindow, (ika.Video.xres, self.statwindow.y)) trans.AddWindowReverse(self.equipwindow, (self.equipwindow.x, -self.equipwin...
trans.AddWindow(self.portraitwindow, (ika.Video.xres, self.portraitwindow.y), remove = True) trans.AddWindow(self.statwindow, (-self.statwindow.width, self.statwindow.y), remove = True) trans.AddWindow(self.equipwindow, (self.equipwindow.x, -self.equipwindow.height), remove = True) trans.AddWindow(self.skillwindow, (se...
transition = Transition() transition.AddWindow(self.portraitwindow, (ika.Video.xres, self.portraitwindow.y), remove=True) transition.AddWindow(self.statwindow, (-self.statwindow.width, self.statwindow.y), remove=True) transition.AddWindow(self.equipwindow, (self.equipwindow.x, -self.equipwindow.height), remove=True) tr...
def StartHide(self): trans.AddWindow(self.portraitwindow, (ika.Video.xres, self.portraitwindow.y), remove = True) trans.AddWindow(self.statwindow, (-self.statwindow.width, self.statwindow.y), remove = True) trans.AddWindow(self.equipwindow, (self.equipwindow.x, -self.equipwindow.height), remove = True) trans.AddWindow(...
def Refresh(self, curchar): self.portraitwindow.Refresh(curchar) self.statwindow.Refresh(curchar) self.equipwindow.Refresh(curchar) self.skillwindow.Refresh(curchar)
def Refresh(self, currentcharacter): self.portraitwindow.Refresh(currentcharacter) self.statwindow.Refresh(currentcharacter) self.equipwindow.Refresh(currentcharacter) self.skillwindow.Refresh(currentcharacter)
def Refresh(self, curchar): self.portraitwindow.Refresh(curchar) self.statwindow.Refresh(curchar) self.equipwindow.Refresh(curchar) self.skillwindow.Refresh(curchar)
self.skillwindow.AddText('No skills')
self.skillwindow.AddText('No skills.')
def Refresh(self, curchar): self.portraitwindow.Refresh(curchar) self.statwindow.Refresh(curchar) self.equipwindow.Refresh(curchar) self.skillwindow.Refresh(curchar)
return self.type + '\t' + self.item.name
return '%s\t%s' % (self.type, self.item.name)
def __str__(self): return self.type + '\t' + self.item.name
__slots__ = [ 'datfilename', 'name', 'portrait', 'chrfile', 'charclass', 'equip', 'skills', 'level', 'initstats', 'endstats', 'naturalstats', 'stats', 'expneeded', 'ent' ]
def __repr__(self): return self.__str__()
"Returns true if the character can equip the item"
def CanEquip(self, itemname): "Returns true if the character can equip the item"
"Returns true if the character can use the item"
def CanUse(self, itemname): "Returns true if the character can use the item"
raise XiException('Invalid equipment type '+`item.equiptype`)
raise XiException('Invalid equipment type %s.' % item.equiptype)
def SetEquip(self, itemname): """ Adds the item to the character's current equipment.
def Equip(self, itemname, slot = None): ''' Equips the specified item
def Equip(self, itemname, slot=None): """Equips the specified item.
def SetEquip(self, itemname): """ Adds the item to the character's current equipment.
If slot is omitted, the first applicable slot in the character's equip list is chosen. '''
If slot is omitted, the first applicable slot in the character's equip list is chosen. """
def Equip(self, itemname, slot = None): ''' Equips the specified item
"Unequips the item in the specified slot"
def Unequip(self, slot): "Unequips the item in the specified slot" slot = slot.lower() if not slot in equiptypes: raise XiException('char.unequip: Invalid equip type specified.')
"Recalculates stats based on current equipment"
def CalcEquip(self): "Recalculates stats based on current equipment" # base stats
ika.Exit('Unknown '+datfile+' token, '+`t`) def Spawn(self, x, y, layer = 0):
ika.Exit('Unknown %s token, %s.' % (datfile, t)) def Spawn(self, x, y, layer=0):
def GetPairOfNumbers(tokens): s1 = tokens.Next() s2 = tokens.Next() if s2 == '-': s2 = tokens.Next()
self.skillwindow = SkillWindow() self.portraitwindow = PortraitWindow() self.statwindow = StatusWindow()
self.skillwindow = xi.menuwindows.SkillWindow() self.portraitwindow = xi.menuwindows.PortraitWindow() self.statwindow = xi.menuwindows.StatusWindow()
def __init__(self, statbar): self.skillwindow = SkillWindow() self.portraitwindow = PortraitWindow() self.statwindow = StatusWindow() self.statbar = statbar self.charidx = 0 self.skillwindow.active = True
self.description = widget.TextFrame()
self.description = xi.widget.TextFrame()
def __init__(self, statbar): self.skillwindow = SkillWindow() self.portraitwindow = PortraitWindow() self.statwindow = StatusWindow() self.statbar = statbar self.charidx = 0 self.skillwindow.active = True
CurChar = property(lambda self: party.party[self.charidx])
CurChar = property(lambda self: xi.party.party[self.charidx])
def __init__(self, statbar): self.skillwindow = SkillWindow() self.portraitwindow = PortraitWindow() self.statwindow = StatusWindow() self.statbar = statbar self.charidx = 0 self.skillwindow.active = True
self.Refresh(party.party[self.charidx]) if right() and self.charidx < len(party.party) - 1:
self.Refresh(xi.party.party[self.charidx]) if right() and self.charidx < len(xi.party.party) - 1:
def UpdateSkillWindow(self): if left() and self.charidx > 0: self.charidx -= 1 self.Refresh(party.party[self.charidx])
self.Refresh(party.party[self.charidx])
self.Refresh(xi.party.party[self.charidx])
def UpdateSkillWindow(self): if left() and self.charidx > 0: self.charidx -= 1 self.Refresh(party.party[self.charidx])
self.Refresh(party.party[self.charidx])
self.Refresh(xi.party.party[self.charidx])
def Execute(self): self.charidx = 0 self.Refresh(party.party[self.charidx])
if cancel():
if xi.controls.cancel():
def Execute(self): self.charidx = 0 self.Refresh(party.party[self.charidx])
elif result == menu.Cancel:
elif result == xi.menu.Cancel:
def Execute(self): self.charidx = 0 self.Refresh(party.party[self.charidx])
def font(color): return '
def font(*args): if len(args) == 1: red, green, blue, alpha = ika.GetRGB(args[0]) elif len(args) == 3: red, green, blue = args alpha = 0xFF elif len(args) == 4: red, green, blue, alpha = args else: raise TypeError('font() takes at most 4 arguments (%s given)' % len(args)) return '
def font(color): return '#[%X]' % color
code = [ 'int %s(struct %s *, %s *);' % (
code = [ 'int %s(struct %s *, %s **);' % (
def GetDeclaration(self, funcname): code = [ 'int %s(struct %s *, %s *);' % ( funcname, self._struct.Name(), self._ctype ) ] return code
'%s_%s_get(struct %s *msg, %s *value)' % (
'%s_%s_get(struct %s *msg, %s **value)' % (
def CodeGet(self): name = self._name code = [ 'int', '%s_%s_get(struct %s *msg, %s *value)' % ( self._struct.Name(), name, self._struct.Name(), self._ctype), '{', ' if (msg->%s_set != 1)' % name, ' return (-1);', ' memcpy(value, msg->%s_data, %s);' % ( name, self._length), ' return (0);', '}' ] return code
' memcpy(value, msg->%s_data, %s);' % ( name, self._length),
' *value = msg->%s_data;' % name,
def CodeGet(self): name = self._name code = [ 'int', '%s_%s_get(struct %s *msg, %s *value)' % ( self._struct.Name(), name, self._struct.Name(), self._ctype), '{', ' if (msg->%s_set != 1)' % name, ' return (-1);', ' memcpy(value, msg->%s_data, %s);' % ( name, self._length), ' return (0);', '}' ] return code
' if (_buf == NULL)\n' ' _buf = evbuffer_new();\n'
' struct evbuffer *_buf = evbuffer_new();\n' ' assert(_buf != NULL);\n'
def PrintCode(self, file): print >>file, ('/*\n' ' * Implementation of %s\n' ' */\n') % self._name