Guest User

Untitled

a guest
Nov 14th, 2016
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ui
  2. import net
  3. import mouseModule
  4. import player
  5. import snd
  6. import localeInfo
  7. import item
  8. import grp
  9. import uiScriptLocale
  10. import uiToolTip
  11. import event
  12. import chat
  13. import uiCommon
  14.  
  15. class CardsInfoWindow(ui.ScriptWindow):
  16.     class DescriptionBox(ui.Window):
  17.         def __init__(self):
  18.             ui.Window.__init__(self)
  19.             self.descIndex = 0
  20.         def __del__(self):
  21.             ui.Window.__del__(self)
  22.         def SetIndex(self, index):
  23.             self.descIndex = index
  24.         def OnRender(self):
  25.             event.RenderEventSet(self.descIndex)
  26.     def __init__(self):
  27.         ui.ScriptWindow.__init__(self)
  28.         self.LoadWindow()
  29.         self.descIndex=0
  30.         self.scrollPos = 0
  31.         self.safemode = 1
  32.         self.questionDialog = None
  33.  
  34.     def __del__(self):
  35.         ui.ScriptWindow.__del__(self)
  36.  
  37.     def LoadWindow(self):
  38.         try:
  39.             pyScrLoader = ui.PythonScriptLoader()
  40.             pyScrLoader.LoadScriptFile(self, "UIScript/minigamerumiwaitingpage.py")
  41.         except:
  42.             import exception
  43.             exception.Abort("minigamerumiwaitingpage.LoadDialog.LoadScript")
  44.  
  45.         try:
  46.             GetObject=self.GetChild
  47.             self.titleBar = GetObject("titlebar")
  48.             self.textBoard = GetObject("desc_board")
  49.             self.scrollBar = GetObject("scrollbar")
  50.             self.checkButton = GetObject("check_image")
  51.             self.checkButton2 = GetObject("confirm_check_button")
  52.             self.startButton = GetObject("game_start_button")
  53.  
  54.         except:
  55.             import exception
  56.             exception.Abort("CubeWindow.LoadDialog.BindObject")
  57.  
  58.         self.titleBar.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
  59.         self.scrollBar.SetPos(0.0)
  60.         self.scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
  61.         self.checkButton.SetEvent(ui.__mem_func__(self.__OnSafeMode))
  62.         self.checkButton2.SetEvent(ui.__mem_func__(self.__OnSafeMode))
  63.         self.startButton.SetEvent(ui.__mem_func__(self.__OnStartQuestion))
  64.  
  65.     def Destroy(self):
  66.         self.ClearDictionary()
  67.         self.titleBar = None
  68.         self.textBoard = None
  69.         self.descriptionBox = None
  70.         self.scrollPos = None
  71.         self.safemode = None
  72.         self.questionDialog = None
  73.    
  74.     def Open(self):
  75.         self.__SetDescriptionEvent()
  76.         self.__CreateDescriptionBox()
  77.         self.scrollBar.SetPos(0.0)
  78.         self.Show()
  79.  
  80.     def Close(self):
  81.         event.ClearEventSet(self.descIndex)
  82.         self.descIndex = 0
  83.         self.Hide()
  84.        
  85.     def __OnStartQuestion(self):
  86.         questionDialog = uiCommon.QuestionDialog2()
  87.         questionDialog.SetText1(localeInfo.MINI_GAME_RUMI_START_QUESTION % (3000, 1))
  88.         questionDialog.SetText2(localeInfo.MINI_GAME_RUMI_START_QUESTION2)
  89.         questionDialog.SetAcceptEvent(ui.__mem_func__(self.__OnStart))
  90.         questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  91.         questionDialog.Open()
  92.         self.questionDialog = questionDialog
  93.        
  94.     def OnCloseQuestionDialog(self):
  95.         if self.questionDialog:
  96.             self.questionDialog.Close()
  97.  
  98.         self.questionDialog = None
  99.        
  100.     def __OnStart(self):
  101.         self.OnCloseQuestionDialog()
  102.         self.Close()
  103.         net.SendChatPacket("/cards o "+ str(self.safemode))
  104.        
  105.     def __OnSafeMode(self):
  106.         if self.safemode == 0:
  107.             self.safemode = 1
  108.             self.checkButton.Show()
  109.         else:
  110.             self.checkButton.Hide()
  111.             self.safemode = 0
  112.        
  113.     def OnUpdate(self):
  114.         (xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition()
  115.         event.UpdateEventSet(self.descIndex, xposEventSet+7, -(yposEventSet+7-(int(self.scrollPos) * 16)))
  116.         self.descriptionBox.SetIndex(self.descIndex)
  117.        
  118.     def OnScroll(self):
  119.         import math
  120.         pos = self.scrollBar.GetPos()
  121.         self.scrollPos = math.floor(float(pos) / float(float(1) / float(event.GetLineCount(self.descIndex) - 18)) + 0.001)
  122.         event.SetVisibleStartLine(self.descIndex, int(self.scrollPos))
  123.         event.Skip(self.descIndex)
  124.  
  125.     def __SetDescriptionEvent(self):
  126.         event.ClearEventSet(self.descIndex)
  127.         self.descIndex = event.RegisterEventSet(uiScriptLocale.CARDS_DESC)
  128.         event.SetRestrictedCount(self.descIndex, 100)
  129.         event.SetVisibleLineCount(self.descIndex, 18)
  130.  
  131.     def __CreateDescriptionBox(self):
  132.         self.descriptionBox = self.DescriptionBox()
  133.         self.descriptionBox.Show()
  134.  
  135.     def __OnCloseButtonClick(self):
  136.         self.Close()
  137.  
  138.     def OnPressEscapeKey(self):
  139.         if 0 != self.eventClose:
  140.             self.eventClose()
  141.         return TRUE
  142.        
  143. class CardsWindow(ui.ScriptWindow):
  144.     CARDS_ICONS = {
  145.         1 : "d:/ymir work/ui/minigame/rumi/card/card_blue_%d.sub",
  146.         2 : "d:/ymir work/ui/minigame/rumi/card/card_red_%d.sub",
  147.         3 : "d:/ymir work/ui/minigame/rumi/card/card_yellow_%d.sub", }
  148.     def __init__(self):
  149.         ui.ScriptWindow.__init__(self)
  150.         self.safemode = 0
  151.         self.questionDialog = None
  152.  
  153.     def __del__(self):
  154.         ui.ScriptWindow.__del__(self)
  155.  
  156.     def LoadWindow(self):
  157.         try:
  158.             pyScrLoader = ui.PythonScriptLoader()
  159.             pyScrLoader.LoadScriptFile(self, "UIScript/minigamerumigamepage.py")
  160.         except:
  161.             import exception
  162.             exception.Abort("minigamerumigamepage.LoadDialog.LoadScript")
  163.  
  164.         try:
  165.             GetObject=self.GetChild
  166.             self.titleBar = GetObject("titlebar")
  167.             self.handSlot = GetObject("HandCardSlot")
  168.             self.fieldSlot = GetObject("FieldCardSlot")
  169.             self.deckSlot = GetObject("DeckCardSlot")
  170.             self.score_completion_effect1 = GetObject("score_completion_effect1")
  171.             self.score_completion_effect2 = GetObject("score_completion_effect2")
  172.             self.score_completion_effect3 = GetObject("score_completion_effect3")
  173.             self.score_completion_text_effect = GetObject("score_completion_text_effect")
  174.             self.deck_flush_effect = GetObject("deck_flush_effect")
  175.             self.cards_count = GetObject("card_cnt_text")
  176.             self.total_points = GetObject("total_score")
  177.             self.field_points = GetObject("score_number_text")
  178.             self.exitButton = GetObject("game_exit_button")
  179.  
  180.         except:
  181.             import exception
  182.             exception.Abort("CubeWindow.LoadDialog.BindObject")
  183.  
  184.         self.titleBar.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
  185.         self.handSlot.SAFE_SetButtonEvent("LEFT", "EXIST", self.SetSelectItemSlotEvent)
  186.         self.handSlot.SAFE_SetButtonEvent("RIGHT", "EXIST", self.SetUnselectItemSlotEvent)
  187.         self.fieldSlot.SAFE_SetButtonEvent("LEFT", "EXIST", self.SetSelectItemSlotEvent2)
  188.         self.score_completion_effect1.SetOnEndFrame(ui.__mem_func__(self.__OnEndFrame))
  189.         self.deckSlot.SAFE_SetButtonEvent("LEFT", "ALWAYS", self.SetPickCardFromDeck)
  190.         self.exitButton.SetEvent(ui.__mem_func__(self.__EndGame))
  191.         self.HideEffects()
  192.        
  193.        
  194.     def SetPickCardFromDeck(self, slotIndex):
  195.         if int(self.cards_count.GetText()) < 1:
  196.             return
  197.         net.SendChatPacket("/cards p")
  198.     def SetSelectItemSlotEvent(self, slotIndex):
  199.         net.SendChatPacket("/cards a " + str(slotIndex))
  200.     def SetSelectItemSlotEvent2(self, slotIndex):
  201.         net.SendChatPacket("/cards r " + str(slotIndex))
  202.     def SetUnselectItemSlotEvent(self, slotIndex):
  203.         if self.safemode == 1:
  204.             questionDialog = uiCommon.QuestionDialog()
  205.             questionDialog.SetText(localeInfo.MINI_GAME_RUMI_DISCARD_QUESTION)
  206.             questionDialog.SetAcceptEvent(lambda arg=TRUE: self.DestroyCard(slotIndex))
  207.             questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  208.             questionDialog.Open()
  209.             self.questionDialog = questionDialog
  210.         else:
  211.             self.DestroyCard(slotIndex)
  212.            
  213.     def __EndGame(self):
  214.         questionDialog = uiCommon.QuestionDialog2()
  215.         questionDialog.SetText1(localeInfo.MINI_GAME_RUMI_EXIT_QUESTION)
  216.         questionDialog.SetText2(localeInfo.MINI_GAME_RUMI_EXIT_QUESTION2)
  217.         questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnEndGame))
  218.         questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  219.         questionDialog.Open()
  220.         self.questionDialog = questionDialog
  221.        
  222.     def OnEndGame(self):
  223.         net.SendChatPacket("/cards e")
  224.         self.OnCloseQuestionDialog()
  225.         self.Close()
  226.     def DestroyCard(self, index):
  227.         net.SendChatPacket("/cards d " + str(index))
  228.         self.OnCloseQuestionDialog()
  229.        
  230.     def OnCloseQuestionDialog(self):
  231.         if self.questionDialog:
  232.             self.questionDialog.Close()
  233.  
  234.         self.questionDialog = None
  235.        
  236.     def __OnEndFrame(self):
  237.         self.HideEffects()
  238.        
  239.     def UpdateCardsInfo(self, hand_1, hand_1_v, hand_2, hand_2_v, hand_3, hand_3_v, hand_4, hand_4_v, hand_5, hand_5_v, cards_left, points):
  240.         if (hand_1 == 0):
  241.             self.handSlot.ClearSlot(0)
  242.         elif (hand_1 != 0):
  243.             self.handSlot.SetCardSlot(0, 10, (self.CARDS_ICONS[hand_1] % (int(hand_1_v))))
  244.         if (hand_2 == 0):
  245.             self.handSlot.ClearSlot(1)
  246.         elif (hand_2 != 0):
  247.             self.handSlot.SetCardSlot(1, 10, (self.CARDS_ICONS[hand_2] % (int(hand_2_v))))
  248.         if (hand_3 == 0):
  249.             self.handSlot.ClearSlot(2)
  250.         elif (hand_3 != 0):
  251.             self.handSlot.SetCardSlot(2, 10, (self.CARDS_ICONS[hand_3] % (int(hand_3_v))))
  252.         if (hand_4 == 0):
  253.             self.handSlot.ClearSlot(3)
  254.         elif (hand_4 != 0):
  255.             self.handSlot.SetCardSlot(3, 10, (self.CARDS_ICONS[hand_4] % (int(hand_4_v))))
  256.         if (hand_5 == 0):
  257.             self.handSlot.ClearSlot(4)
  258.         elif (hand_5 != 0):
  259.             self.handSlot.SetCardSlot(4, 10, (self.CARDS_ICONS[hand_5] % (int(hand_5_v))))
  260.         self.cards_count.SetText(str(cards_left))
  261.         self.total_points.SetText(str(points))
  262.         self.UpdateDeckSlot()
  263.        
  264.     def UpdateCardsFieldInfo(self, slot1, slot1_v, slot2, slot2_v, slot3, slot3_v, points):
  265.         if (slot1 == 0):
  266.             self.fieldSlot.ClearSlot(0)
  267.         elif (slot1 != 0):
  268.             self.fieldSlot.SetCardSlot(0, 10, (self.CARDS_ICONS[slot1] % (int(slot1_v))))
  269.         if (slot2 == 0):
  270.             self.fieldSlot.ClearSlot(1)
  271.         elif (slot2 != 0):
  272.             self.fieldSlot.SetCardSlot(1, 10, (self.CARDS_ICONS[slot2] % (int(slot2_v))))
  273.         if (slot3 == 0):
  274.             self.fieldSlot.ClearSlot(2)
  275.         elif (slot3 != 0):
  276.             self.fieldSlot.SetCardSlot(2, 10, (self.CARDS_ICONS[slot3] % (int(slot3_v))))
  277.         self.field_points.SetText(str(points))
  278.        
  279.     def UpdateDeckSlot(self):
  280.         if int(self.cards_count.GetText()) > 16:
  281.             self.deckSlot.SetCardSlot(2, 10, "d:/ymir work/ui/minigame/rumi/deck/deck3.sub")
  282.             self.deckSlot.SetCardSlot(1, 10, "d:/ymir work/ui/minigame/rumi/deck/deck2.sub")
  283.         elif int(self.cards_count.GetText()) <= 16 and int(self.cards_count.GetText()) > 8:
  284.             self.deckSlot.ClearSlot(2)
  285.             self.deckSlot.SetCardSlot(1, 10, "d:/ymir work/ui/minigame/rumi/deck/deck2.sub")
  286.         elif int(self.cards_count.GetText()) <= 8 and int(self.cards_count.GetText()) > 0:
  287.             self.deckSlot.ClearSlot(2)
  288.             self.deckSlot.ClearSlot(1)
  289.             self.deckSlot.SetCardSlot(0, 10, "d:/ymir work/ui/minigame/rumi/deck/deck1.sub")
  290.         else:
  291.             self.deckSlot.ClearSlot(0)
  292.             self.deckSlot.ClearSlot(1)
  293.             self.deckSlot.ClearSlot(2)
  294.        
  295.     def CardsPutReward(self, slot1, slot1_v, slot2, slot2_v, slot3, slot3_v, points):
  296.         self.score_completion_effect1.ResetFrame()
  297.         self.score_completion_effect1.Show()
  298.         self.score_completion_effect2.ResetFrame()
  299.         self.score_completion_effect2.Show()
  300.         self.score_completion_effect3.ResetFrame()
  301.         self.score_completion_effect3.Show()
  302.         self.score_completion_text_effect.ResetFrame()
  303.         self.score_completion_text_effect.Show()
  304.  
  305.     def HideEffects(self):
  306.         self.score_completion_effect1.Hide()
  307.         self.score_completion_effect2.Hide()
  308.         self.score_completion_effect3.Hide()
  309.         self.score_completion_text_effect.Hide()
  310.         self.deck_flush_effect.Hide()
  311.         self.field_points.SetText("0")
  312.  
  313.     def Destroy(self):
  314.         self.ClearDictionary()
  315.         self.titleBar = None
  316.         self.handSlot = None
  317.         self.fieldSlot = None
  318.         self.deckSlot = None
  319.         self.score_completion_effect1 = None
  320.         self.score_completion_effect2 = None
  321.         self.score_completion_effect3 = None
  322.         self.score_completion_text_effect = None
  323.         self.deck_flush_effect = None
  324.         self.cards_count = None
  325.         self.total_points = None
  326.         self.field_points = None
  327.         self.safemode = None
  328.         self.questionDialog = None
  329.  
  330.     def Open(self, safemode):
  331.         self.safemode = safemode
  332.         self.Show()
  333.  
  334.     def Close(self):
  335.         self.Hide()
  336.  
  337.     def __OnCloseButtonClick(self):
  338.         self.Close()
  339.  
  340.     def OnPressEscapeKey(self):
  341.         if 0 != self.eventClose:
  342.             self.eventClose()
  343.         return TRUE
  344.        
  345. class IngameWindow(ui.ScriptWindow):
  346.     def __init__(self):
  347.         ui.ScriptWindow.__init__(self)
  348.  
  349.     def __del__(self):
  350.         ui.ScriptWindow.__del__(self)
  351.  
  352.     def LoadWindow(self):
  353.         try:
  354.             pyScrLoader = ui.PythonScriptLoader()
  355.             pyScrLoader.LoadScriptFile(self, "UIScript/minigamewindow.py")
  356.         except:
  357.             import exception
  358.             exception.Abort("minigamewindow.LoadDialog.LoadScript")
  359.  
  360.         try:
  361.             GetObject=self.GetChild
  362.             self.gameButton = GetObject("minigame_rumi_button")
  363.  
  364.         except:
  365.             import exception
  366.             exception.Abort("CubeWindow.LoadDialog.BindObject")
  367.  
  368.         self.gameButton.SetEvent(ui.__mem_func__(self.__OnClickGame))
  369.     def __OnClickGame(self):
  370.         self.window = CardsInfoWindow()
  371.         self.window.Open()
  372.        
  373.     def Destroy(self):
  374.         self.ClearDictionary()
RAW Paste Data