AVA2 unlock P4: sash (mt_sash windows/slot/tooltips, sash module, CHR_EQUIPPART_SASH, item_scale)
Client side of metin2-server FEATURE-AVA2-UNLOCK P4: HEADER_CG_SASH 211 / HEADER_GC_SASH 215, a fifth awPart WORD in the character packets (old servers break), the sash part attached by scale per job/sex, the combine and absorb windows in script mt_sash, and quest tools/server/sash on 20016. The ava2items pack keeps the four grade-4 sashes plus their effects, acce window images and item_scale.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0d2a9ebe36
commit
4d7306792e
@@ -37,6 +37,7 @@
|
||||
#include "UserInterface/PythonQuest.h"
|
||||
#include "UserInterface/PythonMessenger.h"
|
||||
#include "UserInterface/PythonSafeBox.h"
|
||||
#include "UserInterface/PythonSash.h"
|
||||
#include "UserInterface/PythonGuild.h"
|
||||
#include "UserInterface/MarkManager.h"
|
||||
#include "UserInterface/GuildMarkDownloader.h"
|
||||
@@ -153,6 +154,7 @@ struct GameSingletons
|
||||
CPythonQuest pyQuest;
|
||||
CPythonMessenger pyManager;
|
||||
CPythonSafeBox pySafeBox;
|
||||
CPythonSash pySash; // PORT: AVA2 sash
|
||||
CPythonGuild pyGuild;
|
||||
CGuildMarkManager kGuildMarkManager;
|
||||
CGuildMarkDownloader kGuildMarkDownloader;
|
||||
@@ -911,6 +913,7 @@ bool run_main_script_body(const char* lpCmdLine, std::string* error)
|
||||
initBackground();
|
||||
initMessenger();
|
||||
initsafebox();
|
||||
initSash();
|
||||
initguild();
|
||||
initServerStateChecker();
|
||||
initRenderTarget(); // PORT: AVA2 model preview
|
||||
@@ -1013,6 +1016,7 @@ namespace PythonBoot
|
||||
#include "BattlePassScript.inc"
|
||||
#include "AppliesScript.inc"
|
||||
#include "ArmorShapesScript.inc"
|
||||
#include "SashScript.inc"
|
||||
|
||||
static void install_script_module(const char* c_szModule, const char* c_szScript)
|
||||
{
|
||||
@@ -1097,6 +1101,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
install_script_module("mt_battlepass", c_szBattlePassScript);
|
||||
install_script_module("mt_applies", c_szAppliesScript);
|
||||
install_script_module("mt_shapes", c_szArmorShapesScript);
|
||||
install_script_module("mt_sash", c_szSashScript);
|
||||
if (g_touch_input)
|
||||
install_script_module("mt_mobile_hud", c_szMobileHUDScript);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,612 @@
|
||||
// PORT: AVA2 sash (披风) windows and tooltips, as module mt_sash. The C++ side is the AVA2 sash module
|
||||
// (PythonSash.cpp, CG/GC_SASH packets, PART_SASH model + item_scale.txt); this script is AVA2 root/uisash.py
|
||||
// (CombineWindow/AbsorbWindow verbatim, their uiscript dicts served through ui.execfile), the glue AVA2 put
|
||||
// into game.py/interfacemodule.py/uiinventory.py (ActSash/AlertSash, right click adds to the open window,
|
||||
// attached slots lit, costume window sash slot) and uitooltip.py's absorption lines (CalcSashValue,
|
||||
// SetSashResultItem/SetSashResultAbsItem). Server messages arrive as "MTSASH <code>" commands
|
||||
// (metin2-server port_sash.cpp). Assets ship in the ava2items pack (tools/server/ava2-items, SASH_*).
|
||||
static const char c_szSashScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app
|
||||
import chat
|
||||
import chrmgr
|
||||
import constInfo
|
||||
import game
|
||||
import item
|
||||
import localeInfo
|
||||
import mouseModule
|
||||
import player
|
||||
import sash
|
||||
import ui
|
||||
import uiInventory
|
||||
import uiToolTip
|
||||
|
||||
L=player.AutoHuntLocalize
|
||||
|
||||
MESSAGES={'already_open':'披风窗口已经打开','absorb_open':'请先关闭披风吸收窗口','combine_open':'请先关闭披风合成窗口',
|
||||
'locked':'物品已锁定,无法放入','grade':'只能放入相同品级的披风','max_abs':'该披风的吸收率已达上限',
|
||||
'absorb_type':'只能吸收武器或铠甲','absorbed':'该披风已经吸收过物品','gold':'金币不足',
|
||||
'success':'成功!','fail':'失败,作为材料的披风已消失'}
|
||||
ABS_CHANGED='合成完成,吸收率变为 %d%%'
|
||||
ALERT_COMBINE='合成失败时,作为材料的第二件披风将会消失。'
|
||||
ALERT_ABSORB='吸收后,被吸收的物品将会消失。'
|
||||
ABSORB_CHANCE='吸收率:%d%%'
|
||||
ABSORB_CHANCE2='吸收率:%d%% ~ %d%%'
|
||||
|
||||
COMBINE_SCRIPT='''# -*- coding: utf-8 -*-
|
||||
import player
|
||||
import uiScriptLocale
|
||||
L=player.AutoHuntLocalize
|
||||
window = {
|
||||
"name" : "Sash_CombineWindow",
|
||||
"x" : (SCREEN_WIDTH - 215)/2, "y" : (SCREEN_HEIGHT - 270)/2,
|
||||
"style" : ("movable", "float",),
|
||||
"width" : 215, "height" : 270,
|
||||
"children" : (
|
||||
{
|
||||
"name" : "board", "type" : "board", "style" : ("attach",),
|
||||
"x" : 0, "y" : 0, "width" : 215, "height" : 270,
|
||||
"children" : (
|
||||
{
|
||||
"name" : "TitleBar", "type" : "titlebar", "style" : ("attach",),
|
||||
"x" : 6, "y" : 6, "width" : 200, "color" : "yellow",
|
||||
"children" : (
|
||||
{ "name" : "TitleName", "type" : "text", "x" : 95, "y" : 3, "text" : L("披风合成"), "text_horizontal_align" : "center" },
|
||||
),
|
||||
},
|
||||
{
|
||||
"name" : "Sash_Combine", "type" : "image", "x" : 9, "y" : 35,
|
||||
"image" : uiScriptLocale.LOCALE_UISCRIPT_PATH + "acce/acce_combine.tga",
|
||||
"children" : (
|
||||
{
|
||||
"name" : "SashSlot", "type" : "slot", "x" : 3, "y" : 3, "width" : 200, "height" : 150,
|
||||
"slot" : (
|
||||
{"index":0, "x":78, "y":7, "width":32, "height":32},
|
||||
{"index":1, "x":78, "y":60, "width":32, "height":32},
|
||||
{"index":2, "x":78, "y":115, "width":32, "height":32},
|
||||
),
|
||||
},
|
||||
{ "name" : "Main", "type" : "text", "text" : L("主披风"), "text_horizontal_align" : "center", "x" : 85 + 12, "y" : 7 + 36 },
|
||||
{ "name" : "serve", "type" : "text", "text" : L("材料披风"), "text_horizontal_align" : "center", "x" : 85 + 12, "y" : 60 + 38 },
|
||||
{ "name" : "Result", "type" : "text", "text" : L("合成结果"), "text_horizontal_align" : "center", "x" : 85 + 12, "y" : 115 + 40 },
|
||||
),
|
||||
},
|
||||
{ "name" : "NeedMoney", "type" : "text", "text" : "", "text_horizontal_align" : "center", "x" : 105, "y" : 215 },
|
||||
{
|
||||
"name" : "AcceptButton", "type" : "button", "x" : 40, "y" : 235, "text" : uiScriptLocale.OK,
|
||||
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
|
||||
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
|
||||
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
|
||||
},
|
||||
{
|
||||
"name" : "CancelButton", "type" : "button", "x" : 114, "y" : 235, "text" : uiScriptLocale.CANCEL,
|
||||
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
|
||||
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
|
||||
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
}
|
||||
'''
|
||||
|
||||
ABSORB_SCRIPT='''# -*- coding: utf-8 -*-
|
||||
import player
|
||||
import uiScriptLocale
|
||||
L=player.AutoHuntLocalize
|
||||
window = {
|
||||
"name" : "Sash_AbsorbtionWindow",
|
||||
"x" : (SCREEN_WIDTH - 205)/2, "y" : (SCREEN_HEIGHT - 270)/2,
|
||||
"style" : ("movable", "float",),
|
||||
"width" : 205, "height" : 270,
|
||||
"children" : (
|
||||
{
|
||||
"name" : "board", "type" : "board", "style" : ("attach",),
|
||||
"x" : 0, "y" : 0, "width" : 205, "height" : 270,
|
||||
"children" : (
|
||||
{
|
||||
"name" : "TitleBar", "type" : "titlebar", "style" : ("attach",),
|
||||
"x" : 6, "y" : 6, "width" : 190, "color" : "yellow",
|
||||
"children" : (
|
||||
{ "name" : "TitleName", "type" : "text", "x" : 95, "y" : 3, "text" : L("披风吸收"), "text_horizontal_align" : "center" },
|
||||
),
|
||||
},
|
||||
{
|
||||
"name" : "Sash_Combine", "type" : "image", "x" : 9, "y" : 35,
|
||||
"image" : uiScriptLocale.LOCALE_UISCRIPT_PATH + "acce/acce_absorb.tga",
|
||||
"children" : (
|
||||
{
|
||||
"name" : "SashSlot", "type" : "slot", "x" : 3, "y" : 3, "width" : 190, "height" : 200,
|
||||
"slot" : (
|
||||
{"index":0, "x":26, "y":41, "width":31, "height":31},
|
||||
{"index":1, "x":125, "y":8, "width":31, "height":96},
|
||||
{"index":2, "x":75, "y":126, "width":31, "height":31},
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
{
|
||||
"name" : "AcceptButton", "type" : "button", "x" : 40, "y" : 235, "text" : uiScriptLocale.OK,
|
||||
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
|
||||
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
|
||||
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
|
||||
},
|
||||
{
|
||||
"name" : "CancelButton", "type" : "button", "x" : 114, "y" : 235, "text" : uiScriptLocale.CANCEL,
|
||||
"default_image" : "d:/ymir work/ui/public/middle_button_01.sub",
|
||||
"over_image" : "d:/ymir work/ui/public/middle_button_02.sub",
|
||||
"down_image" : "d:/ymir work/ui/public/middle_button_03.sub",
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
}
|
||||
'''
|
||||
|
||||
SCRIPTS={'sash_combinewindow.py':COMBINE_SCRIPT,'sash_absorbwindow.py':ABSORB_SCRIPT}
|
||||
# Costume window: the sash slot left of the hair slot (CostumeSlot coordinates).
|
||||
COSTUME_SASH_POS=(13,8)
|
||||
|
||||
g_windows=None
|
||||
g_effects=False
|
||||
|
||||
|
||||
def CalcSashValue(value,abs):
|
||||
# AVA2 uitooltip.CalcSashValue; the server scales applies the same way (port_sash.cpp).
|
||||
if not value:return 0
|
||||
valueCalc=round(value*abs)/100
|
||||
valueCalc+=0.5
|
||||
valueCalc=int(valueCalc)+1 if valueCalc>0 else int(valueCalc)
|
||||
return 1 if (valueCalc<=0 and value>0) else valueCalc
|
||||
|
||||
|
||||
def IsSash(itemVnum):
|
||||
item.SelectItem(itemVnum)
|
||||
return item.GetItemType()==item.ITEM_TYPE_COSTUME and item.GetItemSubType()==item.COSTUME_TYPE_SASH
|
||||
|
||||
|
||||
def IsSashWindowOpen():
|
||||
return bool(g_windows) and (g_windows[0].IsOpened() or g_windows[1].IsOpened())
|
||||
|
||||
|
||||
class CombineWindow(ui.ScriptWindow):
|
||||
def __init__(self):
|
||||
ui.ScriptWindow.__init__(self)
|
||||
self.isLoaded=0;self.PositionOut=0;self.PositionStartX=0;self.PositionStartY=0
|
||||
self.tooltipItem=None
|
||||
|
||||
def __del__(self):
|
||||
ui.ScriptWindow.__del__(self)
|
||||
|
||||
def Destroy(self):
|
||||
self.ClearDictionary()
|
||||
self.titleBar=None;self.btnAccept=None;self.btnCancel=None;self.sashSlot=None;self.needMoney=None;self.Result=None
|
||||
self.tooltipItem=None;self.PositionOut=0;self.PositionStartX=0;self.PositionStartY=0
|
||||
|
||||
def LoadWindow(self):
|
||||
if self.isLoaded:return
|
||||
self.isLoaded=1
|
||||
try:
|
||||
pyScrLoader=ui.PythonScriptLoader()
|
||||
pyScrLoader.LoadScriptFile(self,"uiscript/sash_combinewindow.py")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("Sash_CombineWindow.LoadDialog.LoadScript")
|
||||
try:
|
||||
self.board=self.GetChild("board")
|
||||
self.titleBar=self.GetChild("TitleBar")
|
||||
self.btnAccept=self.GetChild("AcceptButton")
|
||||
self.btnCancel=self.GetChild("CancelButton")
|
||||
self.needMoney=self.GetChild("NeedMoney")
|
||||
self.Result=self.GetChild("Result")
|
||||
self.sashSlot=self.GetChild("SashSlot")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("Sash_CombineWindow.LoadDialog.BindObject")
|
||||
self.sashSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
|
||||
self.sashSlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
|
||||
self.sashSlot.SetUseSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
|
||||
self.sashSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
|
||||
self.sashSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
|
||||
self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
|
||||
self.btnCancel.SetEvent(ui.__mem_func__(self.OnClose))
|
||||
self.btnAccept.SetEvent(ui.__mem_func__(self.OnAccept))
|
||||
|
||||
def SetItemToolTip(self,itemTooltip):
|
||||
self.tooltipItem=itemTooltip
|
||||
|
||||
def IsOpened(self):
|
||||
return bool(self.IsShow() and self.isLoaded)
|
||||
|
||||
def SetPrice(self):
|
||||
self.needMoney.SetText(L('合成费用:')+localeInfo.NumberToMoneyString(sash.GetPrice()))
|
||||
|
||||
def Open(self):
|
||||
self.PositionOut=0
|
||||
(self.PositionStartX,self.PositionStartY,z)=player.GetMainCharacterPosition()
|
||||
self.SetPrice()
|
||||
for i in xrange(sash.WINDOW_MAX_MATERIALS+1):
|
||||
self.sashSlot.ClearSlot(i)
|
||||
self.Show()
|
||||
|
||||
def Close(self):
|
||||
if self.tooltipItem:self.tooltipItem.HideToolTip()
|
||||
self.Hide()
|
||||
|
||||
def OnClose(self):
|
||||
sash.SendCloseRequest()
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.OnClose()
|
||||
return True
|
||||
|
||||
def OnAccept(self):
|
||||
sash.SendRefineRequest()
|
||||
|
||||
def OnUpdate(self):
|
||||
LIMIT_RANGE=sash.LIMIT_RANGE
|
||||
(x,y,z)=player.GetMainCharacterPosition()
|
||||
if abs(x-self.PositionStartX)>=LIMIT_RANGE or abs(y-self.PositionStartY)>=LIMIT_RANGE:
|
||||
if not self.PositionOut:
|
||||
self.PositionOut+=1
|
||||
self.OnClose()
|
||||
|
||||
def OnSelectEmptySlot(self,selectedSlotPos):
|
||||
isAttached=mouseModule.mouseController.isAttached()
|
||||
if not isAttached or selectedSlotPos==sash.WINDOW_MAX_MATERIALS:return
|
||||
attachedSlotType=mouseModule.mouseController.GetAttachedType()
|
||||
attachedSlotPos=mouseModule.mouseController.GetAttachedSlotNumber()
|
||||
attachedInvenType=player.SlotTypeToInvenType(attachedSlotType)
|
||||
mouseModule.mouseController.DeattachObject()
|
||||
if attachedSlotType==player.SLOT_TYPE_INVENTORY and attachedInvenType==player.INVENTORY:
|
||||
sash.Add(attachedInvenType,attachedSlotPos,selectedSlotPos)
|
||||
|
||||
def OnSelectItemSlot(self,selectedSlotPos):
|
||||
if selectedSlotPos==sash.WINDOW_MAX_MATERIALS:return
|
||||
mouseModule.mouseController.DeattachObject()
|
||||
sash.Remove(selectedSlotPos)
|
||||
|
||||
def OnOverInItem(self,selectedSlotPos):
|
||||
if self.tooltipItem:
|
||||
if selectedSlotPos==sash.WINDOW_MAX_MATERIALS:
|
||||
(isHere,iCell)=sash.GetAttachedItem(0)
|
||||
if isHere:self.tooltipItem.SetSashResultItem(iCell)
|
||||
else:
|
||||
(isHere,iCell)=sash.GetAttachedItem(selectedSlotPos)
|
||||
if isHere:self.tooltipItem.SetInventoryItem(iCell)
|
||||
|
||||
def OnOverOutItem(self):
|
||||
if self.tooltipItem:self.tooltipItem.HideToolTip()
|
||||
|
||||
def Refresh(self,iAct):
|
||||
self.SetPrice()
|
||||
self.sashSlot.ClearSlot(sash.WINDOW_MAX_MATERIALS)
|
||||
for i in xrange(sash.WINDOW_MAX_MATERIALS):
|
||||
self.sashSlot.ClearSlot(i)
|
||||
(isHere,iCell)=sash.GetAttachedItem(i)
|
||||
if isHere:
|
||||
self.sashSlot.SetItemSlot(i,player.GetItemIndex(iCell),0)
|
||||
if i==int(sash.WINDOW_MAX_MATERIALS-1):
|
||||
(itemVnum,MinAbs,MaxAbs)=sash.GetResultItem()
|
||||
if not itemVnum:break
|
||||
self.sashSlot.SetItemSlot(i+1,itemVnum,0)
|
||||
break
|
||||
self.sashSlot.RefreshSlot()
|
||||
|
||||
|
||||
class AbsorbWindow(CombineWindow):
|
||||
# AVA2 AbsorbWindow: CombineWindow without the price line, a two-item result tooltip.
|
||||
def LoadWindow(self):
|
||||
if self.isLoaded:return
|
||||
self.isLoaded=1
|
||||
try:
|
||||
pyScrLoader=ui.PythonScriptLoader()
|
||||
pyScrLoader.LoadScriptFile(self,"uiscript/sash_absorbwindow.py")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("Sash_AbsorbtionWindow.LoadDialog.LoadScript")
|
||||
try:
|
||||
self.titleBar=self.GetChild("TitleBar")
|
||||
self.btnAccept=self.GetChild("AcceptButton")
|
||||
self.btnCancel=self.GetChild("CancelButton")
|
||||
self.sashSlot=self.GetChild("SashSlot")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("Sash_AbsorbtionWindow.LoadDialog.BindObject")
|
||||
self.sashSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
|
||||
self.sashSlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
|
||||
self.sashSlot.SetUseSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
|
||||
self.sashSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
|
||||
self.sashSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
|
||||
self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
|
||||
self.btnCancel.SetEvent(ui.__mem_func__(self.OnClose))
|
||||
self.btnAccept.SetEvent(ui.__mem_func__(self.OnAccept))
|
||||
|
||||
def SetPrice(self):
|
||||
pass
|
||||
|
||||
def OnOverInItem(self,selectedSlotPos):
|
||||
if self.tooltipItem:
|
||||
if selectedSlotPos==sash.WINDOW_MAX_MATERIALS:
|
||||
(isHere1,iCell1)=sash.GetAttachedItem(0)
|
||||
(isHere2,iCell2)=sash.GetAttachedItem(1)
|
||||
if isHere1 and isHere2:self.tooltipItem.SetSashResultAbsItem(iCell1,iCell2)
|
||||
else:
|
||||
(isHere,iCell)=sash.GetAttachedItem(selectedSlotPos)
|
||||
if isHere:self.tooltipItem.SetInventoryItem(iCell)
|
||||
|
||||
|
||||
# --- tooltip (AVA2 uitooltip.py ENABLE_SASH_SYSTEM parts) -------------------------------------------------
|
||||
Tip=uiToolTip.ItemToolTip
|
||||
_addItemData=Tip.AddItemData
|
||||
_appendAffect=Tip._ItemToolTip__AppendAffectInformation
|
||||
_appendAttribute=Tip._ItemToolTip__AppendAttributeInformation
|
||||
|
||||
|
||||
def AppendAbsorbedItem(self,itemAbsorbedVnum,absChance):
|
||||
# Attack/defence and applies of the absorbed item, scaled by the absorption rate.
|
||||
item.SelectItem(itemAbsorbedVnum)
|
||||
itemType=item.GetItemType()
|
||||
if itemType==item.ITEM_TYPE_WEAPON:
|
||||
attack=[item.GetValue(3),item.GetValue(4),item.GetValue(5)]
|
||||
magic=[item.GetValue(1),item.GetValue(2),item.GetValue(5)]
|
||||
lines=[]
|
||||
minPower,maxPower,addPower=[CalcSashValue(v,absChance) for v in attack]
|
||||
if maxPower>minPower:lines.append(localeInfo.TOOLTIP_ITEM_ATT_POWER%(minPower+addPower,maxPower+addPower))
|
||||
else:lines.append(localeInfo.TOOLTIP_ITEM_ATT_POWER_ONE_ARG%(minPower+addPower))
|
||||
minMagic,maxMagic,addPower=[CalcSashValue(v,absChance) for v in magic]
|
||||
if magic[0]>0 or magic[1]>0:
|
||||
if maxMagic>minMagic:magicLine=localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER%(minMagic+addPower,maxMagic+addPower)
|
||||
else:magicLine=localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER_ONE_ARG%(minMagic+addPower)
|
||||
if item.GetItemSubType()==item.WEAPON_FAN:lines.insert(0,magicLine)
|
||||
else:lines.append(magicLine)
|
||||
for line in lines:self.AppendTextLine(line,self.POSITIVE_COLOR)
|
||||
elif itemType==item.ITEM_TYPE_ARMOR:
|
||||
defGrade=CalcSashValue(item.GetValue(1),absChance)
|
||||
defBonus=CalcSashValue(item.GetValue(5)*2,absChance)
|
||||
if defGrade>0:
|
||||
self.AppendSpace(5)
|
||||
self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE%(defGrade+defBonus),self.GetChangeTextLineColor(defGrade))
|
||||
magicDefencePower=CalcSashValue(item.GetValue(0),absChance)
|
||||
if magicDefencePower>0:
|
||||
self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_DEF_POWER%magicDefencePower,self.GetChangeTextLineColor(magicDefencePower))
|
||||
for i in xrange(item.ITEM_APPLY_MAX_NUM):
|
||||
item.SelectItem(itemAbsorbedVnum)
|
||||
(affectType,affectValue)=item.GetAffect(i)
|
||||
affectValue=CalcSashValue(affectValue,absChance)
|
||||
affectString=self._ItemToolTip__GetAffectString(affectType,affectValue)
|
||||
if affectString and affectValue>0:
|
||||
self.AppendTextLine(affectString,self.GetChangeTextLineColor(affectValue))
|
||||
|
||||
|
||||
def AppendScaledAttributes(self,attrSlot,absChance):
|
||||
if not attrSlot:return
|
||||
for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
|
||||
type,value=attrSlot[i][0],attrSlot[i][1]
|
||||
if not value:continue
|
||||
value=CalcSashValue(value,absChance)
|
||||
affectString=self._ItemToolTip__GetAffectString(type,value)
|
||||
if affectString and value>0:
|
||||
self.AppendTextLine(affectString,self._ItemToolTip__GetAttributeColor(i,value))
|
||||
|
||||
|
||||
def AddItemData(self,itemVnum,metinSlot,attrSlot=0,flags=0,unbindTime=0):
|
||||
self.mtSash=None
|
||||
if metinSlot and IsSash(itemVnum):
|
||||
self.mtSash=(itemVnum,int(metinSlot[sash.ABSORPTION_SOCKET]),int(metinSlot[sash.ABSORBED_SOCKET]))
|
||||
try:
|
||||
return _addItemData(self,itemVnum,metinSlot,attrSlot,flags,unbindTime)
|
||||
finally:
|
||||
self.mtSash=None
|
||||
|
||||
|
||||
def AppendAffectInformation(self):
|
||||
_appendAffect(self)
|
||||
state=getattr(self,'mtSash',None)
|
||||
if not state:return
|
||||
itemVnum,absChance,itemAbsorbedVnum=state
|
||||
self.AppendTextLine(L(ABSORB_CHANCE%absChance),self.CONDITION_COLOR)
|
||||
if itemAbsorbedVnum:AppendAbsorbedItem(self,itemAbsorbedVnum,absChance)
|
||||
item.SelectItem(itemVnum)
|
||||
|
||||
|
||||
def AppendAttributeInformation(self,attrSlot):
|
||||
state=getattr(self,'mtSash',None)
|
||||
if not state:return _appendAttribute(self,attrSlot)
|
||||
AppendScaledAttributes(self,attrSlot,state[1])
|
||||
item.SelectItem(state[0])
|
||||
|
||||
|
||||
def SetSashResultItem(self,slotIndex,window_type=player.INVENTORY):
|
||||
(itemVnum,MinAbs,MaxAbs)=sash.GetResultItem()
|
||||
if not itemVnum:return
|
||||
self.ClearToolTip()
|
||||
metinSlot=[player.GetItemMetinSocket(window_type,slotIndex,i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
|
||||
attrSlot=[player.GetItemAttribute(window_type,slotIndex,i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
|
||||
if not IsSash(itemVnum):return
|
||||
itemDesc=item.GetItemDescription()
|
||||
self._ItemToolTip__AdjustMaxWidth(attrSlot,itemDesc)
|
||||
self._ItemToolTip__SetItemTitle(itemVnum,metinSlot,attrSlot)
|
||||
self.AppendDescription(itemDesc,26)
|
||||
self.AppendDescription(item.GetItemSummary(),26,self.CONDITION_COLOR)
|
||||
self._ItemToolTip__AppendLimitInformation()
|
||||
if MinAbs==MaxAbs:self.AppendTextLine(L(ABSORB_CHANCE%MinAbs),self.CONDITION_COLOR)
|
||||
else:self.AppendTextLine(L(ABSORB_CHANCE2%(MinAbs,MaxAbs)),self.CONDITION_COLOR)
|
||||
itemAbsorbedVnum=int(metinSlot[sash.ABSORBED_SOCKET])
|
||||
if itemAbsorbedVnum:AppendAbsorbedItem(self,itemAbsorbedVnum,MaxAbs)
|
||||
AppendScaledAttributes(self,attrSlot,MaxAbs)
|
||||
item.SelectItem(itemVnum)
|
||||
self.AppendWearableInformation()
|
||||
self.ShowToolTip()
|
||||
|
||||
|
||||
def SetSashResultAbsItem(self,slotIndex1,slotIndex2,window_type=player.INVENTORY):
|
||||
itemVnumSash=player.GetItemIndex(window_type,slotIndex1)
|
||||
itemVnumTarget=player.GetItemIndex(window_type,slotIndex2)
|
||||
if not itemVnumSash or not itemVnumTarget:return
|
||||
self.ClearToolTip()
|
||||
if not IsSash(itemVnumSash):return
|
||||
metinSlot=[player.GetItemMetinSocket(window_type,slotIndex1,i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
|
||||
attrSlot=[player.GetItemAttribute(window_type,slotIndex2,i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
|
||||
absChance=int(metinSlot[sash.ABSORPTION_SOCKET])
|
||||
itemDesc=item.GetItemDescription()
|
||||
self._ItemToolTip__AdjustMaxWidth(attrSlot,itemDesc)
|
||||
self._ItemToolTip__SetItemTitle(itemVnumSash,metinSlot,attrSlot)
|
||||
self.AppendDescription(itemDesc,26)
|
||||
self.AppendDescription(item.GetItemSummary(),26,self.CONDITION_COLOR)
|
||||
item.SelectItem(itemVnumSash)
|
||||
self._ItemToolTip__AppendLimitInformation()
|
||||
self.AppendTextLine(L(ABSORB_CHANCE%absChance),self.CONDITION_COLOR)
|
||||
AppendAbsorbedItem(self,itemVnumTarget,absChance)
|
||||
AppendScaledAttributes(self,attrSlot,absChance)
|
||||
item.SelectItem(itemVnumSash)
|
||||
self.AppendWearableInformation()
|
||||
self.ShowToolTip()
|
||||
|
||||
|
||||
Tip.AddItemData=AddItemData
|
||||
Tip._ItemToolTip__AppendAffectInformation=AppendAffectInformation
|
||||
Tip._ItemToolTip__AppendAttributeInformation=AppendAttributeInformation
|
||||
Tip.SetSashResultItem=SetSashResultItem
|
||||
Tip.SetSashResultAbsItem=SetSashResultAbsItem
|
||||
|
||||
|
||||
# --- uiscripts: the two sash windows and the costume window's sash slot ------------------------------------
|
||||
def FindChild(node,name):
|
||||
if node.get("name")==name:return node
|
||||
for child in node.get("children",()):
|
||||
found=FindChild(child,name)
|
||||
if found:return found
|
||||
return None
|
||||
|
||||
|
||||
def PatchCostumeWindow(window):
|
||||
base=FindChild(window,"Costume_Base");slot=FindChild(window,"CostumeSlot")
|
||||
if not base or not slot:return
|
||||
x,y=COSTUME_SASH_POS
|
||||
frame={"name":"SashSlotBase","type":"image","x":slot["x"]+x,"y":slot["y"]+y,"image":"d:/ymir work/ui/public/Slot_Base.sub"}
|
||||
base["children"]=(frame,)+tuple(base.get("children",()))
|
||||
slot["slot"]=tuple(slot["slot"])+({"index":item.COSTUME_SLOT_SASH,"x":x,"y":y,"width":32,"height":32},)
|
||||
|
||||
|
||||
_execfile=ui.execfile
|
||||
|
||||
def ExecFile(fileName,dict):
|
||||
name=fileName.replace("\\","/").split("/")[-1].lower()
|
||||
if name in SCRIPTS:
|
||||
exec(SCRIPTS[name],dict)
|
||||
return
|
||||
_execfile(fileName,dict)
|
||||
if name=="costumewindow.py" and "window" in dict:PatchCostumeWindow(dict["window"])
|
||||
|
||||
ui.execfile=ExecFile
|
||||
|
||||
_refreshCostume=uiInventory.CostumeWindow.RefreshCostumeSlot
|
||||
|
||||
def RefreshCostumeSlot(self):
|
||||
_refreshCostume(self)
|
||||
self.wndEquip.SetItemSlot(item.COSTUME_SLOT_SASH,player.GetItemIndex(item.COSTUME_SLOT_SASH),0)
|
||||
self.wndEquip.RefreshSlot()
|
||||
|
||||
uiInventory.CostumeWindow.RefreshCostumeSlot=RefreshCostumeSlot
|
||||
|
||||
|
||||
# --- inventory: right click adds to the open sash window, attached items are lit ----------------------------
|
||||
_useItemSlot=uiInventory.InventoryWindow.UseItemSlot
|
||||
_refreshBag=uiInventory.InventoryWindow.RefreshBagSlotWindow
|
||||
|
||||
def UseItemSlot(self,slotIndex):
|
||||
if IsSashWindowOpen() and app.GetCursor()!=app.SELL:
|
||||
cell=self._InventoryWindow__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
|
||||
if not player.IsEquipmentSlot(cell):
|
||||
sash.Add(player.INVENTORY,cell,255)
|
||||
return
|
||||
return _useItemSlot(self,slotIndex)
|
||||
|
||||
|
||||
def AutoPotionActive(cell):
|
||||
return constInfo.IS_AUTO_POTION(player.GetItemIndex(cell)) and player.GetItemMetinSocket(cell,0)!=0
|
||||
|
||||
|
||||
def RefreshBagSlotWindow(self):
|
||||
_refreshBag(self)
|
||||
attached=set()
|
||||
if IsSashWindowOpen():
|
||||
for j in xrange(sash.WINDOW_MAX_MATERIALS):
|
||||
(isHere,iCell)=sash.GetAttachedItem(j)
|
||||
if isHere:attached.add(iCell)
|
||||
lit=getattr(self,'mtSashLit',set())
|
||||
now=set()
|
||||
for i in xrange(player.INVENTORY_PAGE_SIZE):
|
||||
cell=self._InventoryWindow__InventoryLocalSlotPosToGlobalSlotPos(i)
|
||||
if cell in attached:
|
||||
self.wndItem.ActivateSlot(i);now.add(i)
|
||||
elif i in lit and not AutoPotionActive(cell):
|
||||
self.wndItem.DeactivateSlot(i)
|
||||
self.mtSashLit=now
|
||||
self.wndItem.RefreshSlot()
|
||||
|
||||
uiInventory.InventoryWindow.UseItemSlot=UseItemSlot
|
||||
uiInventory.InventoryWindow.RefreshBagSlotWindow=RefreshBagSlotWindow
|
||||
|
||||
|
||||
# --- game window: ActSash/AlertSash (called by the GC_SASH packet), MTSASH messages, effects -----------------
|
||||
def RegisterEffects():
|
||||
global g_effects
|
||||
if g_effects:return
|
||||
g_effects=True
|
||||
chrmgr.RegisterEffect(chrmgr.EFFECT_SASH_SUCCEDED,"","d:/ymir work/effect/etc/buff/buff_item6.mse")
|
||||
chrmgr.RegisterEffect(chrmgr.EFFECT_SASH_EQUIP,"","d:/ymir work/effect/etc/buff/buff_item7.mse")
|
||||
chrmgr.RegisterEffect(chrmgr.EFFECT_REFINED+chrmgr.EFFECT_SASH,"Bip01","d:/ymir work/pc/common/effect/armor/acc_01.mse")
|
||||
|
||||
|
||||
_open=game.GameWindow.Open
|
||||
_close=game.GameWindow.Close
|
||||
_command=game.GameWindow.BINARY_ServerCommand_Run
|
||||
|
||||
def Open(self):
|
||||
global g_windows
|
||||
_open(self)
|
||||
RegisterEffects()
|
||||
g_windows=(CombineWindow(),AbsorbWindow())
|
||||
for window in g_windows:
|
||||
window.LoadWindow();window.Hide()
|
||||
if self.interface:window.SetItemToolTip(self.interface.tooltipItem)
|
||||
|
||||
def Close(self):
|
||||
global g_windows
|
||||
if g_windows:
|
||||
for window in g_windows:window.Close();window.Destroy()
|
||||
g_windows=None
|
||||
_close(self)
|
||||
|
||||
def ActSash(self,iAct,bWindow):
|
||||
if not g_windows or not self.interface:return
|
||||
window=g_windows[0 if bWindow else 1]
|
||||
inventory=self.interface.wndInventory
|
||||
if iAct==1:
|
||||
if not window.IsOpened():window.Open()
|
||||
if inventory and not inventory.IsShow():inventory.Show()
|
||||
elif iAct==2:
|
||||
if window.IsOpened():window.Close()
|
||||
elif iAct==3 or iAct==4:
|
||||
if window.IsOpened():window.Refresh(iAct)
|
||||
if inventory:inventory.RefreshBagSlotWindow()
|
||||
|
||||
def AlertSash(self,bWindow):
|
||||
self.PopupMessage(L(ALERT_COMBINE if bWindow else ALERT_ABSORB))
|
||||
|
||||
def Command(self,line):
|
||||
if line.startswith('MTSASH '):
|
||||
words=line.split()
|
||||
if len(words)==3 and words[1]=='abs' and words[2].isdigit():text=ABS_CHANGED%int(words[2])
|
||||
else:text=MESSAGES.get(words[1] if len(words)>1 else '')
|
||||
if text:chat.AppendChat(chat.CHAT_TYPE_INFO,L(text))
|
||||
return 1
|
||||
return _command(self,line)
|
||||
|
||||
game.GameWindow.Open=Open
|
||||
game.GameWindow.Close=Close
|
||||
game.GameWindow.ActSash=ActSash
|
||||
game.GameWindow.AlertSash=AlertSash
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
)PY";
|
||||
Reference in New Issue
Block a user