forked from metin-server/m2dev-client
Merge pull request #70 from MindRapist/mr-15
This commit is contained in:
@@ -1972,13 +1972,28 @@ class GameWindow(ui.ScriptWindow):
|
||||
self.interface.CommandCloseMall()
|
||||
# END_OF_ITEM_MALL
|
||||
|
||||
def RefineSuceededMessage(self):
|
||||
# MR-15: Update refine messages
|
||||
def RefineSuceededMessage(self, arg = None):
|
||||
snd.PlaySound("sound/ui/make_soket.wav")
|
||||
self.PopupMessage(localeInfo.REFINE_SUCCESS)
|
||||
|
||||
def RefineFailedMessage(self):
|
||||
def RefineFailedMessage(self, arg = None):
|
||||
snd.PlaySound("sound/ui/jaeryun_fail.wav")
|
||||
self.PopupMessage(localeInfo.REFINE_FAILURE)
|
||||
# Use local refine_type and choose popup text similar to uirefine.OpenQuestionDialog
|
||||
try:
|
||||
refine_type = int(arg) if arg is not None else None
|
||||
except Exception:
|
||||
refine_type = None
|
||||
|
||||
if refine_type == 3:
|
||||
# type 3: show first special destroy-with-bonus message
|
||||
self.PopupMessage(localeInfo.REFINE_FAILURE_KEEP_GRADE)
|
||||
elif refine_type == 2:
|
||||
# type 2: downgrade warning
|
||||
self.PopupMessage(localeInfo.REFINE_FAILURE_GRADE_DOWN)
|
||||
else:
|
||||
self.PopupMessage(localeInfo.REFINE_FAILURE_DEL_ITEM)
|
||||
# MR-15: -- END OF -- Update refine messages
|
||||
|
||||
def CommandCloseSafebox(self):
|
||||
self.interface.CommandCloseSafebox()
|
||||
|
||||
@@ -19,6 +19,12 @@ import uiPhaseCurtain
|
||||
import localeInfo
|
||||
|
||||
class PopupDialog(ui.ScriptWindow):
|
||||
# MR-15: Multiline dialog messages
|
||||
BASE_HEIGHT = 105
|
||||
BASE_WIDTH = 280
|
||||
BUTTON_Y = 63
|
||||
LINE_HEIGHT = 12
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def __init__(self):
|
||||
print("NEW POPUP DIALOG ----------------------------------------------------------------------------")
|
||||
@@ -46,7 +52,19 @@ class PopupDialog(ui.ScriptWindow):
|
||||
AcceptButton.SetText(ButtonName)
|
||||
AcceptButton.SetEvent(ui.__mem_func__(self.Close))
|
||||
|
||||
self.GetChild("message").SetText(Message)
|
||||
# MR-15: Multiline dialog messages
|
||||
messageWidget = self.GetChild("message")
|
||||
messageWidget.SetText(Message)
|
||||
|
||||
extraH = len(messageWidget.extraLines) * self.LINE_HEIGHT + 2
|
||||
newH = self.BASE_HEIGHT + extraH
|
||||
self.SetSize(self.BASE_WIDTH, newH)
|
||||
self.GetChild("board").SetSize(self.BASE_WIDTH, newH)
|
||||
AcceptButton.SetPosition(0, self.BUTTON_Y + extraH)
|
||||
|
||||
self.SetCenterPosition()
|
||||
self.UpdateRect()
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
self.Show()
|
||||
|
||||
def Close(self):
|
||||
|
||||
@@ -443,6 +443,13 @@ class TextLine(Window):
|
||||
def __init__(self):
|
||||
Window.__init__(self)
|
||||
self.max = 0
|
||||
|
||||
# MR-15: Multiline dialog messages
|
||||
self.extraLines = []
|
||||
self.textHAlign = None
|
||||
self.textVAlign = None
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
self.SetFontName(localeInfo.UI_DEF_FONT)
|
||||
|
||||
def __del__(self):
|
||||
@@ -464,21 +471,45 @@ class TextLine(Window):
|
||||
wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_ARABIC)
|
||||
|
||||
def SetHorizontalAlignLeft(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textHAlign = "left"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_LEFT)
|
||||
|
||||
def SetHorizontalAlignRight(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textHAlign = "right"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_RIGHT)
|
||||
|
||||
def SetHorizontalAlignCenter(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textHAlign = "center"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetHorizontalAlign(self.hWnd, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
|
||||
|
||||
def SetVerticalAlignTop(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textVAlign = "top"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_TOP)
|
||||
|
||||
def SetVerticalAlignBottom(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textVAlign = "bottom"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_BOTTOM)
|
||||
|
||||
def SetVerticalAlignCenter(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.textVAlign = "center"
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetVerticalAlign(self.hWnd, wndMgr.TEXT_VERTICAL_ALIGN_CENTER)
|
||||
|
||||
def SetSecret(self, Value=True):
|
||||
@@ -500,6 +531,10 @@ class TextLine(Window):
|
||||
wndMgr.SetFeather(self.hWnd, value)
|
||||
|
||||
def SetFontName(self, fontName):
|
||||
# MR-15: Multiline dialog messages
|
||||
self.fontName = fontName
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
wndMgr.SetFontName(self.hWnd, fontName)
|
||||
|
||||
def SetDefaultFontName(self):
|
||||
@@ -512,10 +547,55 @@ class TextLine(Window):
|
||||
wndMgr.SetFontColor(self.hWnd, color)
|
||||
|
||||
def SetText(self, text):
|
||||
wndMgr.SetText(self.hWnd, text)
|
||||
# MR-15: Multiline dialog messages
|
||||
for line in self.extraLines:
|
||||
line.Hide()
|
||||
|
||||
self.extraLines = []
|
||||
|
||||
if not text:
|
||||
wndMgr.SetText(self.hWnd, "")
|
||||
return
|
||||
|
||||
if "\\n" in text or "/n" in text:
|
||||
parts = text.replace("\\n", "\n").replace("/n", "\n").split("\n")
|
||||
parts = [p.strip(" ") for p in parts]
|
||||
|
||||
wndMgr.SetText(self.hWnd, parts[0])
|
||||
|
||||
if len(parts) > 1:
|
||||
LINE_HEIGHT = 20
|
||||
|
||||
for i, part in enumerate(parts[1:], 1):
|
||||
extra = TextLine()
|
||||
extra.SetParent(self)
|
||||
extra.SetFontName(self.fontName)
|
||||
|
||||
if self.textHAlign == "center":
|
||||
extra.SetHorizontalAlignCenter()
|
||||
elif self.textHAlign == "right":
|
||||
extra.SetHorizontalAlignRight()
|
||||
|
||||
if self.textVAlign == "center":
|
||||
extra.SetVerticalAlignCenter()
|
||||
elif self.textVAlign == "bottom":
|
||||
extra.SetVerticalAlignBottom()
|
||||
|
||||
extra.SetPosition(0, LINE_HEIGHT * i)
|
||||
extra.SetText(part)
|
||||
extra.Show()
|
||||
self.extraLines.append(extra)
|
||||
else:
|
||||
wndMgr.SetText(self.hWnd, text)
|
||||
|
||||
def GetText(self):
|
||||
return wndMgr.GetText(self.hWnd)
|
||||
text = wndMgr.GetText(self.hWnd)
|
||||
|
||||
for line in self.extraLines:
|
||||
text += "\n" + wndMgr.GetText(line.hWnd)
|
||||
|
||||
return text
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def GetTextSize(self):
|
||||
return wndMgr.GetTextSize(self.hWnd)
|
||||
|
||||
@@ -215,6 +215,12 @@ class InputDialogWithDescription2(InputDialog):
|
||||
self.description2.SetText(text)
|
||||
|
||||
class QuestionDialog(ui.ScriptWindow):
|
||||
# MR-15: Multiline dialog messages
|
||||
BASE_HEIGHT = 105
|
||||
BASE_WIDTH = 340
|
||||
BUTTON_Y = 63
|
||||
LINE_HEIGHT = 12
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def __init__(self):
|
||||
ui.ScriptWindow.__init__(self)
|
||||
@@ -261,6 +267,9 @@ class QuestionDialog(ui.ScriptWindow):
|
||||
|
||||
def SetText(self, text):
|
||||
self.textLine.SetText(text)
|
||||
# MR-15: Multiline dialog messages
|
||||
self.__UpdateLayout()
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def SetAcceptText(self, text):
|
||||
self.acceptButton.SetText(text)
|
||||
@@ -268,11 +277,30 @@ class QuestionDialog(ui.ScriptWindow):
|
||||
def SetCancelText(self, text):
|
||||
self.cancelButton.SetText(text)
|
||||
|
||||
# MR-15: Multiline dialog messages
|
||||
def __UpdateLayout(self):
|
||||
extraH = len(self.textLine.extraLines) * self.LINE_HEIGHT
|
||||
newH = self.BASE_HEIGHT + extraH + 10
|
||||
btnY = self.BUTTON_Y + extraH + 10
|
||||
|
||||
self.SetSize(self.BASE_WIDTH, newH)
|
||||
self.board.SetSize(self.BASE_WIDTH, newH)
|
||||
self.acceptButton.SetPosition(-40, btnY)
|
||||
self.cancelButton.SetPosition(+40, btnY)
|
||||
self.SetCenterPosition()
|
||||
self.UpdateRect()
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return True
|
||||
|
||||
class QuestionDialog2(QuestionDialog):
|
||||
# MR-15: Multiline dialog messages
|
||||
BASE_HEIGHT = 105
|
||||
BUTTON_Y = 68
|
||||
LINE_HEIGHT = 12
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
def __init__(self):
|
||||
QuestionDialog.__init__(self)
|
||||
@@ -291,11 +319,36 @@ class QuestionDialog2(QuestionDialog):
|
||||
self.acceptButton = self.GetChild("accept")
|
||||
self.cancelButton = self.GetChild("cancel")
|
||||
|
||||
# MR-15: Multiline dialog messages
|
||||
def SetText1(self, text):
|
||||
self.textLine1.SetText(text)
|
||||
self.__UpdateLayout()
|
||||
|
||||
def SetText2(self, text):
|
||||
self.textLine2.SetText(text)
|
||||
self.__UpdateLayout()
|
||||
|
||||
def __UpdateLayout(self):
|
||||
# Shift textLine2 down by the number of extra lines in textLine1
|
||||
offset = len(self.textLine1.extraLines) * self.LINE_HEIGHT + 2
|
||||
|
||||
try:
|
||||
x2, y2 = self.textLine2.GetLocalPosition()
|
||||
self.textLine2.SetPosition(x2, y2 + offset)
|
||||
except:
|
||||
pass
|
||||
|
||||
extraH = (len(self.textLine1.extraLines) + len(self.textLine2.extraLines)) * self.LINE_HEIGHT
|
||||
newH = self.BASE_HEIGHT + extraH + 10
|
||||
btnY = self.BUTTON_Y + extraH + 10
|
||||
|
||||
self.SetSize(280, newH)
|
||||
self.board.SetSize(280, newH)
|
||||
self.acceptButton.SetPosition(-40, btnY)
|
||||
self.cancelButton.SetPosition(+40, btnY)
|
||||
self.SetCenterPosition()
|
||||
self.UpdateRect()
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
class QuestionDialogWithTimeLimit(QuestionDialog2):
|
||||
|
||||
|
||||
@@ -149,10 +149,14 @@ class RefineDialog(ui.ScriptWindow):
|
||||
|
||||
def UpdateDialog(self):
|
||||
newWidth = self.toolTip.GetWidth() + 30
|
||||
newHeight = self.toolTip.GetHeight() + 98
|
||||
# MR-15: Adjust button padding for refine window
|
||||
newHeight = self.toolTip.GetHeight() + 108
|
||||
# MR-15: -- END OF -- Adjust button padding for refine window
|
||||
|
||||
self.board.SetSize(newWidth, newHeight)
|
||||
self.titleBar.SetWidth(newWidth-15)
|
||||
# MR-15: Adjust button padding for refine window
|
||||
self.titleBar.SetWidth(newWidth - 15)
|
||||
# MR-15: -- END OF -- Adjust button padding for refine window
|
||||
self.SetSize(newWidth, newHeight)
|
||||
|
||||
(x, y) = self.GetLocalPosition()
|
||||
@@ -319,11 +323,12 @@ class RefineDialogNew(ui.ScriptWindow):
|
||||
item.SelectItem(nextGradeItemVnum)
|
||||
self.itemImage.LoadImage(item.GetIconImageFileName())
|
||||
xSlotCount, ySlotCount = item.GetItemSize()
|
||||
|
||||
for slot in self.slotList:
|
||||
slot.Hide()
|
||||
|
||||
for i in range(min(3, ySlotCount)):
|
||||
self.slotList[i].SetPosition(-35, i*32 - (ySlotCount-1)*16)
|
||||
self.slotList[i].SetPosition(-35, i * 32 - (ySlotCount - 1) * 16)
|
||||
self.slotList[i].Show()
|
||||
|
||||
self.dialogHeight = self.toolTip.GetHeight() + 46
|
||||
@@ -333,6 +338,11 @@ class RefineDialogNew(ui.ScriptWindow):
|
||||
self.Show()
|
||||
|
||||
def Close(self):
|
||||
# MR-15: Multiline dialog messages
|
||||
if self.dlgQuestion:
|
||||
self.dlgQuestion.Hide()
|
||||
# MR-15: -- END OF -- Multiline dialog messages
|
||||
|
||||
self.dlgQuestion = None
|
||||
self.Hide()
|
||||
|
||||
@@ -378,19 +388,21 @@ class RefineDialogNew(ui.ScriptWindow):
|
||||
|
||||
def UpdateDialog(self):
|
||||
newWidth = self.toolTip.GetWidth() + 60
|
||||
newHeight = self.dialogHeight + 69
|
||||
# MR-15: Adjust button padding for refine window
|
||||
newHeight = self.dialogHeight + 79
|
||||
# MR-15: -- END OF -- Adjust button padding for refine window
|
||||
|
||||
newHeight -= 8
|
||||
|
||||
if app.IsRTL():
|
||||
self.board.SetPosition( newWidth, 0 )
|
||||
self.board.SetPosition(newWidth, 0)
|
||||
|
||||
(x, y) = self.titleBar.GetLocalPosition()
|
||||
self.titleBar.SetPosition( newWidth - 15, y )
|
||||
self.titleBar.SetPosition(newWidth - 15, y)
|
||||
|
||||
self.board.SetSize(newWidth, newHeight)
|
||||
self.toolTip.SetPosition(15 + 35, 38)
|
||||
self.titleBar.SetWidth(newWidth-15)
|
||||
self.titleBar.SetWidth(newWidth - 15)
|
||||
self.SetSize(newWidth, newHeight)
|
||||
|
||||
(x, y) = self.GetLocalPosition()
|
||||
@@ -413,7 +425,9 @@ class RefineDialogNew(ui.ScriptWindow):
|
||||
|
||||
if 3 == self.type: ## <20><>ö
|
||||
dlgQuestion.SetText1(localeInfo.REFINE_DESTROY_WARNING_WITH_BONUS_PERCENT_1)
|
||||
dlgQuestion.SetText2(localeInfo.REFINE_DESTROY_WARNING_WITH_BONUS_PERCENT_2)
|
||||
# MR-15: Update refining messages
|
||||
dlgQuestion.SetText2(localeInfo.REFINE_POPUP_NO_DOWNGRADE_MESSAGE)
|
||||
# MR-15: -- END OF -- Update refining messages
|
||||
elif 2 == self.type: ## <20>ູ<EFBFBD><E0BAB9>
|
||||
dlgQuestion.SetText1(localeInfo.REFINE_DOWN_GRADE_WARNING)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user