This is my syserr.txt
0619 22:39:11369 :: Traceback (most recent call last):
0619 22:39:11369 :: File "networkModule.py", line 239, in SetGamePhase
0619 22:39:11386 :: File "game.py", line 120, in __init__
0619 22:39:11387 :: File "interfaceModule.py", line 340, in MakeInterface
0619 22:39:11387 :: File "interfaceModule.py", line 280, in __MakeDialogs
0619 22:39:11387 :: AttributeError
0619 22:39:11387 :: :
0619 22:39:11387 :: 'module' object has no attribute 'ItemShopWindow'
0619 22:39:11387 ::
0619 22:39:11388 :: Traceback (most recent call last):
0619 22:39:11388 :: File "game.py", line 2465, in BINARY_ServerCommand_Run
0619 22:39:11388 :: AttributeError
0619 22:39:11388 :: :
0619 22:39:11388 :: 'GameWindow' object has no attribute 'serverCommander'
0619 22:39:11388 ::
0619 22:39:12225 :: Traceback (most recent call last):
0619 22:39:12225 :: File "game.py", line 2465, in BINARY_ServerCommand_Run
0619 22:39:12226 :: AttributeError
0619 22:39:12226 :: :
0619 22:39:12226 :: 'GameWindow' object has no attribute 'serverCommander'
0619 22:39:12226 ::
And my uiitemshop.py
import ui, uiToolTip, grp, item, random, event, time, constInfo, dbg, app, uiCommon, chat, math, localeInfo
AFFECT_DICT = uiToolTip.ItemToolTip().AFFECT_DICT
BONUS1_5 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,41,43,44,45,48,53,71,72]
BONUS6_7 = [1,2,3,4,5,6,7,8,15,16,64,63,59,60,61,62,78,79,80,81]
class ItemShopWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.isLoaded = FALSE
self.__LoadWindow()
self.int_pos = [[206,38],[267,50],[319,83],[355,136],[375,199],[358,263],[321,317],[265,346],[206,359],[144,345],[91,314],[53,262],[40,199],[54,137],[92,88],[143,52]]
self.RotationFunc = [0,0,0,0,0,360,0,0]
self.wheelAutoCooldown = None
self.wheelAutoCooldownTime = 5 # time in seconds to clear wheel content after recieve the prize
self.isWheelSpining = FALSE
self.bannerChangeTime = 15 # time in seconds which the banner will change it automatically
self.adminItemList = {}
self.adminTmpAddVnum = 0
self.isSearching = False
self.searchList = []
self.bannerVar = {'fadeOut' : 0, 'currentTime' : 0, 'intervallEndTime' : 0, 'currentAlphaValue' : 0, 'currentImage' : 0, 'lastSwitch' : time.clock() + self.bannerChangeTime}
self.bannerOptions = {'folder' : app.GetLocalePath() + '/ui/itemshop/', 'time' : 10, 'timeToFade' : 0.04, 'interval' : 0.05, 'banner_0' : 'banner_0', 'banner_1' : 'banner_1'}
self.curPage = 'HOME'
self.__BindObjects()
self.__BindEvents()
def __BindObjects(self):
self.board = self.GetChild("board")
self.arrows = {'home' : {'mostBought' : 1, 'hotOffers' : 1}, 'itemshop' : {'categorys' : 1, 'items' : 1}, 'logs' : 1}
self.category = {'itemshop' : 0, 'admin' : 0}
self.elements = {
'money' : {'coins' : self.GetChild("CoinsValue"), 'drs' : self.GetChild("DrsValue")},
'home' : {'mostBought' : [], 'hotOffers' : [], 'mostBoughtItems' : {'box_0' : ItemBox(), 'box_1' : ItemBox(), 'box_2' : ItemBox()}, 'hotOffersItems' : {'box_0' : ItemBox(), 'box_1' : ItemBox()}, 'buttons' : {'arrowLeft' : self.GetChild("HomeArrowLeft"), 'arrowRight' : self.GetChild("HomeArrowRight"), 'arrowUp' : self.GetChild("HomeArrowUp"), 'arrowDown' : self.GetChild("HomeArrowDown")}, 'banner' : {'banner_0' : self.GetChild("Banner1"), 'banner_1' : self.GetChild("Banner2"), 'change_0' : self.GetChild("ChangeBanner1"), 'change_1' : self.GetChild("ChangeBanner2")}},
'itemshop' : {'buttons' : {'arrowUp' : self.GetChild("ItemShopArrowUp"), 'arrowDown' : self.GetChild("ItemShopArrowDown"), 'arrowLeft' : self.GetChild("ItemShopArrowLeft"), 'arrowRight' : self.GetChild("ItemShopArrowRight")}, 'items' : {'box_0' : ItemBox(), 'box_1' : ItemBox(), 'box_2' : ItemBox(), 'box_3' : ItemBox(), 'box_4' : ItemBox(), 'box_5' : ItemBox(), 'box_6' : ItemBox(), 'box_7' : ItemBox(), 'box_8' : ItemBox()}, 'textline' : {'page_nr' : self.GetChild("ItemShopPageNumber")}},
'wheel' : {'images' : {'bg' : self.GetChild("BgWheel"), 'rotation' : self.GetChild("RotationWheel")}, 'buttons' : {'spin' : self.GetChild("SpinButton")}, 'objects' : {}, 'items' : [], 'best_items' : []},
'logs' : {'items' : {'box_0' : LogBox(), 'box_1' : LogBox(), 'box_2' : LogBox(), 'box_3' : LogBox(), 'box_4' : LogBox(), 'box_5' : LogBox(), 'box_6' : LogBox(), 'box_7' : LogBox(), 'box_8' : LogBox()}, 'textline' : {'page_nr' : self.GetChild("LogsPageNumber")}, 'buttons' : {'arrowLeft' : self.GetChild("LogsArrowLeft"), 'arrowRight' : self.GetChild("LogsArrowRight")}},
'admin' : {
'buttons' : {'addItemTime' : self.GetChild("AdminAddItemTime"), 'addNewItem' : self.GetChild("AdminAddNewItem"), 'return' : self.GetChild("ReturnButton")},
'addItemTimeWindow' : self.GetChild("AddItemTimeWindow"),
'addItemWindow' : self.GetChild("AddItemWindow"),
'categoryListBox' : self.GetChild("CategorysListBox"),
'categoryListBoxScroll' : self.GetChild("CategorysListBoxScroll"),
'itemListBox' : self.GetChild("ItemsListBox"),
'itemListBoxScroll' : self.GetChild("ItemsListBoxScroll"),
'discountBox' : DiscountItemBox(),
'categoryDiscountBox' : DiscountCategoryBox(),
'bonusBoxes' : {'attrtype0' : self.GetChild("AddItemAttrtype0"), 'attrvalue0' : self.GetChild("AddItemAttrvalue0"), 'attrtype1' : self.GetChild("AddItemAttrtype1"), 'attrvalue1' : self.GetChild("AddItemAttrvalue1"), 'attrtype2' : self.GetChild("AddItemAttrtype2"), 'attrvalue2' : self.GetChild("AddItemAttrvalue2"), 'attrtype3' : self.GetChild("AddItemAttrtype3"), 'attrvalue3' : self.GetChild("AddItemAttrvalue3"), 'attrtype4' : self.GetChild("AddItemAttrtype4"), 'attrvalue4' : self.GetChild("AddItemAttrvalue4"), 'attrtype5' : self.GetChild("AddItemAttrtype5"), 'attrvalue5' : self.GetChild("AddItemAttrvalue5"), 'attrtype6' : self.GetChild("AddItemAttrtype6"), 'attrvalue6' : self.GetChild("AddItemAttrvalue6")},
'socketsBoxes' : {'socket0' : self.GetChild("AddItemSocket0"), 'socket1' : self.GetChild("AddItemSocket1"), 'socket2' : self.GetChild("AddItemSocket2")},
'applyAddItem' : self.GetChild("AddItemApply"), 'resetAddItem' : self.GetChild("AddItemReset"), 'iconAddItem' : self.GetChild("AddItemIcon"), 'vnumAddItem' : self.GetChild("AddItemVnum"), 'catAddItem' : self.GetChild("AddItemCat"), 'priceAddItem' : self.GetChild("AddItemPrice"),
}
}
self.page = []
self.page.append(self.GetChild("HomeWindow"))
self.page.append(self.GetChild("IShopWindow"))
self.page.append(self.GetChild("WheelWindow"))
self.page.append(self.GetChild("LogsWindow"))
self.page.append(self.GetChild("GmWindow"))
self.tab = []
self.tab.append(self.GetChild("HomeTab"))
self.tab.append(self.GetChild("IShopTab"))
self.tab.append(self.GetChild("WheelTab"))
self.tab.append(self.GetChild("LogsTab"))
self.tab.append(self.GetChild("GmTab"))
self.tab[4].Hide()
for i in xrange(16):
self.elements['wheel']['objects']['tooltip_%d' % i] = self.CreateToolTip()
self.elements['wheel']['objects']['int_%d' % i] = self.CreateImage(self.elements['wheel']['images']['rotation'], app.GetLocalePath() + "/ui/itemshop/int_icon.tga", self.int_pos[i][0], self.int_pos[i][1])
self.elements['wheel']['objects']['icon_%d' % i] = self.CreateImage(self.elements['wheel']['objects']['int_%d' % i], None, 0, 0)
self.elements['wheel']['objects']['icon_%d' % i].SAFE_SetStringEvent("MOUSE_OVER_IN", self.elements['wheel']['objects']['tooltip_%d' % i].ShowToolTip)
self.elements['wheel']['objects']['icon_%d' % i].SAFE_SetStringEvent("MOUSE_OVER_OUT", self.elements['wheel']['objects']['tooltip_%d' % i].HideToolTip)
self.elements['wheel']['objects']['icon_%d' % i].SetWindowHorizontalAlignCenter()
self.elements['wheel']['objects']['icon_%d' % i].SetWindowVerticalAlignCenter()
for i in xrange(6):
self.elements['wheel']['objects']['bgbar_%d' % i] = self.CreateBar(self.GetChild("bgBestItems"), 0, 12+42+66*i, 0, 0)
self.elements['wheel']['objects']['tooltipbests_%d' % i] = self.CreateToolTip()
self.elements['wheel']['objects']['iconbests_%d' % i] = self.CreateImage(self.elements['wheel']['objects']['bgbar_%d' % i], None, 0, 0)
self.elements['wheel']['objects']['iconbests_%d' % i].SAFE_SetStringEvent("MOUSE_OVER_IN", self.elements['wheel']['objects']['tooltipbests_%d' % i].ShowToolTip)
self.elements['wheel']['objects']['iconbests_%d' % i].SAFE_SetStringEvent("MOUSE_OVER_OUT", self.elements['wheel']['objects']['tooltipbests_%d' % i].HideToolTip)
self.elements['wheel']['objects']['iconbests_%d' % i].SetWindowVerticalAlignCenter()
self.elements['wheel']['objects']['namebests_%d' % i] = self.CreateText(self.elements['wheel']['objects']['bgbar_%d' % i])
self.elements['wheel']['objects']['namebests_%d' % i].SetPosition(50, 0)
self.elements['wheel']['objects']['namebests_%d' % i].SetWindowVerticalAlignCenter()
self.elements['wheel']['objects']['namebests_%d' % i].SetVerticalAlignCenter()
self.adminAddNewItemToolTip = uiToolTip.ItemToolTip()
self.adminAddNewItemToolTip.Hide()
"""for i in xrange(7):
self.elements['admin']['bonusBoxes']['attrtype%d' % i] = DropDown(self.GetChild("AddItemNewBoard"), '-- Ninguno --')
self.elements['admin']['bonusBoxes']['attrtype%d' % i].SetSize(330, 20)
self.elements['admin']['bonusBoxes']['attrtype%d' % i].SetPosition(18, 310-25*i)
if i > 5:
for x in AFFECT_DICT:
if x in BONUS6_7:
self.elements['admin']['bonusBoxes']['attrtype%d' % i].AppendItem(str(AFFECT_DICT[x](0)), x)
else:
for x in AFFECT_DICT:
if x in BONUS1_5:
self.elements['admin']['bonusBoxes']['attrtype%d' % i].AppendItem(str(AFFECT_DICT[x](0)), x)
self.elements['admin']['bonusBoxes']['attrtype%d' % i].Show()"""
def __BindEvents(self):
self.board.SetCloseEvent(ui.__mem_func__(self.Close))
for i in xrange(len(self.tab)):
self.tab[i].SetEvent(lambda tabName = self.pages[i] : self.SelectPage(tabName))
self.elements['itemshop']['buttons']['arrowUp'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'ITEMSHOP_CATEGORYS_UP')
self.elements['itemshop']['buttons']['arrowDown'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'ITEMSHOP_CATEGORYS_DOWN')
self.elements['itemshop']['buttons']['arrowLeft'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'ITEMSHOP_ITEMS_LEFT')
self.elements['itemshop']['buttons']['arrowRight'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'ITEMSHOP_ITEMS_RIGHT')
self.elements['home']['buttons']['arrowRight'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'HOME_MOSTBOUGHT_RIGHT')
self.elements['home']['buttons']['arrowLeft'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'HOME_MOSTBOUGHT_LEFT')
self.elements['home']['buttons']['arrowDown'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'HOME_HOTOFFERS_DOWN')
self.elements['home']['buttons']['arrowUp'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'HOME_HOTOFFERS_UP')
self.elements['logs']['buttons']['arrowLeft'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'LOGS_LEFT')
self.elements['logs']['buttons']['arrowRight'].SetEvent(ui.__mem_func__(self.__OnClickArrow), 'LOGS_RIGHT')
self.elements['wheel']['buttons']['spin'].SetEvent(ui.__mem_func__(self.__OnClickRequestSpinWheel))
self.elements['admin']['categoryListBox'].SetScrollBar(self.elements['admin']['categoryListBoxScroll'])
self.elements['admin']['itemListBox'].SetScrollBar(self.elements['admin']['itemListBoxScroll'])
self.elements['admin']['buttons']['addItemTime'].SetEvent(ui.__mem_func__(self.__OnClickAdminButton), 'ITEM_TIME')
self.elements['admin']['buttons']['addNewItem'].SetEvent(ui.__mem_func__(self.__OnClickAdminButton), 'ADD_ITEM')
self.elements['admin']['applyAddItem'].SetEvent(ui.__mem_func__(self.__OnClickAddNewItem))
self.elements['admin']['resetAddItem'].SetEvent(ui.__mem_func__(self.__OnClickResetAddNewItem))
self.GetChild("SearchButton").SetEvent(ui.__mem_func__(self.__OnClickSearchButton))
self.GetChild("SearchValue").SetReturnEvent(ui.__mem_func__(self.__OnClickSearchButton))
for i in xrange(2):
self.elements['home']['banner']['change_%d' % i].SetEvent(ui.__mem_func__(self.SwitchBanner), i)
self.elements['admin']['buttons']['return'].SetEvent(ui.__mem_func__(self.SelectPage), 'GM_ZONE')
self.elements['admin']['discountBox'].Open(self.elements['admin']['addItemTimeWindow'], 320, 80)
self.elements['admin']['categoryDiscountBox'].Open(self.elements['admin']['addItemTimeWindow'], 320, 80+180+15)
self.elements['itemshop']['items']['box_0'].SetSettings(self.page[1], 160, 9)
self.elements['itemshop']['items']['box_1'].SetSettings(self.page[1], 160+202+14, 9)
self.elements['itemshop']['items']['box_2'].SetSettings(self.page[1], 160+(202+14)*2, 9)
self.elements['itemshop']['items']['box_3'].SetSettings(self.page[1], 160, 9+(76+45+16)+10)
self.elements['itemshop']['items']['box_4'].SetSettings(self.page[1], 160+202+14, 9+(76+45+16)+10)
self.elements['itemshop']['items']['box_5'].SetSettings(self.page[1], 160+(202+14)*2, 9+(76+45+16)+10)
self.elements['itemshop']['items']['box_6'].SetSettings(self.page[1], 160, 9+((76+45+16)+10)*2)
self.elements['itemshop']['items']['box_7'].SetSettings(self.page[1], 160+202+14, 9+((76+45+16)+10)*2)
self.elements['itemshop']['items']['box_8'].SetSettings(self.page[1], 160+(202+14)*2, 9+((76+45+16)+10)*2)
self.elements['home']['mostBoughtItems']['box_0'].SetSettings(self.page[0], 39+14+10, 324+14)
self.elements['home']['mostBoughtItems']['box_1'].SetSettings(self.page[0], 39+14+10+202+40, 324+14)
self.elements['home']['mostBoughtItems']['box_2'].SetSettings(self.page[0], 39+14+10+(202+40)*2, 324+14)
self.elements['home']['hotOffersItems']['box_0'].SetSettings(self.page[0], 85+14+10+(202+40)*2, 33)
self.elements['home']['hotOffersItems']['box_1'].SetSettings(self.page[0], 85+14+10+(202+40)*2, 33+117+14)
self.elements['logs']['items']['box_0'].SetSettings(self.page[3], 25, 18)
self.elements['logs']['items']['box_1'].SetSettings(self.page[3], 25+250+10, 18)
self.elements['logs']['items']['box_2'].SetSettings(self.page[3], 25+(250+10)*2, 18)
self.elements['logs']['items']['box_3'].SetSettings(self.page[3], 25, 18+120+18)
self.elements['logs']['items']['box_4'].SetSettings(self.page[3], 25+250+10, 18+120+18)
self.elements['logs']['items']['box_5'].SetSettings(self.page[3], 25+(250+10)*2, 18+120+18)
self.elements['logs']['items']['box_6'].SetSettings(self.page[3], 25, 18+(120+18)*2)
self.elements['logs']['items']['box_7'].SetSettings(self.page[3], 25+250+10, 18+(120+18)*2)
self.elements['logs']['items']['box_8'].SetSettings(self.page[3], 25+(250+10)*2, 18+(120+18)*2)
self.elements['admin']['vnumAddItem'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['catAddItem'].SetFocus))
self.elements['admin']['vnumAddItem'].SetTabEvent(ui.__mem_func__(self.elements['admin']['catAddItem'].SetFocus))
self.elements['admin']['catAddItem'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['priceAddItem'].SetFocus))
self.elements['admin']['catAddItem'].SetTabEvent(ui.__mem_func__(self.elements['admin']['priceAddItem'].SetFocus))
self.elements['admin']['priceAddItem'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype0'].SetFocus))
self.elements['admin']['priceAddItem'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype0'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype0'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue0'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype0'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue0'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue0'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype1'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue0'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype1'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype1'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue1'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype1'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue1'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue1'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype2'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue1'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype2'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype2'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue2'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype2'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue2'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue2'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype3'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue2'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype3'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype3'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue3'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype3'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue3'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue3'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype4'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue3'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype4'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype4'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue4'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype4'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue4'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue4'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype5'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue4'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype5'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype5'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue5'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype5'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue5'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue5'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype6'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue5'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrtype6'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype6'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue6'].SetFocus))
self.elements['admin']['bonusBoxes']['attrtype6'].SetTabEvent(ui.__mem_func__(self.elements['admin']['bonusBoxes']['attrvalue6'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue6'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket0'].SetFocus))
self.elements['admin']['bonusBoxes']['attrvalue6'].SetTabEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket0'].SetFocus))
self.elements['admin']['socketsBoxes']['socket0'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket1'].SetFocus))
self.elements['admin']['socketsBoxes']['socket0'].SetTabEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket1'].SetFocus))
self.elements['admin']['socketsBoxes']['socket1'].SetReturnEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket2'].SetFocus))
self.elements['admin']['socketsBoxes']['socket1'].SetTabEvent(ui.__mem_func__(self.elements['admin']['socketsBoxes']['socket2'].SetFocus))
self.elements['admin']['socketsBoxes']['socket2'].SetReturnEvent(ui.__mem_func__(self.__OnClickAddNewItem))
self.elements['admin']['socketsBoxes']['socket2'].SetTabEvent(ui.__mem_func__(self.__OnClickAddNewItem))
self.elements['admin']['iconAddItem'].SAFE_SetStringEvent("MOUSE_OVER_IN", self.adminAddNewItemToolTip.ShowToolTip)
self.elements['admin']['iconAddItem'].SAFE_SetStringEvent("MOUSE_OVER_OUT", self.adminAddNewItemToolTip.HideToolTip)
self.isLoaded = TRUE
def CreateCategoryButton(self, parent, x, y, text, func, arg):
button = ui.Button()
button.SetParent(parent)
button.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
button.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
button.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
button.SetText(text)
button.SetEvent(ui.__mem_func__(func), arg)
button.SetPosition(x, y)
button.Show()
return button
def CreateToolTip(self):
toolTip = uiToolTip.ItemToolTip()
toolTip.HideToolTip()
return toolTip
def CreateImage(self, parent, src_img, x, y):
img = ui.ExpandedImageBox()
img.SetParent(parent)
img.SetPosition(x, y)
if src_img != None:
img.LoadImage(src_img)
img.Show()
return img
def CreateBar(self, parent, x, y, sizex, sizey):
bar = ui.Bar()
bar.SetParent(parent)
bar.SetPosition(x, y)
bar.SetSize(sizex, sizey)
bar.SetColor(grp.GenerateColor(0.0, 0.0, 0.0, 0.0))
bar.Show()
return bar
def CreateText(self, parent):
text = ui.TextLine()
text.SetParent(parent)
text.Show()
return text
def RefreshIShopCategorys(self):
try:
for i in xrange(12):
self.elements['itemshop']['buttons']['category_%d' % i].Hide()
except:
pass
try:
for i in xrange(min(12, len(self.categorys['itemshop']))):
scrolledId = i + self.arrows['itemshop']['categorys']
self.elements['itemshop']['buttons']['category_%d' % i] = self.CreateCategoryButton(self.page[1], 25, 35+35*i, self.categorys['itemshop'][scrolledId][1], self.__OnClickSelectCategoryIShop, self.categorys['itemshop'][scrolledId][0])
self.elements['itemshop']['buttons']['category_%d' % i].Show()
except:
pass
if (len(self.categorys['itemshop']) > 12):
if (self.arrows['itemshop']['categorys'] <= 0):
self.elements['itemshop']['buttons']['arrowDown'].Show()
self.elements['itemshop']['buttons']['arrowUp'].Hide()
elif (self.arrows['itemshop']['categorys']+12 < len(self.categorys['itemshop'])):
self.elements['itemshop']['buttons']['arrowDown'].Show()
self.elements['itemshop']['buttons']['arrowUp'].Show()
elif (self.arrows['itemshop']['categorys']+12 >= len(self.categorys['itemshop'])):
self.elements['itemshop']['buttons']['arrowDown'].Hide()
self.elements['itemshop']['buttons']['arrowUp'].Show()
else:
self.elements['itemshop']['buttons']['arrowDown'].Hide()
self.elements['itemshop']['buttons']['arrowUp'].Hide()
def RefreshIShopItems(self):
curPage = self.arrows['itemshop']['items']
for i in xrange(9):
self.elements['itemshop']['items']['box_%d' % i].Hide()
try:
if self.isSearching:
for i in xrange(min(9, len(self.searchList) - curPage * 9 +9)):
curItem = self.searchList[i + (curPage - 1)*9]
self.elements['itemshop']['items']['box_%d' % i].SetContent(curItem[0], curItem[1], curItem[3], curItem[4], curItem[2])
self.elements['itemshop']['items']['box_%d' % i].SetPercent(curItem[7])
self.elements['itemshop']['items']['box_%d' % i].SetTime(curItem[5], curItem[6])
self.elements['itemshop']['items']['box_%d' % i].Show()
else:
for i in xrange(min(9, len(constInfo.ItemShop['ITEMS']['itemshop'][self.category['itemshop']]) - curPage * 9 +9)):
curItem = constInfo.ItemShop['ITEMS']['itemshop'][self.category['itemshop']][i + (curPage - 1)*9]
self.elements['itemshop']['items']['box_%d' % i].SetContent(curItem[0], curItem[1], curItem[3], curItem[4], curItem[2])
self.elements['itemshop']['items']['box_%d' % i].SetPercent(curItem[7])
self.elements['itemshop']['items']['box_%d' % i].SetTime(curItem[5], curItem[6])
self.elements['itemshop']['items']['box_%d' % i].Show()
except:
self.elements['itemshop']['buttons']['arrowRight'].Hide()
self.elements['itemshop']['buttons']['arrowLeft'].Hide()
self.GetChild("ItemShopPageNumberSlot").Hide()
return
if self.isSearching:
maxPage = math.ceil(float(len(self.searchList))/float(9))
else:
maxPage = math.ceil(float(len(constInfo.ItemShop['ITEMS']['itemshop'][self.category['itemshop']]))/float(9))
if maxPage >= 1:
self.elements['itemshop']['textline']['page_nr'].SetText('%d/%d' % (curPage, maxPage))
self.GetChild("ItemShopPageNumberSlot").Show()
else:
self.GetChild("ItemShopPageNumberSlot").Hide()
if self.isSearching:
if curPage * 9 >= len(self.searchList):
self.elements['itemshop']['buttons']['arrowRight'].Hide()
else:
self.elements['itemshop']['buttons']['arrowRight'].Show()
else:
if curPage * 9 >= len(constInfo.ItemShop['ITEMS']['itemshop'][self.category['itemshop']]):
self.elements['itemshop']['buttons']['arrowRight'].Hide()
else:
self.elements['itemshop']['buttons']['arrowRight'].Show()
if curPage > 1:
self.elements['itemshop']['buttons']['arrowLeft'].Show()
else:
self.elements['itemshop']['buttons']['arrowLeft'].Hide()
def RefreshIShopMostBought(self):
curPage = self.arrows['home']['mostBought']
for i in xrange(3):
self.elements['home']['mostBoughtItems']['box_%d' % i].Hide()
try:
for i in xrange(min(3, len(constInfo.ItemShop['ITEMS']['mostBought']) - curPage * 3 +3)):
curItem = constInfo.ItemShop['ITEMS']['mostBought'][i + (curPage - 1)*3]
self.elements['home']['mostBoughtItems']['box_%d' % i].SetContent(curItem[0], curItem[1], curItem[3], curItem[4], curItem[2])
self.elements['home']['mostBoughtItems']['box_%d' % i].SetPercent(curItem[7])
self.elements['home']['mostBoughtItems']['box_%d' % i].SetTime(curItem[5], curItem[6])
self.elements['home']['mostBoughtItems']['box_%d' % i].Show()
except:
self.elements['home']['buttons']['arrowRight'].Hide()
self.elements['home']['buttons']['arrowLeft'].Hide()
return
if curPage * 3 >= len(constInfo.ItemShop['ITEMS']['mostBought']):
self.elements['home']['buttons']['arrowRight'].Hide()
else:
self.elements['home']['buttons']['arrowRight'].Show()
if curPage > 1:
self.elements['home']['buttons']['arrowLeft'].Show()
else:
self.elements['home']['buttons']['arrowLeft'].Hide()
def RefreshIShopHotOffers(self):
curPage = self.arrows['home']['hotOffers']
for i in xrange(2):
self.elements['home']['hotOffersItems']['box_%d' % i].Hide()
try:
for i in xrange(min(2, len(constInfo.ItemShop['ITEMS']['hotOffers']) - curPage * 2 +2)):
curItem = constInfo.ItemShop['ITEMS']['hotOffers'][i + (curPage - 1)*2]
self.elements['home']['hotOffersItems']['box_%d' % i].SetContent(curItem[0], curItem[1], curItem[3], curItem[4], curItem[2])
self.elements['home']['hotOffersItems']['box_%d' % i].SetPercent(curItem[7])
self.elements['home']['hotOffersItems']['box_%d' % i].SetTime(curItem[5], curItem[6])
self.elements['home']['hotOffersItems']['box_%d' % i].Show()
except:
self.elements['home']['buttons']['arrowDown'].Hide()
self.elements['home']['buttons']['arrowUp'].Hide()
return
if curPage * 2 >= len(constInfo.ItemShop['ITEMS']['hotOffers']):
self.elements['home']['buttons']['arrowDown'].Hide()
else:
self.elements['home']['buttons']['arrowDown'].Show()
if curPage > 1:
self.elements['home']['buttons']['arrowUp'].Show()
else:
self.elements['home']['buttons']['arrowUp'].Hide()
def RefreshWheelOfDestiny(self):
if not self.isWheelSpining:
for i in xrange(8):
self.RotationFunc[i] = 0
for i in xrange(16):
self.elements['wheel']['objects']['icon_%d' % i].Hide()
for i in xrange(6):
self.elements['wheel']['objects']['bgbar_%d' % i].Hide()
self.elements['wheel']['images']['rotation'].SetRotation(self.RotationFunc[1])
def RefreshLogs(self):
curPage = self.arrows['logs']
for i in xrange(9):
self.elements['logs']['items']['box_%d' % i].Hide()
try:
for i in xrange(min(9, len(constInfo.ItemShop['LOGS']) - curPage * 9 +9)):
curItem = constInfo.ItemShop['LOGS'][i + (curPage - 1)*9]
self.elements['logs']['items']['box_%d' % i].SetContent(curItem[0], curItem[1], curItem[2], curItem[4], curItem[5])
self.elements['logs']['items']['box_%d' % i].SetDate(curItem[3].split('[_]')[0], curItem[3].split('[_]')[1])
self.elements['logs']['items']['box_%d' % i].Show()
except:
self.elements['logs']['buttons']['arrowRight'].Hide()
self.elements['logs']['buttons']['arrowLeft'].Hide()
self.GetChild("LogsPageNumberSlot").Hide()
return
maxPage = math.ceil(float(len(constInfo.ItemShop['LOGS']))/float(9))
if maxPage >= 1:
self.elements['logs']['textline']['page_nr'].SetText('%d/%d' % (curPage, maxPage))
self.GetChild("LogsPageNumberSlot").Show()
else:
self.GetChild("LogsPageNumberSlot").Hide()
if curPage * 9 >= len(constInfo.ItemShop['LOGS']):
self.elements['logs']['buttons']['arrowRight'].Hide()
else:
self.elements['logs']['buttons']['arrowRight'].Show()
if curPage > 1:
self.elements['logs']['buttons']['arrowLeft'].Show()
else:
self.elements['logs']['buttons']['arrowLeft'].Hide()
def RefreshAdminItems(self):
for cat in self.categorys['itemshop']:
self.adminItemList[cat[0]] = []
self.elements['admin']['categoryListBox'].AppendItem(Item(cat[1]))
self.elements['admin']['categoryListBoxScroll'].SetMiddleBarSize(float(8)/float(len(self.adminItemList)))
self.elements['admin']['categoryListBox'].SetSelectEvent(self.RefreshAdminItemLists)
def RefreshAdminItemLists(self, selectItem):
self.elements['admin']['discountBox'].Hide()
cat = self.categorys['itemshop'][self.elements['admin']['categoryListBox'].GetItemIndex(selectItem)][0]
self.elements['admin']['categoryDiscountBox'].SetCategoryID(cat)
self.elements['admin']['categoryDiscountBox'].SetPosition(320, 80)
self.elements['admin']['categoryDiscountBox'].Show()
self.category['admin'] = cat
self.elements['admin']['itemListBox'].RemoveAllItems()
try:
for i in xrange(len(constInfo.ItemShop['ITEMS']['itemshop'][cat])):
item.SelectItem(constInfo.ItemShop['ITEMS']['itemshop'][cat][i][1])
self.elements['admin']['itemListBox'].AppendItem(Item(item.GetItemName()))
self.adminItemList[cat].append(constInfo.ItemShop['ITEMS']['itemshop'][cat][i])
self.elements['admin']['itemListBox'].SetSelectEvent(self.SelectAdminDicountItem)
except:
pass
if len(self.adminItemList[cat]) > 10:
self.elements['admin']['itemListBoxScroll'].SetMiddleBarSize(float(10)/float(len(self.adminItemList[cat])))
self.elements['admin']['itemListBoxScroll'].Show()
else:
self.elements['admin']['itemListBoxScroll'].Hide()
def SelectAdminDicountItem(self, selectItem):
itemInfo = constInfo.ItemShop['ITEMS']['itemshop'][self.category['admin']][self.elements['admin']['itemListBox'].GetItemIndex(selectItem)]
self.elements['admin']['discountBox'].SetContent(itemInfo[0], itemInfo[1], itemInfo[3], itemInfo[4])
self.elements['admin']['discountBox'].Show()
self.elements['admin']['categoryDiscountBox'].SetPosition(320, 80+180+15)
def SwitchBanner(self, newBanner):
self.bannerVar['lastSwitch'] = time.clock() + self.bannerOptions['time'] + self.bannerOptions['timeToFade']/self.bannerOptions['interval']
self.elements['home']['banner']['banner_1'].LoadImage(self.bannerOptions['folder'] + self.bannerOptions['banner_%d' % self.bannerVar['currentImage']] + '.tga')
self.elements['home']['banner']['banner_1'].Show()
self.elements['home']['banner']['banner_0'].LoadImage(self.bannerOptions['folder'] + self.bannerOptions['banner_%d' % newBanner]+ '.tga')
self.bannerVar['currentImage'] = newBanner
self.SetAlpha(self.elements['home']['banner']['banner_1'], 1.0)
self.bannerVar['fadeOut'] = 1
self.bannerVar['intervallEndTime'] = self.bannerVar['currentTime'] + self.bannerOptions['timeToFade']
if newBanner == 0:
self.elements['home']['banner']['change_1'].SetUp()
self.elements['home']['banner']['change_0'].Down()
elif newBanner == 1:
self.elements['home']['banner']['change_0'].SetUp()
self.elements['home']['banner']['change_1'].Down()
def SetAlpha(self, image, alpha):
self.bannerVar['currentAlphaValue'] = alpha
image.SetAlpha(alpha)
def CreateWheelPrizesTable(self):
self.elements['wheel']['items'] = []
self.elements['wheel']['best_items'] = []
for i in xrange(14):
self.elements['wheel']['items'].append(constInfo.ItemShop['WOD'][0][random.randrange(0, len(constInfo.ItemShop['WOD'][0])-1)])
for i in xrange(2):
self.elements['wheel']['items'].append(constInfo.ItemShop['WOD'][1][random.randrange(0, len(constInfo.ItemShop['WOD'][1])-1)])
for i in xrange(6):
self.elements['wheel']['best_items'].append(constInfo.ItemShop['WOD'][1][random.randrange(0, len(constInfo.ItemShop['WOD'][1])-1)])
def SelectPage(self, pageName):
for tab in self.tab:
tab.SetUp()
for page in self.page:
page.Hide()
self.GetChild("SearchValue").KillFocus()
Idx = 0
if pageName == 'HOME':
Idx = 0
self.arrows['home']['mostBought'] = 1
self.arrows['home']['hotOffers'] = 1
self.RefreshIShopMostBought()
self.RefreshIShopHotOffers()
self.SwitchBanner(0)
elif pageName == 'ITEMSHOP':
Idx = 1
self.category['itemshop'] = self.categorys['itemshop'][0][0]
self.arrows['itemshop']['items'] = 1
self.arrows['itemshop']['categorys'] = 0
self.isSearching = False
self.RefreshIShopCategorys()
self.RefreshIShopItems()
elif pageName == 'WHEEL':
Idx = 2
self.RefreshWheelOfDestiny()
elif pageName == 'LOGS':
Idx = 3
self.RefreshLogs()
elif pageName == 'GM_ZONE':
Idx = 4
elif pageName == 'SEARCH':
self.__OnClickAdminButton('NONE')
self.curPage = pageName
self.tab[1].Down()
return
self.__OnClickAdminButton('NONE')
self.curPage = pageName
self.tab[Idx].Down()
self.page[Idx].Show()
def __OnClickAdminButton(self, admin):
self.page[4].Hide()
if admin == 'ITEM_TIME':
self.elements['admin']['categoryListBox'].RemoveAllItems()
self.RefreshAdminItems()
self.elements['admin']['itemListBox'].RemoveAllItems()
self.elements['admin']['itemListBoxScroll'].Hide()
self.elements['admin']['discountBox'].Hide()
self.elements['admin']['categoryDiscountBox'].SetPosition(320, 80)
self.elements['admin']['categoryDiscountBox'].Hide()
self.elements['admin']['addItemTimeWindow'].Show()
self.elements['admin']['buttons']['return'].Show()
elif admin == 'ADD_ITEM':
self.__OnClickResetAddNewItem()
self.elements['admin']['addItemWindow'].Show()
self.elements['admin']['buttons']['return'].Show()
elif admin == 'NONE':
self.elements['admin']['addItemTimeWindow'].Hide()
self.elements['admin']['addItemWindow'].Hide()
self.elements['admin']['buttons']['return'].Hide()
def __OnClickArrow(self, arrow):
if arrow == 'ITEMSHOP_CATEGORYS_UP':
self.arrows['itemshop']['categorys'] -= 1
self.RefreshIShopCategorys()
elif arrow == 'ITEMSHOP_CATEGORYS_DOWN':
self.arrows['itemshop']['categorys'] += 1
self.RefreshIShopCategorys()
elif arrow == 'ITEMSHOP_ITEMS_LEFT':
self.arrows['itemshop']['items'] -= 1
self.RefreshIShopItems()
elif arrow == 'ITEMSHOP_ITEMS_RIGHT':
self.arrows['itemshop']['items'] += 1
self.RefreshIShopItems()
elif arrow == 'HOME_MOSTBOUGHT_LEFT':
self.arrows['home']['mostBought'] -= 1
self.RefreshIShopMostBought()
elif arrow == 'HOME_MOSTBOUGHT_RIGHT':
self.arrows['home']['mostBought'] += 1
self.RefreshIShopMostBought()
elif arrow == 'HOME_HOTOFFERS_DOWN':
self.arrows['home']['hotOffers'] += 1
self.RefreshIShopHotOffers()
elif arrow == 'HOME_HOTOFFERS_UP':
self.arrows['home']['hotOffers'] -= 1
self.RefreshIShopHotOffers()
elif arrow == 'LOGS_LEFT':
self.arrows['logs'] -= 1
self.RefreshLogs()
elif arrow == 'LOGS_RIGHT':
self.arrows['logs'] += 1
self.RefreshLogs()
def __OnClickAddNewItem(self):
attributes,sockets = "",""
for i in xrange(7):
attributes = attributes+self.elements['admin']['bonusBoxes']['attrtype%d' % i].GetText()+'#'+self.elements['admin']['bonusBoxes']['attrvalue%d' % i].GetText()+'#'
for i in xrange(3):
sockets = sockets+self.elements['admin']['socketsBoxes']['socket%d' % i].GetText()+'#'
if self.elements['admin']['vnumAddItem'].GetText() == '0' or self.elements['admin']['vnumAddItem'].GetText() == '' or self.elements['admin']['catAddItem'].GetText() == '0' or self.elements['admin']['catAddItem'].GetText() == '' or self.elements['admin']['priceAddItem'].GetText() == '0' or self.elements['admin']['priceAddItem'].GetText() == '':
return
constInfo.ItemShop['QCMD'] = 'ADD_ITEM#%s#%s#%s#%s#%s' % (self.elements['admin']['catAddItem'].GetText(), self.elements['admin']['vnumAddItem'].GetText(), attributes[:-1], sockets[:-1], self.elements['admin']['priceAddItem'].GetText())
event.QuestButtonClick(constInfo.ItemShop['QID'])
def __OnClickResetAddNewItem(self):
for i in xrange(7):
self.elements['admin']['bonusBoxes']['attrtype%d' % i].SetText('0')
self.elements['admin']['bonusBoxes']['attrvalue%d' % i].SetText('0')
for i in xrange(3):
self.elements['admin']['socketsBoxes']['socket%d' % i].SetText('0')
self.elements['admin']['vnumAddItem'].SetText('')
self.elements['admin']['vnumAddItem'].SetFocus()
self.elements['admin']['catAddItem'].SetText('1')
self.elements['admin']['priceAddItem'].SetText('0')
self.elements['admin']['iconAddItem'].Hide()
def __OnClickSearchButton(self):
self.SelectPage('ITEMSHOP')
self.searchList = []
item_name = self.GetChild("SearchValue").GetText()
if item_name != "" and item_name != 'Buscar...':
self.isSearching = True
for cat in constInfo.ItemShop['ITEMS']['itemshop']:
for i in xrange(len(constInfo.ItemShop['ITEMS']['itemshop'][cat])):
item.SelectItem(constInfo.ItemShop['ITEMS']['itemshop'][cat][i][1])
if (item_name in item.GetItemName()) or (item_name in item.GetItemName().lower()):
self.searchList.append(constInfo.ItemShop['ITEMS']['itemshop'][cat][i])
self.RefreshIShopItems()
def __OnClickSelectCategoryIShop(self, catIdx):
self.isSearching = False
self.category['itemshop'] = catIdx
self.arrows['itemshop']['items'] = 1
self.RefreshIShopItems()
def __OnClickRequestSpinWheel(self):
if not self.isWheelSpining:
self.CreateWheelPrizesTable()
constInfo.ItemShop['QCMD'] = 'REQUEST_SPIN_WHEEL#'
event.QuestButtonClick(constInfo.ItemShop['QID'])
def SpinWheel(self):
for i in xrange(16):
item.SelectItem(self.elements['wheel']['items'][i])
self.elements['wheel']['objects']['icon_%d' % i].SetParent(self.elements['wheel']['objects']['int_%d' % i])
self.elements['wheel']['objects']['icon_%d' % i].LoadImage(item.GetIconImageFileName())
self.elements['wheel']['objects']['icon_%d' % i].Show()
self.elements['wheel']['objects']['tooltip_%d' % i].ClearToolTip()
self.elements['wheel']['objects']['tooltip_%d' % i].AddItemData(self.elements['wheel']['items'][i], [0,0,0])
self.elements['wheel']['objects']['tooltip_%d' % i].HideToolTip()
for i in xrange(6):
item.SelectItem(self.elements['wheel']['best_items'][i])
self.elements['wheel']['objects']['iconbests_%d' % i].LoadImage(item.GetIconImageFileName())
self.elements['wheel']['objects']['namebests_%d' % i].SetText(item.GetItemName())
self.elements['wheel']['objects']['tooltipbests_%d' % i].ClearToolTip()
self.elements['wheel']['objects']['tooltipbests_%d' % i].AddItemData(self.elements['wheel']['best_items'][i], [0,0,0])
self.elements['wheel']['objects']['tooltipbests_%d' % i].HideToolTip()
self.elements['wheel']['objects']['bgbar_%d' % i].SetSize(3+50+self.elements['wheel']['objects']['namebests_%d' % i].GetTextSize()[0], 64)
self.elements['wheel']['objects']['bgbar_%d' % i].SetPosition(0, 66*i)
self.elements['wheel']['objects']['bgbar_%d' % i].SetWindowHorizontalAlignCenter()
self.elements['wheel']['objects']['bgbar_%d' % i].Show()
rand_num = random.randrange(16)
self.RotationFunc[2] = self.RotationFunc[1]
self.RotationFunc[3] = (rand_num-self.RotationFunc[6])*22.5+5*360
self.RotationFunc[6] = rand_num
self.RotationFunc[4] = 5
self.RotationFunc[7] = 1
self.RotationFunc[0] = 1
self.wheelAutoCooldown = None
self.isWheelSpining = TRUE
def SetRotationWheel(self):
if self.RotationFunc[1] >= (self.RotationFunc[2]+360):
self.RotationFunc[1] = self.RotationFunc[1]-360
if self.RotationFunc[3] <= (360*4) and self.RotationFunc[3] > (3*360) and self.RotationFunc[4] != 4:
self.RotationFunc[4] = 4
elif self.RotationFunc[3] <= (360*3) and self.RotationFunc[3] > (2*360) and self.RotationFunc[4] != 3:
self.RotationFunc[4] = 3
elif self.RotationFunc[3] <= (360*2) and self.RotationFunc[3] > (200) and self.RotationFunc[4] != 2:
self.RotationFunc[4] = 2
elif self.RotationFunc[3] <= 200 and self.RotationFunc[3] > 0 and self.RotationFunc[4] != 1:
self.RotationFunc[4] = 1
elif self.RotationFunc[3] <= 0:
dbg.TraceError('Table: %s, Prize: %d, Rand: %d' % (str(self.elements['wheel']['items']), self.elements['wheel']['items'][self.RotationFunc[6]], self.RotationFunc[6]))
constInfo.ItemShop['QCMD'] = 'REQUEST_PRIZE_WHEEL#%d' % self.elements['wheel']['items'][self.RotationFunc[6]]
event.QuestButtonClick(constInfo.ItemShop['QID'])
for i in xrange(8):
self.RotationFunc[i] = 0
self.wheelAutoCooldown = time.clock()+self.wheelAutoCooldownTime
self.isWheelSpining = FALSE
return
self.RotationFunc[3] -= self.RotationFunc[4]
self.RotationFunc[1] += self.RotationFunc[4]
self.elements['wheel']['images']['rotation'].SetRotation(self.RotationFunc[1])
def __del__(self):
ui.ScriptWindow.__del__(self)
def EnableGMZone(self):
self.tab[4].Show()
def Open(self, mode):
if not self.isLoaded:
self.__LoadWindow()
self.SelectPage('HOME')
self.SwitchBanner(0)
if mode == 1:
self.EnableGMZone()
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.Hide()
def Destroy(self):
self.Close()
self.ClearDictionary()
def OnPressEscapeKey(self):
self.Close()
return TRUE
def OnPressExitKey(self):
self.Close()
return TRUE
def OnUpdate(self):
if self.wheelAutoCooldown:
if self.wheelAutoCooldown < time.clock():
self.RefreshWheelOfDestiny()
self.wheelAutoCooldown = None
if self.elements['admin']['vnumAddItem'].GetText() != '0' and self.elements['admin']['vnumAddItem'].GetText() != '':
if self.adminTmpAddVnum != int(self.elements['admin']['vnumAddItem'].GetText()):
try:
self.adminTmpAddVnum = int(self.elements['admin']['vnumAddItem'].GetText())
item.SelectItem(self.adminTmpAddVnum)
self.elements['admin']['iconAddItem'].LoadImage(item.GetIconImageFileName())
self.elements['admin']['iconAddItem'].Show()
self.adminAddNewItemToolTip.ClearToolTip()
self.adminAddNewItemToolTip.AddItemData(self.adminTmpAddVnum, [0, 0, 0])
self.adminAddNewItemToolTip.HideToolTip()
except:
self.elements['admin']['iconAddItem'].Hide()
self.elements['money']['coins'].SetText(localeInfo.NumberToMoneyString(constInfo.COINS_DRS[0]).replace('Yang', "MD's"))
self.elements['money']['drs'].SetText(localeInfo.NumberToMoneyString(constInfo.COINS_DRS[1]).replace('Yang', "DR's"))
if self.bannerVar['lastSwitch'] < time.clock():
if self.bannerVar['currentImage'] == 0:
self.SwitchBanner(1)
else:
self.SwitchBanner(0)
if self.bannerVar['fadeOut'] == 1:
self.bannerVar['currentTime'] = time.clock()
if self.bannerVar['currentAlphaValue'] > 0.0:
if self.bannerVar['currentTime'] >= self.bannerVar['intervallEndTime']:
newAlphaValue = self.bannerVar['currentAlphaValue']
newAlphaValue -= self.bannerOptions['interval']
self.SetAlpha(self.elements['home']['banner']['banner_1'], newAlphaValue)
self.bannerVar['intervallEndTime'] = self.bannerVar['currentTime'] + self.bannerOptions['timeToFade']
else:
self.bannerVar['fadeOut'] = 0
self.elements['home']['banner']['banner_1'].Hide()
if self.RotationFunc[0] < 1:
return
self.SetRotationWheel()
class ItemBox(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.isLoaded = FALSE
self.priceValue = "MD's"
self.time = None
self.runOut = None
self.price = None
self.itemData = [0, [], []]
self.lastTime = None
self.id = -1
def __LoadObjects(self):
self.SetSize(192, 107+18)
Board = ui.ResizableTextValue()
Board.SetParent(self)
Board.SetSize(192, 76+31)
Board.SetPosition(0, 18)
Board.SetLine('left')
Board.SetLine('right')
Board.SetLine('top')
Board.SetLine('bottom')
Board.Show()
self.Board = Board
TimerBoard = ui.ResizableTextValue()
TimerBoard.SetParent(self)
TimerBoard.SetSize(85, 18)
TimerBoard.SetPosition(22, 0)
TimerBoard.SetLine('left')
TimerBoard.SetLine('right')
TimerBoard.SetLine('top')
TimerBoard.SetText('10h 10m 10s')
TimerBoard.Hide()
self.TimerBoard = TimerBoard
PercentBoard = ui.ResizableTextValue()
PercentBoard.SetParent(self)
PercentBoard.SetSize(40, 18)
PercentBoard.SetPosition(137, 0)
PercentBoard.SetLine('left')
PercentBoard.SetLine('right')
PercentBoard.SetLine('top')
PercentBoard.SetText('50%')
PercentBoard.Hide()
self.PercentBoard = PercentBoard
ItemName = ui.ResizableTextValue()
ItemName.SetParent(self.Board)
ItemName.SetSize(150, 18)
ItemName.SetPosition(41, 1)
ItemName.SetLine('left')
ItemName.SetLine('bottom')
ItemName.Show()
self.ItemName = ItemName
ItemPrice = ui.ResizableTextValue()
ItemPrice.SetParent(self.Board)
ItemPrice.SetSize(85, 18)
ItemPrice.SetPosition(106, 19+1)
ItemPrice.SetLine('left')
ItemPrice.SetLine('bottom')
ItemPrice.Show()
self.ItemPrice = ItemPrice
ItemAmountSlot = ui.ResizableTextValue()
ItemAmountSlot.SetParent(self.Board)
ItemAmountSlot.SetSize(85, 18)
ItemAmountSlot.SetPosition(106, 1+19*2)
ItemAmountSlot.SetLine('left')
ItemAmountSlot.SetLine('bottom')
ItemAmountSlot.Show()
self.ItemAmountSlot = ItemAmountSlot
ItemAmountTxt = ui.TextLine()
ItemAmountTxt.SetParent(self.ItemAmountSlot)
ItemAmountTxt.SetPosition(11, 0)
ItemAmountTxt.SetWindowHorizontalAlignCenter()
ItemAmountTxt.SetHorizontalAlignCenter()
ItemAmountTxt.SetWindowVerticalAlignCenter()
ItemAmountTxt.SetVerticalAlignCenter()
ItemAmountTxt.SetText('ud.')
ItemAmountTxt.SetOutline()
ItemAmountTxt.SetPackedFontColor(0xffA07970)
ItemAmountTxt.Show()
self.ItemAmountTxt = ItemAmountTxt
ItemAmount = ui.EditLine()
ItemAmount.SetParent(self.ItemAmountSlot)
ItemAmount.SetSize(10, 18)
ItemAmount.SetPosition((self.ItemAmountSlot.GetWidth()/2)-13, 3)
ItemAmount.SetMax(3)
ItemAmount.SetNumberMode()
ItemAmount.SetText('1')
ItemAmount.SetOutline()
ItemAmount.SetPackedFontColor(0xffA07970)
ItemAmount.Show()
self.ItemAmount = ItemAmount
BuyButton = ui.CoolButton()
BuyButton.SetParent(self.Board)
BuyButton.SetSize(75, 12*2)
BuyButton.SetPosition(111, 17+19*3)
BuyButton.SetText('Comprar')
BuyButton.SetEvent(ui.__mem_func__(self.__OnClickBuyButton))
BuyButton.Show()
self.BuyButton = BuyButton
ToolTip = uiToolTip.ItemToolTip()
ToolTip.HideToolTip()
self.ToolTip = ToolTip
ItemIcon = ui.ExpandedImageBox()
ItemIcon.SetParent(self.Board)
ItemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ToolTip.ShowToolTip)
ItemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.ToolTip.HideToolTip)
ItemIcon.Show()
self.ItemIcon = ItemIcon
self.BuyQuestion = uiCommon.QuestionDialog()
self.BuyQuestion.SetAcceptEvent(lambda arg = TRUE: self.AnswerBuyItem(arg))
self.BuyQuestion.SetCancelEvent(lambda arg = FALSE: self.AnswerBuyItem(arg))
self.SetSize(self.Board.GetWidth(), self.Board.GetHeight()+(self.TimerBoard.GetHeight()-8))
self.isLoaded = TRUE
def __del__(self):
ui.Window.__del__(self)
def SetCoin(self, coin):
self.priceValue = ("MD's", "AP's")[coin-1]
def SetContent(self, id, vnum, attrs, sockets, price):
item.SelectItem(vnum)
self.id = id
self.price = price
if item.IsFlag(4) == 1:
self.ItemAmountSlot.Show()
else:
self.ItemAmountSlot.Hide()
self.ItemName.SetText(item.GetItemName())
self.ItemIcon.LoadImage(item.GetIconImageFileName())
self.ItemIcon.SetPosition(40, (49,35,28)[item.GetItemSize()[1]-1])
self.ItemIcon.SetScale(1, (1,1,0.8)[item.GetItemSize()[1]-1])
self.ItemPrice.SetText('Precio: %d %s' % (price, self.priceValue))
self.ItemAmount.SetText('1')
self.ItemAmount.KillFocus()
self.ItemAmount.CanEdit(TRUE)
self.BuyButton.Enable()
attrs += [(0,0)]*8
self.itemData = [vnum, attrs, sockets]
self.ToolTip.ClearToolTip()
if item.GetLimit(0)[0] == 7:
self.ToolTip.AddItemData(vnum, [sockets[0]+app.GetGlobalTimeStamp(), sockets[1], sockets[2]], attrs)
else:
self.ToolTip.AddItemData(vnum, sockets, attrs)
self.ToolTip.HideToolTip()
def SetTime(self, time, runOut):
if time == 0:
self.TimerBoard.Show()
self.time = None
return
else:
self.TimerBoard.Show()
self.time = time
self.runOut = runOut
self.lastTime = 0
def SetPercent(self, percent):
if percent == 0:
self.PercentBoard.Show()
else:
self.PercentBoard.SetText('%d%%' % percent)
self.PercentBoard.Show()
self.ItemPrice.SetText('Precio: %d %s' % (math.ceil(self.price-(self.price/100.00)*percent), self.priceValue))
def __OnClickBuyButton(self):
self.ItemAmount.KillFocus()
amount = self.ItemAmount.GetText()
price = int(amount) * int(self.ItemPrice.GetText().split(' ')[1])
if amount == '1':
self.BuyQuestion.SetText("Quieres comprar %s por %d %s?" % (self.ItemName.GetText(), price, self.priceValue))
else:
self.BuyQuestion.SetText("Quieres comprar %sx %s por %d %s?" % (amount, self.ItemName.GetText(), price, self.priceValue))
self.BuyQuestion.Open()
def AnswerBuyItem(self, arg):
if arg:
constInfo.ItemShop['QCMD'] = 'BUY_ITEM#%d#%s' % (self.id, self.ItemAmount.GetText())
event.QuestButtonClick(constInfo.ItemShop['QID'])
self.BuyQuestion.Close()
def OnUpdate(self):
if not self.ItemAmount.IsFocus() and (self.ItemAmount.GetText() == '' or self.ItemAmount.GetText() == '0'):
self.ItemAmount.SetText('1')
if int(self.ItemAmount.GetText()) > 500:
self.ItemAmount.SetText('500')
if self.time:
remaining = self.time - app.GetGlobalTimeStamp()
if self.lastTime < time.clock():
if remaining <= 0:
self.time = None
self.PercentBoard.Hide()
self.TimerBoard.Hide()
self.ItemPrice.SetText('Precio: %d %s' % (self.price, self.priceValue))
return
self.lastTime = time.clock() + 1
hoursRemaining = int(remaining) / 3600
minutesRemaining = int(remaining % 3600) / 60
secondsRemaining = int(remaining % 60)
self.TimerBoard.SetText('%dh %dm %ds' % (hoursRemaining, minutesRemaining, secondsRemaining))
def SetSettings(self, parent, x, y):
if not self.isLoaded:
self.__LoadObjects()
self.SetParent(parent)
self.SetPosition(x, y)
self.SetTop()
self.Show()
class LogBox(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.isLoaded = FALSE
def __LoadObjects(self):
Board = ui.ResizableTextValue()
Board.SetParent(self)
Board.SetSize(230, 110)
Board.SetLine('left')
Board.SetLine('right')
Board.SetLine('top')
Board.SetLine('bottom')
Board.Show()
self.Board = Board
ItemName = ui.ResizableTextValue()
ItemName.SetParent(self.Board)
ItemName.SetSize(182, 18)
ItemName.SetPosition(47, 0)
ItemName.SetLine('left')
ItemName.SetLine('bottom')
ItemName.SetLine('top')
ItemName.Show()
self.ItemName = ItemName
ToolTip = uiToolTip.ItemToolTip()
ToolTip.HideToolTip()
self.ToolTip = ToolTip
ItemIcon = ui.ExpandedImageBox()
ItemIcon.SetParent(self.Board)
ItemIcon.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ToolTip.ShowToolTip)
ItemIcon.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.ToolTip.HideToolTip)
ItemIcon.Show()
self.ItemIcon = ItemIcon
ItemPrice = ui.ResizableTextValue()
ItemPrice.SetParent(self.Board)
ItemPrice.SetSize(117, 18)
ItemPrice.SetPosition(112, 19)
ItemPrice.SetLine('left')
ItemPrice.SetLine('bottom')
ItemPrice.Show()
self.ItemPrice = ItemPrice
ItemDate = ui.ResizableTextValue()
ItemDate.SetParent(self.Board)
ItemDate.SetSize(117, 18)
ItemDate.SetPosition(112, 19*2)
ItemDate.SetLine('left')
ItemDate.SetLine('bottom')
ItemDate.Show()
self.ItemDate = ItemDate
ItemHour = ui.ResizableTextValue()
ItemHour.SetParent(self.Board)
ItemHour.SetSize(117, 18)
ItemHour.SetPosition(112, 19*3)
ItemHour.SetLine('left')
ItemHour.SetLine('bottom')
ItemHour.Show()
self.ItemHour = ItemHour
self.SetSize(self.Board.GetWidth(), self.Board.GetHeight())
self.isLoaded = TRUE
def SetContent(self, vnum, amount, price, attrs, sockets):
item.SelectItem(vnum)
if amount > 1:
self.ItemName.SetText('%s %dx' % (item.GetItemName(), amount))
else:
self.ItemName.SetText(item.GetItemName())
self.ItemIcon.LoadImage(item.GetIconImageFileName())
self.ItemIcon.SetPosition(40, (51,37,30)[item.GetItemSize()[1]-1])
self.ItemIcon.SetScale(1, (1,1,0.8)[item.GetItemSize()[1]-1])
self.ItemPrice.SetText('Precio: %d %s' % (price, "MD's"))
attrs += [(0,0)]*8
self.ToolTip.ClearToolTip()
if item.GetLimit(0)[0] == 7:
self.ToolTip.AddItemData(vnum, [sockets[0]+app.GetGlobalTimeStamp(), sockets[1], sockets[2]], attrs)
else:
self.ToolTip.AddItemData(vnum, sockets, attrs)
self.ToolTip.HideToolTip()
def SetDate(self, date, hour):
self.ItemDate.SetText('Fecha: %s' % date)
self.ItemHour.SetText('Hora: %s' % hour)
def SetSettings(self, parent, x, y):
if not self.isLoaded:
self.__LoadObjects()
self.SetParent(parent)
self.SetPosition(x, y)
self.SetTop()
self.Show()
class DiscountItemBox(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.isLoaded = False
self.data = [0,0]
def __LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/itemshop_discountitembox.py")
except:
import exception
exception.Abort("DiscountItemBox.LoadWindow.LoadObject")
try:
self.iconItem = self.GetChild("ItemIcon")
self.nameItem = self.GetChild("ItemName")
self.percent = self.GetChild("Percent")
self.hours = self.GetChild("Hours")
self.minutes = self.GetChild("Minutes")
self.seconds = self.GetChild("Seconds")
self.applyButton = self.GetChild("ApplyButton")
except:
import exception
exception.Abort("DiscountItemBox.LoadWindow.LoadObject")
self.toolTip = uiToolTip.ItemToolTip()
self.toolTip.HideToolTip()
self.iconItem.SAFE_SetStringEvent("MOUSE_OVER_IN", self.toolTip.ShowToolTip)
self.iconItem.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.toolTip.HideToolTip)
self.AcceptQuestion = uiCommon.QuestionDialog()
self.AcceptQuestion.SetAcceptEvent(lambda arg = True: self.AnswerAcceptQuestion(arg))
self.AcceptQuestion.SetCancelEvent(lambda arg = False: self.AnswerAcceptQuestion(arg))
self.applyButton.SetEvent(ui.__mem_func__(self.__OnClickAcceptButton))
self.percent.SetReturnEvent(ui.__mem_func__(self.hours.SetFocus))
self.percent.SetTabEvent(ui.__mem_func__(self.hours.SetFocus))
self.hours.SetReturnEvent(ui.__mem_func__(self.minutes.SetFocus))
self.hours.SetTabEvent(ui.__mem_func__(self.minutes.SetFocus))
self.minutes.SetReturnEvent(ui.__mem_func__(self.seconds.SetFocus))
self.minutes.SetTabEvent(ui.__mem_func__(self.seconds.SetFocus))
self.seconds.SetReturnEvent(ui.__mem_func__(self.__OnClickAcceptButton))
self.seconds.SetTabEvent(ui.__mem_func__(self.percent.SetFocus))
self.isLoaded = True
def SetContent(self, id, vnum, attrs, sockets):
self.data = [id, vnum]
item.SelectItem(vnum)
self.percent.SetText('1')
self.hours.SetText('1')
self.minutes.SetText('1')
self.seconds.SetText('1')
self.iconItem.LoadImage(item.GetIconImageFileName())
self.nameItem.SetText(item.GetItemName())
attrs += [(0,0)]*8
self.toolTip.ClearToolTip()
self.toolTip.AddItemData(vnum, sockets, attrs)
self.toolTip.HideToolTip()
def __OnClickAcceptButton(self):
item.SelectItem(self.data[1])
self.AcceptQuestion.SetText("Quieres aplicar un descuento del %d%% a %s por %dh, %dm y %ds?" % (int(self.percent.GetText()), item.GetItemName(), int(self.hours.GetText()), int(self.minutes.GetText()), int(self.seconds.GetText())))
self.AcceptQuestion.Open()
def AnswerAcceptQuestion(self, arg):
self.time = (int(self.hours.GetText())*3600)+(int(self.minutes.GetText())*60)+(int(self.seconds.GetText()))
if arg:
constInfo.ItemShop['QCMD'] = 'ADD_ITEM_TIME#%d#%d#%s' % (self.data[0], self.time, self.percent.GetText())
event.QuestButtonClick(constInfo.ItemShop['QID'])
self.AcceptQuestion.Close()
def __del__(self):
ui.ScriptWindow.__del__(self)
def OnUpdate(self):
if self.percent.IsFocus():
if int(self.percent.GetText()) > 100:
self.percent.SetText('100')
def Open(self, parent, x, y):
if not self.isLoaded:
self.__LoadWindow()
self.SetParent(parent)
self.SetPosition(x, y)
self.Show()
class DiscountCategoryBox(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.isLoaded = False
self.category = 0
def __LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/itemshop_discountcategorybox.py")
except:
import exception
exception.Abort("DiscountCategoryBox.LoadWindow.LoadObject")
try:
self.percent = self.GetChild("Percent")
self.hours = self.GetChild("Hours")
self.minutes = self.GetChild("Minutes")
self.seconds = self.GetChild("Seconds")
self.applyButton = self.GetChild("ApplyButton")
except:
import exception
exception.Abort("DiscountItemBox.LoadWindow.LoadObject")
self.AcceptQuestion = uiCommon.QuestionDialog()
self.AcceptQuestion.SetAcceptEvent(lambda arg = True: self.AnswerAcceptQuestion(arg))
self.AcceptQuestion.SetCancelEvent(lambda arg = False: self.AnswerAcceptQuestion(arg))
self.applyButton.SetEvent(ui.__mem_func__(self.__OnClickAcceptButton))
self.percent.SetReturnEvent(ui.__mem_func__(self.hours.SetFocus))
self.percent.SetTabEvent(ui.__mem_func__(self.hours.SetFocus))
self.hours.SetReturnEvent(ui.__mem_func__(self.minutes.SetFocus))
self.hours.SetTabEvent(ui.__mem_func__(self.minutes.SetFocus))
self.minutes.SetReturnEvent(ui.__mem_func__(self.seconds.SetFocus))
self.minutes.SetTabEvent(ui.__mem_func__(self.seconds.SetFocus))
self.seconds.SetReturnEvent(ui.__mem_func__(self.__OnClickAcceptButton))
self.seconds.SetTabEvent(ui.__mem_func__(self.percent.SetFocus))
self.isLoaded = True
def __del__(self):
ui.ScriptWindow.__del__(self)
def SetCategoryID(self, id):
self.category = id
def __OnClickAcceptButton(self):
self.AcceptQuestion.SetText("Quieres aplicar un descuento del %d%% a esta categoria por %dh, %dm y %ds?" % (int(self.percent.GetText()), int(self.hours.GetText()), int(self.minutes.GetText()), int(self.seconds.GetText())))
self.AcceptQuestion.Open()
def AnswerAcceptQuestion(self, arg):
self.time = (int(self.hours.GetText())*3600)+(int(self.minutes.GetText())*60)+(int(self.seconds.GetText()))
if arg:
constInfo.ItemShop['QCMD'] = 'ADD_CATEGORY_TIME#%d#%d#%s' % (self.category, self.time, self.percent.GetText())
event.QuestButtonClick(constInfo.ItemShop['QID'])
self.AcceptQuestion.Close()
def Open(self, parent, x, y):
if not self.isLoaded:
self.__LoadWindow()
self.SetParent(parent)
self.SetPosition(x, y)
self.Show()
class Item(ui.ListBoxEx.Item):
def __init__(self, fileName):
ui.ListBoxEx.Item.__init__(self)
self.canLoad = 0
self.text = fileName
if len(fileName) > 40:
self.textLine = self.__CreateTextLine(fileName[:37]+"...")
else:
self.textLine = self.__CreateTextLine(fileName[:40])
def __del__(self):
ui.ListBoxEx.Item.__del__(self)
def GetText(self):
return self.text
def SetSize(self, width, height):
ui.ListBoxEx.Item.SetSize(self, 6*len(self.textLine.GetText()) + 4, height)
def __CreateTextLine(self, fileName):
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetPosition(0, 0)
textLine.SetText(fileName)
textLine.Show()
return textLine
class DropDown(ui.Window):
dropped = 0
dropstat = 0
last = 0
lastS = 0
maxh = 95
c = 1
OnChange = None
class Item(ui.ListBoxEx.Item):
def __init__(self,parent, text,value=0):
ui.ListBoxEx.Item.__init__(self)
self.textBox=ui.TextLine()
self.textBox.SetParent(self)
self.textBox.SetText(text)
self.textBox.Show()
self.value = value
def GetValue(self):
return self.value
def __del__(self):
ui.ListBoxEx.Item.__del__(self)
def __init__(self,parent,tt = "",down=1):
ui.Window.__init__(self,"TOP_MOST")
self.down = down
self.SetParentProxy(parent)
self.bg = ui.Bar("TOP_MOST")
self.bg.SetParent(self)
self.bg.SetPosition(0,0)
self.bg.SetColor(0xc0000000)
self.bg.OnMouseOverIn = self.bgMouseIn
self.bg.OnMouseOverOut = self.bgMouseOut
self.bg.OnMouseLeftButtonDown = self.ExpandMe
self.bg.Show()
self.act = ui.TextLine()
self.act.SetParent(self.bg)
self.act.SetPosition(4,2)
self.act.SetText(tt)
self.act.Show()
self.GetText = self.act.GetText
self.Drop = ui.Bar("TOP_MOST")
self.Drop.SetParent(self.GetParentProxy())
self.Drop.SetPosition(0,21)
self.Drop.SetSize(150,0)
self.Drop.SetColor(0xff0a0a0a)
self.ScrollBar = ui.ThinScrollBar()
self.ScrollBar.SetParent(self.Drop)
self.ScrollBar.SetWindowHorizontalAlignRight()
self.ScrollBar.SetPosition(18,0)
self.ScrollBar.SetScrollBarSize(0)
self.ScrollBar.Hide()
self.DropList = ui.ListBoxEx()
self.DropList.SetParent(self.Drop)
self.DropList.itemHeight = 12
self.DropList.itemWidth = 311
self.DropList.itemStep = 13
self.DropList.SetPosition(0,0)
self.DropList.SetSize(132,13)
self.DropList.SetScrollBar(self.ScrollBar)
self.DropList.SetSelectEvent(self.SetTitle)
self.DropList.SetViewItemCount(0)
self.DropList.Show()
if tt != "":
self.AppendItemAndSelect(tt)
self.selected = self.DropList.GetSelectedItem()
self.SetSize(120,20)
def __del__(self):
ui.Window.__del__(self)
def AppendItem(self,text,value=0):
self.c += 1
self.DropList.AppendItem(self.Item(self,text,value))
self.maxh = min(95, 13*self.c)
if self.c > 7:
self.ScrollBar.Show()
def AppendItemAndSelect(self,text,value=0):
self.DropList.AppendItem(self.Item(self,text,value))
self.DropList.SelectIndex(len(self.DropList.itemList)-1)
def SelectByAffectId(self,id):
for x in self.DropList.itemList:
if x.value == id:
self.DropList.SelectItem(x)
break
def SetTitle(self,item):
self.act.SetText(str(item.textBox.GetText()))
self.last = self.DropList.basePos
self.lastS = self.ScrollBar.GetPos()
self.dropped = 0
self.selected = item
if self.OnChange:
self.OnChange()
def SetPosition(self,w,h):
ui.Window.SetPosition(self,w,h)
if self.down == 1:
self.Drop.SetPosition(w,h+21)
else:
self.Drop.SetPosition(w,h-self.Drop.GetHeight())
def SetSize(self,w,h):
ui.Window.SetSize(self,w,h)
self.bg.SetSize(w,h)
self.Drop.SetSize(w,0)
self.DropList.SetSize(w-18,self.maxh)
for x in self.DropList.itemList:
x.SetSize(w-18,12)
self.ScrollBar.SetPosition(w-18,0)
def ExpandMe(self):
if self.dropped == 1:
self.dropped = 0
else:
self.dropped = 1
def OnUpdate(self):
iter = 6
if self.Drop.GetHeight() < 50:
self.ScrollBar.Hide()
else:
self.ScrollBar.Show()
if self.dropped == 0 and self.dropstat == 1:
if self.Drop.GetHeight() <=0:
self.dropstat = 0
self.Drop.SetSize(self.Drop.GetWidth(),0)
self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
self.Drop.Hide()
else:
if self.Drop.GetHeight()-iter < 0:
self.Drop.SetSize(self.Drop.GetWidth(),0)
else:
self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()-iter)
(w,h) = self.GetLocalPosition()
self.SetPosition(w,h)
self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight())
self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
self.DropList.SetBasePos(self.last+1)
self.DropList.SetBasePos(self.last)
elif self.dropped == 1 and self.dropstat == 0:
self.Drop.Show()
self.SetTop()
if self.Drop.GetHeight() >=self.maxh:
self.Drop.SetSize(self.Drop.GetWidth(),self.maxh)
self.ScrollBar.SetScrollBarSize(self.maxh)
self.dropstat = 1
self.DropList.SetViewItemCount(7)
self.ScrollBar.SetPos(self.lastS)
else:
self.ScrollBar.SetScrollBarSize(self.Drop.GetHeight()+iter)
self.Drop.SetSize(self.Drop.GetWidth(),self.Drop.GetHeight()+iter)
(w,h) = self.GetLocalPosition()
self.SetPosition(w,h)
self.DropList.SetViewItemCount(int(self.Drop.GetHeight()/13))
self.DropList.SetBasePos(self.last+1)
self.DropList.SetBasePos(self.last)
## BG Hover
def bgMouseIn(self):
self.bg.SetColor(0xc00a0a0a)
def bgMouseOut(self):
self.bg.SetColor(0xc0000000)
# sh = ItemShopWindow()
# sh.Open(1)
## Shang ~ Nilon2