feat: add MeshPort overlay networking, item actions window, and AVA2 client enhancements
- add MeshPort peer-to-peer overlay networking SDK, C++ integration, and Python bindings - add item actions quick use/split/delete/lock overlay window (mt_item_actions) - add shop name range and NPC name visibility settings to system display options - support battlepass ticket activation and month validation in mt_battlepass - support boss tracking teleport destination button in mt_bosses - support asynchronous account registration cancellation and pending login cancellation - update AVA2 item conversion for attr lock scrolls and battlepass tickets - update .gitignore for local build outputs and caches
This commit is contained in:
@@ -11,6 +11,7 @@ import grp
|
||||
import item
|
||||
import net
|
||||
import nonplayer
|
||||
import player
|
||||
import ui
|
||||
import weakref
|
||||
from mt_biolog import Action, Text, L
|
||||
@@ -29,7 +30,8 @@ TYPES={1:('击杀怪物','击杀 ','mob'),2:('击杀 Boss','击杀 Boss ','mob')
|
||||
9:(None,'向 NPC 出售 ','item')}
|
||||
ERRORS={'loading':'数据加载中,请稍后再试','slot':'没有这个任务','claimed':'奖励已经领取过了','incomplete':'任务尚未完成',
|
||||
'space':'背包空间不足,请整理后再领取','config':'奖励配置有误,请联系管理员','db':'服务器繁忙,请稍后再试',
|
||||
'rate':'操作过快,请稍后再试','invalid':'参数无效'}
|
||||
'rate':'操作过快,请稍后再试','invalid':'参数无效','ticket':'请使用当月战令票激活','month':'这张战令票不属于当前月份',
|
||||
'activated':'本月战令已经激活过了','busy':'请先结束交易、商店、仓库或传送'}
|
||||
|
||||
|
||||
def Number(text,low=0,high=10**12):
|
||||
@@ -86,7 +88,7 @@ class Pass(object):
|
||||
self.Clear()
|
||||
|
||||
def Clear(self):
|
||||
self.season=None;self.missions={};self.final=None;self.reading=None;self.none=False;self.error=None;self.claiming=None
|
||||
self.season=None;self.missions={};self.final=None;self.reading=None;self.none=False;self.error=None;self.claiming=None;self.access=None;self.month=None
|
||||
|
||||
def Ready(self):
|
||||
return self.waiting is None or self.now()>=self.waiting
|
||||
@@ -104,10 +106,15 @@ class Pass(object):
|
||||
return self.Post('/mt_bp 1 info')
|
||||
|
||||
def Claim(self,slot):
|
||||
if self.claiming is not None or not self.season:return False
|
||||
if self.claiming is not None or not self.season or self.access not in (None,1):return False
|
||||
if self.Post('/mt_bp 1 claim %d'%slot):self.claiming=slot;self.error=None;return True
|
||||
return False
|
||||
|
||||
def Activate(self,cell,vnum):
|
||||
if self.access!=0 or self.waiting is not None or not 25150<=vnum<=25161:return False
|
||||
if player.GetItemIndex(cell)!=vnum:return False
|
||||
return self.Post('/mt_bp 1 activate %d %d'%(cell,vnum))
|
||||
|
||||
def Close(self):
|
||||
self.send('/mt_bp 1 close')
|
||||
|
||||
@@ -135,7 +142,10 @@ class Pass(object):
|
||||
def Parse(self,kind,args):
|
||||
if kind=='season' and len(args)==5:
|
||||
seasonId,start,end,now=[Number(w,0,2**32-1) for w in args[:4]];count=Number(args[4],1,MAX_SLOT)
|
||||
self.reading=dict(season=(seasonId,start,end,now,self.now()),count=count,missions={},final=None)
|
||||
self.reading=dict(season=(seasonId,start,end,now,self.now()),count=count,missions={},final=None,access=None,month=None)
|
||||
elif kind=='access' and len(args) in (1,2) and self.reading is not None:
|
||||
self.reading['access']=Number(args[0],0,2)
|
||||
if len(args)==2:self.reading['month']=Number(args[1],1,12)
|
||||
elif kind=='mission' and self.reading is not None and len(args)>=6:
|
||||
slot=Number(args[0],1,MAX_SLOT);kind=Number(args[1],1,9)
|
||||
self.reading['missions'][slot]=dict(slot=slot,type=kind,sub=Number(args[2],0,2**32-1),target=Number(args[3],1),
|
||||
@@ -145,7 +155,7 @@ class Pass(object):
|
||||
elif kind=='end' and not args and self.reading is not None:
|
||||
r=self.reading;self.reading=None
|
||||
if len(r['missions'])!=r['count'] or r['final'] is None:return
|
||||
self.season=r['season'];self.missions=r['missions'];self.final=r['final'];self.none=False
|
||||
self.season=r['season'];self.missions=r['missions'];self.final=r['final'];self.access=r['access'];self.month=r['month'];self.none=False
|
||||
self.Answered('info')
|
||||
elif kind=='none' and not args:
|
||||
self.Clear();self.none=True;self.Answered('none')
|
||||
@@ -214,6 +224,8 @@ class BattlePassWindow(ui.Window):
|
||||
self.finalState=Text(self,330,y+4,'')
|
||||
self.finalReward=Text(self,18,y+26,'',0xffb3aa98)
|
||||
self.finalButton=Action(self,WIDTH-118,y,100,'领取',lambda:self.state.Claim(0) and self.Refresh())
|
||||
self.activateButton=Action(self,WIDTH-218,y,200,'使用当月战令票激活',self.AskActivate)
|
||||
self.activateButton.Hide();self.confirm=None;self.pendingTicket=None
|
||||
y=self.GetHeight()-56
|
||||
self.prev=Action(self,18,y,80,'上一页',lambda:self.Turn(-1))
|
||||
self.pageText=Text(self,140,y+24,'');self.pageText.SetHorizontalAlignCenter()
|
||||
@@ -232,8 +244,43 @@ class BattlePassWindow(ui.Window):
|
||||
def Hide(self):
|
||||
state=self.__dict__.get('state') # ui.Window.__init__ hides the window before state is set
|
||||
if self.IsShow() and state and state.season:state.Close()
|
||||
self.pendingTicket=None
|
||||
self.CloseConfirm()
|
||||
ui.Window.Hide(self)
|
||||
|
||||
def CloseConfirm(self):
|
||||
confirm=self.__dict__.get('confirm')
|
||||
if confirm:
|
||||
confirm.Close();confirm.SetAcceptEvent(None);confirm.SetCancelEvent(None);self.confirm=None
|
||||
|
||||
def OfferTicket(self,cell,vnum):
|
||||
self.pendingTicket=(cell,vnum)
|
||||
self.Open()
|
||||
|
||||
def AskTicket(self,cell,vnum):
|
||||
if self.state.access!=0 or player.GetItemIndex(cell)!=vnum:return
|
||||
item.SelectItem(vnum)
|
||||
if item.GetValue(0)!=self.state.month:self.state.error='month';self.Refresh();return
|
||||
import uiCommon
|
||||
self.CloseConfirm();self.confirm=uiCommon.QuestionDialog()
|
||||
self.confirm.SetText(L('消耗战令票并激活本月战令?'))
|
||||
self.confirm.SetAcceptEvent(lambda:self.ConfirmActivate(cell,vnum))
|
||||
self.confirm.SetCancelEvent(self.CloseConfirm);self.confirm.Open()
|
||||
|
||||
def AskActivate(self):
|
||||
if self.state.access!=0:return
|
||||
for cell in range(player.INVENTORY_PAGE_SIZE*player.INVENTORY_PAGE_COUNT):
|
||||
vnum=player.GetItemIndex(cell)
|
||||
if not 25150<=vnum<=25161:continue
|
||||
item.SelectItem(vnum)
|
||||
# Display uses server time, not the phone's local month/time zone.
|
||||
if item.GetValue(0)!=self.state.month:continue
|
||||
self.AskTicket(cell,vnum);return
|
||||
self.state.error='ticket';self.Refresh()
|
||||
|
||||
def ConfirmActivate(self,cell,vnum):
|
||||
self.CloseConfirm();self.state.Activate(cell,vnum);self.Refresh()
|
||||
|
||||
def Slots(self):
|
||||
return sorted(self.state.missions)
|
||||
|
||||
@@ -264,7 +311,7 @@ class BattlePassWindow(ui.Window):
|
||||
if m['claimed']:row['button'].SetText('已领取')
|
||||
elif s.claiming==m['slot']:row['button'].SetText('领取中')
|
||||
else:row['button'].SetText('领取' if done else '未完成')
|
||||
row['button'].SetEnabled(done and not m['claimed'] and bool(m['rewards']) and s.claiming is None)
|
||||
row['button'].SetEnabled(s.access in (None,1) and done and not m['claimed'] and bool(m['rewards']) and s.claiming is None)
|
||||
f=s.final
|
||||
for w in (self.finalName,self.finalState,self.finalReward,self.finalButton):
|
||||
if f:w.Show()
|
||||
@@ -274,7 +321,11 @@ class BattlePassWindow(ui.Window):
|
||||
self.finalState.SetText(L('已领取' if f['claimed'] else '全部任务完成' if ready else '完成全部任务后可领取'))
|
||||
self.finalReward.SetText(L('奖励:')+RewardText(f['rewards']))
|
||||
self.finalButton.SetText('已领取' if f['claimed'] else '领取中' if s.claiming==0 else '领取')
|
||||
self.finalButton.SetEnabled(ready and not f['claimed'] and s.claiming is None)
|
||||
self.finalButton.SetEnabled(s.access in (None,1) and ready and not f['claimed'] and s.claiming is None)
|
||||
if s.access==0:
|
||||
self.finalButton.Hide();self.finalState.Hide();self.finalReward.Hide();self.activateButton.Show()
|
||||
self.activateButton.SetEnabled(s.waiting is None)
|
||||
else:self.activateButton.Hide()
|
||||
many=self.Pages()>1
|
||||
for w in (self.prev,self.next,self.pageText):
|
||||
if many and s.season:w.Show()
|
||||
@@ -288,6 +339,8 @@ class BattlePassWindow(ui.Window):
|
||||
elif s.none:note='当前没有进行中的战令赛季'
|
||||
elif not s.season:note='正在查询……'
|
||||
elif s.claiming is not None:note='正在领取……'
|
||||
elif s.access==0:note='激活后才开始累计进度'
|
||||
elif s.access==2:note='本月战令已完成'
|
||||
else:note='击杀、钓鱼、强化等都会自动计入进度'
|
||||
self.note.SetText(L(note))
|
||||
|
||||
@@ -305,7 +358,7 @@ class BattlePassWindow(ui.Window):
|
||||
def OnPressEscapeKey(self):self.Hide();return True
|
||||
|
||||
def Destroy(self):
|
||||
self.Hide();self.closeButton.event=self.finalButton.event=self.prev.event=self.next.event=None
|
||||
self.Hide();self.closeButton.event=self.finalButton.event=self.activateButton.event=self.prev.event=self.next.event=None
|
||||
for row in self.rows:row['button'].event=None
|
||||
self.state=None
|
||||
|
||||
@@ -327,7 +380,10 @@ def OnPass(kind,value):
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('战令任务完成:')+name+L(',按 F6 领取奖励'))
|
||||
elif kind=='claimed':chat.AppendChat(chat.CHAT_TYPE_INFO,L('战令奖励已放入背包' if value else '战令最终奖励已放入背包'))
|
||||
elif kind=='error':chat.AppendChat(chat.CHAT_TYPE_INFO,L(ERRORS[s.error]))
|
||||
if g_window and g_window.IsShow():g_window.Refresh()
|
||||
if g_window and g_window.IsShow():
|
||||
if kind=='info' and g_window.pendingTicket:
|
||||
ticket=g_window.pendingTicket;g_window.pendingTicket=None;g_window.AskTicket(*ticket)
|
||||
g_window.Refresh()
|
||||
|
||||
|
||||
g_pass=Pass(net.SendChatPacket,app.GetTime,OnPass)
|
||||
|
||||
@@ -24,6 +24,20 @@ g_tick=None
|
||||
PAGE=8
|
||||
REFRESH=30.
|
||||
SHARED_CHANNEL=99
|
||||
TRAVEL_LEVELS={9844:(40,60),9836:(65,85),9838:(80,100),9840:(95,115),9842:(105,120),
|
||||
1093:(40,120),2092:(70,120),2493:(75,120),2598:(80,120),6091:(90,120),
|
||||
6191:(90,120),9018:(105,120),20442:(110,120)}
|
||||
|
||||
|
||||
def Travel(vnum,done=None):
|
||||
service=mt_feature_service.g_service
|
||||
if not service:return
|
||||
def received(data,error):
|
||||
errors={'unsupported':'服务器未启用此入口传送','level':'等级不符合入口要求',
|
||||
'busy':'当前状态不能传送,请稍后再试','unavailable':'服务器尚未开放该地图'}
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L(errors.get(error,'传送失败,请稍后重试') if error else '正在前往入口'))
|
||||
if done:done(data,error)
|
||||
service.Request('travel',vnum,0,received)
|
||||
# Server map index -> map directory (share/locale/<locale>/map/index), for localeInfo.MINIMAP_ZONE_NAME_DICT.
|
||||
MAPS={1:'metin2_map_a1',3:'metin2_map_a3',4:'metin2_map_guild_01',5:'metin2_map_monkey_dungeon_11',
|
||||
6:'metin2_guild_village_01',21:'metin2_map_b1',23:'metin2_map_b3',24:'metin2_map_guild_02',
|
||||
@@ -117,10 +131,11 @@ class BossWindow(ui.Window):
|
||||
self.lines=[Text(self,18,0,'',0xffefdfc3) for i in range(PAGE)]
|
||||
self.details=[Text(self,30,0,'',0xffb2aa9a) for i in range(PAGE)]
|
||||
self.remindButtons=[Action(self,0,0,92,'',lambda i=i:self.Remind(i)) for i in range(PAGE)]
|
||||
self.travelButtons=[Action(self,0,0,72,'传送',lambda i=i:self.Teleport(i)) for i in range(PAGE)]
|
||||
self.note=Text(self,18,0,'提醒:Boss 刷新后在聊天框提示;以服务器刷新为准。',0xffb2aa9a)
|
||||
self.Reflow();self.Hide()
|
||||
|
||||
def Buttons(self):return [self.closeButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons
|
||||
def Buttons(self):return [self.closeButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons+self.travelButtons
|
||||
|
||||
def Open(self):
|
||||
self.Reflow();self.SetCenterPosition();self.Show();self.SetTop();self.Query()
|
||||
@@ -147,6 +162,12 @@ class BossWindow(ui.Window):
|
||||
rows=self.tracker.rows or [];index=self.page*PAGE+i
|
||||
if index<len(rows):self.tracker.Toggle(rows[index]);self.Render()
|
||||
|
||||
def Teleport(self,i):
|
||||
rows=self.tracker.rows or [];index=self.page*PAGE+i
|
||||
if index>=len(rows) or rows[index]['vnum'] not in TRAVEL_LEVELS:return
|
||||
self.travelButtons[i].SetEnabled(False)
|
||||
Travel(rows[index]['vnum'],lambda data,error:self.Render())
|
||||
|
||||
def Render(self):
|
||||
t=self.tracker;rows=t.rows or [];self.page=min(self.page,self.Pages()-1)
|
||||
if t.error:self.status.SetText(L('服务端未启用 Boss 追踪' if t.error=='unsupported' else '未同步,请稍后刷新'))
|
||||
@@ -156,6 +177,7 @@ class BossWindow(ui.Window):
|
||||
self.prevButton.SetEnabled(self.page>0);self.nextButton.SetEnabled(self.page+1<self.Pages())
|
||||
for i in range(PAGE):
|
||||
index=self.page*PAGE+i;line=self.lines[i];detail=self.details[i];button=self.remindButtons[i]
|
||||
travel=self.travelButtons[i];travel.Hide()
|
||||
if index>=len(rows):line.Hide();detail.Hide();button.Hide();continue
|
||||
r=rows[index];left=t.Left(r)
|
||||
channel='共享' if r['channel']==SHARED_CHANNEL else 'CH%d'%r['channel']
|
||||
@@ -169,6 +191,9 @@ class BossWindow(ui.Window):
|
||||
button.SetText(L('提醒:'+('开' if Key(r) in t.reminders else '关')))
|
||||
button.SetEnabled(bool(r['alive']==0 and r['next']) or Key(r) in t.reminders)
|
||||
line.Show();detail.Show();button.Show()
|
||||
service=mt_feature_service.g_service
|
||||
if r['vnum'] in TRAVEL_LEVELS and service and service.mask is not None and service.mask&512:
|
||||
travel.Show();travel.SetEnabled(not service.pending and not service.queue)
|
||||
|
||||
def Reflow(self):
|
||||
dims=(wndMgr.GetScreenWidth(),wndMgr.GetScreenHeight())
|
||||
@@ -179,6 +204,7 @@ class BossWindow(ui.Window):
|
||||
for i in range(PAGE):
|
||||
y=88+i*spacing
|
||||
self.lines[i].SetPosition(18,y);self.details[i].SetPosition(30,y+18);self.remindButtons[i].SetPosition(width-110,y)
|
||||
self.travelButtons[i].SetPosition(width-190,y)
|
||||
self.note.SetPosition(18,height-22);self.SetCenterPosition()
|
||||
|
||||
def OnUpdate(self):
|
||||
|
||||
@@ -21,18 +21,22 @@ LEVEL_HINTS=('显示所有角色的特效','隐藏其他玩家和NPC的特效,
|
||||
|
||||
|
||||
class Options(object):
|
||||
def __init__(self):self.effect=0;self.tree=True;self.cloud=True
|
||||
def __init__(self):self.effect=0;self.tree=True;self.cloud=True;self.shopRange=0;self.npcNames=True
|
||||
|
||||
def Load(self,text):
|
||||
words=text.split()
|
||||
if len(words)!=3 or not all(w.isdigit() and len(w)==1 for w in words):return
|
||||
effect,tree,cloud=[int(w) for w in words]
|
||||
if effect<len(LEVELS) and tree in (0,1) and cloud in (0,1):self.effect=effect;self.tree=tree==1;self.cloud=cloud==1
|
||||
if len(words) not in (3,5) or not all(w.isdigit() and len(w)==1 for w in words):return
|
||||
effect,tree,cloud=[int(w) for w in words[:3]]
|
||||
shop,names=[int(w) for w in words[3:]] if len(words)==5 else (0,1)
|
||||
if effect<len(LEVELS) and tree in (0,1) and cloud in (0,1) and shop<5 and names in (0,1):
|
||||
self.effect=effect;self.tree=tree==1;self.cloud=cloud==1;self.shopRange=shop;self.npcNames=names==1
|
||||
|
||||
def Dump(self):return '%d %d %d'%(self.effect,int(self.tree),int(self.cloud))
|
||||
def Dump(self):return '%d %d %d %d %d'%(self.effect,int(self.tree),int(self.cloud),self.shopRange,int(self.npcNames))
|
||||
|
||||
def Apply(self):
|
||||
systemSetting.SetEffectLevel(self.effect)
|
||||
systemSetting.SetShopNamesRange(self.shopRange)
|
||||
systemSetting.SetShopNameStatus(self.npcNames)
|
||||
background.SetVisiblePart(background.PART_TREE,int(self.tree))
|
||||
background.SetVisiblePart(background.PART_CLOUD,int(self.cloud))
|
||||
|
||||
@@ -55,7 +59,7 @@ def Mark(text,on):return L(B(u'【%s】'%text if on else text))
|
||||
class DisplayWindow(ui.Window):
|
||||
def __init__(self,options):
|
||||
ui.Window.__init__(self);self.SetWindowName('DisplayWindow');self.AddFlag('float');self.AddFlag('movable')
|
||||
self.options=options;self.SetSize(332,404)
|
||||
self.options=options;self.SetSize(332,456)
|
||||
self.heading=Text(self,18,18,'显示设置',0xffffd68b)
|
||||
self.closeButton=Action(self,256,6,60,'关闭',self.Hide)
|
||||
self.effectText=Text(self,18,54,'特效',0xffc3b7a1)
|
||||
@@ -65,10 +69,12 @@ class DisplayWindow(ui.Window):
|
||||
self.cloudButton=Action(self,170,260,144,'',self.ToggleCloud)
|
||||
self.nameButton=Action(self,18,312,144,'',self.ToggleName)
|
||||
self.damageButton=Action(self,170,312,144,'',self.ToggleDamage)
|
||||
self.status=Text(self,18,376,'',0xffc3b7a1)
|
||||
self.rangeButton=Action(self,18,364,144,'',self.NextRange)
|
||||
self.npcButton=Action(self,170,364,144,'',self.ToggleNPC)
|
||||
self.status=Text(self,18,428,'',0xffc3b7a1)
|
||||
self.Refresh();self.Hide()
|
||||
|
||||
def Buttons(self):return [self.closeButton,self.treeButton,self.cloudButton,self.nameButton,self.damageButton]+self.levelButtons
|
||||
def Buttons(self):return [self.closeButton,self.treeButton,self.cloudButton,self.nameButton,self.damageButton,self.rangeButton,self.npcButton]+self.levelButtons
|
||||
|
||||
def Open(self):self.Refresh();self.SetCenterPosition();self.Show();self.SetTop()
|
||||
|
||||
@@ -80,6 +86,10 @@ class DisplayWindow(ui.Window):
|
||||
|
||||
def ToggleCloud(self):self.options.cloud=not self.options.cloud;self.Changed()
|
||||
|
||||
def NextRange(self):self.options.shopRange=(self.options.shopRange+1)%5;self.Changed()
|
||||
|
||||
def ToggleNPC(self):self.options.npcNames=not self.options.npcNames;self.Changed()
|
||||
|
||||
# Names and damage numbers are the original game options (saved by the client config on exit).
|
||||
def ToggleName(self):systemSetting.SetAlwaysShowNameFlag(not systemSetting.IsAlwaysShowName());self.Refresh()
|
||||
|
||||
@@ -91,6 +101,8 @@ class DisplayWindow(ui.Window):
|
||||
self.treeButton.SetText(Mark(u'显示树木',o.tree));self.cloudButton.SetText(Mark(u'显示云',o.cloud))
|
||||
self.nameButton.SetText(Mark(u'总是显示名字',systemSetting.IsAlwaysShowName()))
|
||||
self.damageButton.SetText(Mark(u'显示伤害数字',systemSetting.IsShowDamage()))
|
||||
self.rangeButton.SetText(L(B(u'摊位范围 %d 米'%((100,60,40,20,10)[o.shopRange]))))
|
||||
self.npcButton.SetText(Mark(u'显示NPC名称',o.npcNames))
|
||||
self.status.SetText(L(LEVEL_HINTS[o.effect]))
|
||||
|
||||
def OnRender(self):
|
||||
|
||||
@@ -33,6 +33,7 @@ class DungeonWindow(ui.Window):
|
||||
self.rows=[Text(self,24,142+32*i,'',0xffefdfc3) for i in range(6)]
|
||||
self.remindButton=Action(self,18,0,146,'到期提醒:关',self.Remind)
|
||||
self.entryButton=Action(self,180,0,146,'查看入口',self.Entry)
|
||||
self.travelButton=Action(self,342,0,146,'传送到入口',self.Travel)
|
||||
self.note=Text(self,18,0,'当前仅接入已核实的龙穴及相关周任务。',0xffb2aa9a)
|
||||
self.Reflow();self.Hide()
|
||||
|
||||
@@ -92,6 +93,15 @@ class DungeonWindow(ui.Window):
|
||||
self.remindButton.SetText('到期提醒:'+('开' if self.reminder is not None and self.reminder[0]==self.tab else '关'))
|
||||
self.remindButton.SetEnabled(v is not None and not self.stale and (self.tab==0 or 'weekly_end' in v))
|
||||
self.entryButton.SetEnabled(v is not None and not self.stale and (self.tab==0 or 'weekly_npc' in v))
|
||||
service=mt_feature_service.g_service
|
||||
if self.tab==0 and service and service.mask is not None and service.mask&512:self.travelButton.Show()
|
||||
else:self.travelButton.Hide()
|
||||
self.travelButton.SetEnabled(v is not None and not self.stale)
|
||||
|
||||
def Travel(self):
|
||||
if self.values is None or self.stale or self.tab!=0:return
|
||||
import mt_boss
|
||||
mt_boss.Travel(2493)
|
||||
|
||||
def Entry(self):
|
||||
if self.values is None or self.stale:return
|
||||
@@ -124,6 +134,7 @@ class DungeonWindow(ui.Window):
|
||||
if dims==self.dimensions:return
|
||||
self.dimensions=dims;width=min(660,max(500,dims[0]-16));height=min(450,max(300,dims[1]-16));self.SetSize(width,height)
|
||||
self.closeButton.SetPosition(width-76,6)
|
||||
self.travelButton.SetPosition(342,height-74)
|
||||
spacing=min(32,max(16,(height-250)//5))
|
||||
for i,row in enumerate(self.rows):row.SetPosition(24,132+i*spacing)
|
||||
self.remindButton.SetPosition(18,height-74);self.entryButton.SetPosition(180,height-74);self.note.SetPosition(18,height-18)
|
||||
@@ -148,7 +159,7 @@ class DungeonWindow(ui.Window):
|
||||
|
||||
def Destroy(self):
|
||||
self.generation+=1;self.reminder=None;self.values=None;self.Hide()
|
||||
for b in (self.closeButton,self.lairButton,self.weeklyButton,self.refreshButton,self.remindButton,self.entryButton):b.event=None
|
||||
for b in (self.closeButton,self.lairButton,self.weeklyButton,self.refreshButton,self.remindButton,self.entryButton,self.travelButton):b.event=None
|
||||
|
||||
|
||||
class ReminderTick(ui.Window):
|
||||
|
||||
@@ -6,7 +6,7 @@ import net
|
||||
import ui
|
||||
from mt_wiki_data import Number
|
||||
|
||||
BITS={'mob':1,'chest':2,'stats':4,'sources':8,'dungeons':16,'calendar':32,'bosses':256}
|
||||
BITS={'mob':1,'chest':2,'stats':4,'sources':8,'dungeons':16,'calendar':32,'bosses':256,'travel':512}
|
||||
WHOLE=('stats','dungeons','bosses') # one reply with every row; no subject or page
|
||||
g_service=None
|
||||
g_tick=None
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// PORT: touch equivalents of AVA2's inventory preview / chest shortcuts.
|
||||
// Native touch selection invokes ShowInventory; no synthetic modifier keys.
|
||||
static const char c_szItemActionsScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import game
|
||||
import grp
|
||||
import player
|
||||
import ui
|
||||
import uiInventory
|
||||
import weakref
|
||||
import wndMgr
|
||||
from mt_biolog import Action
|
||||
|
||||
g_window=None
|
||||
|
||||
|
||||
class ItemActions(ui.Window):
|
||||
def __init__(self):
|
||||
ui.Window.__init__(self);self.AddFlag('float');self.SetWindowName('TouchItemActions')
|
||||
self.snapshot=None;self.buttons=[];self.Hide()
|
||||
|
||||
def Clear(self):
|
||||
self.Hide();self.snapshot=None
|
||||
for button in self.buttons:button.Hide();button.event=None
|
||||
self.buttons=[]
|
||||
|
||||
def Valid(self):
|
||||
if not self.snapshot:return False
|
||||
try:
|
||||
owner,page,cell,vnum,count=self.snapshot
|
||||
return (owner.IsShow() and owner.inventoryPageIndex==page and
|
||||
player.GetItemIndex(cell)==vnum and player.GetItemCount(cell)==count)
|
||||
except ReferenceError:return False
|
||||
|
||||
def Select(self,owner,cell):
|
||||
self.Clear()
|
||||
vnum=player.GetItemIndex(cell)
|
||||
if not vnum:return
|
||||
self.snapshot=(weakref.proxy(owner),owner.inventoryPageIndex,cell,vnum,player.GetItemCount(cell))
|
||||
import mt_preview
|
||||
import mt_chest
|
||||
import mt_wiki
|
||||
choices=[('百科',lambda:mt_wiki.OpenItem(vnum))]
|
||||
if mt_preview.ItemSpec(vnum):choices.append(('模型预览',lambda:mt_preview.Preview('item',vnum)))
|
||||
if mt_chest.g_window and mt_chest.Batchable(vnum):
|
||||
choices.append(('批量开箱',lambda:mt_chest.g_window.Select(cell,vnum)))
|
||||
choices.append(('关闭',self.Clear))
|
||||
for i,(label,action) in enumerate(choices):
|
||||
self.buttons.append(Action(self,8+i*108,6,100,label,lambda action=action:self.Run(action)))
|
||||
self.SetSize(16+len(choices)*108,60)
|
||||
x,y=owner.GetGlobalPosition()
|
||||
self.SetPosition(max(0,min(x,wndMgr.GetScreenWidth()-self.GetWidth())),
|
||||
max(0,min(y+owner.GetHeight(),wndMgr.GetScreenHeight()-self.GetHeight())))
|
||||
self.Show();self.SetTop()
|
||||
|
||||
def Run(self,action):
|
||||
valid=self.Valid();self.Clear()
|
||||
if valid:action()
|
||||
|
||||
def OnUpdate(self):
|
||||
if self.IsShow() and not self.Valid():self.Clear()
|
||||
|
||||
def OnRender(self):
|
||||
x,y=self.GetGlobalPosition();grp.SetColor(0xf51b1916);grp.RenderBar(x,y,self.GetWidth(),self.GetHeight())
|
||||
|
||||
def OnPressEscapeKey(self):self.Clear();return True
|
||||
|
||||
|
||||
def ShowInventory(owner,cell):
|
||||
if g_window:g_window.Select(owner,cell)
|
||||
|
||||
|
||||
_open=game.GameWindow.Open
|
||||
_close=game.GameWindow.Close
|
||||
|
||||
def Open(self):
|
||||
global g_window
|
||||
_open(self);g_window=ItemActions()
|
||||
|
||||
def Close(self):
|
||||
global g_window
|
||||
if g_window:g_window.Clear();g_window=None
|
||||
_close(self)
|
||||
|
||||
game.GameWindow.Open=Open
|
||||
game.GameWindow.Close=Close
|
||||
|
||||
_use=uiInventory.InventoryWindow.UseItemSlot
|
||||
|
||||
def UseItemSlot(self,slot):
|
||||
cell=self._InventoryWindow__InventoryLocalSlotPosToGlobalSlotPos(slot)
|
||||
vnum=player.GetItemIndex(cell)
|
||||
if 25150<=vnum<=25161:
|
||||
import mt_battlepass
|
||||
if mt_battlepass.g_window:mt_battlepass.g_window.OfferTicket(cell,vnum)
|
||||
return
|
||||
if vnum in (50348,50349):
|
||||
import mt_switchbot
|
||||
if mt_switchbot.g_window:mt_switchbot.g_window.Open()
|
||||
return
|
||||
return _use(self,slot)
|
||||
|
||||
uiInventory.InventoryWindow.UseItemSlot=UseItemSlot
|
||||
)PY";
|
||||
@@ -0,0 +1,30 @@
|
||||
// PORT: networking is prepared by the native transport, independently of the login UI.
|
||||
#include <Python.h>
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
#include "transport.h"
|
||||
#include "MeshPortConfig.h"
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
namespace {
|
||||
PyObject* event(PyObject*,PyObject*) { return PyInt_FromLong(mt::meshport::take_event()); }
|
||||
PyObject* local(PyObject*,PyObject* args) {
|
||||
const char* ip;if(!PyArg_ParseTuple(args,"s",&ip))return nullptr;
|
||||
return PyBool_FromLong(mt::meshport::same_subnet(ip));
|
||||
}
|
||||
PyMethodDef methods[]={
|
||||
{"event",event,METH_NOARGS,nullptr},{"same_subnet",local,METH_VARARGS,nullptr},
|
||||
{nullptr,nullptr,0,nullptr}
|
||||
};
|
||||
}
|
||||
void initMeshPort() {
|
||||
std::string config=kMeshPortConfig;
|
||||
if(const char* path=std::getenv("MT_MESHPORT_CONFIG")) {
|
||||
std::ifstream input(path,std::ios::binary);
|
||||
config.assign(std::istreambuf_iterator<char>(input),{});
|
||||
}
|
||||
if(config.size()>65536)config.clear();
|
||||
mt::meshport::configure(config);
|
||||
Py_InitModule("_mt_meshport",methods);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
// PORT: native transport owns routing; Python displays status and handles pending-login cancellation.
|
||||
static const char* c_szMeshPortScript = R"PY(# -*- coding: utf-8 -*-
|
||||
import app
|
||||
import ui
|
||||
import wndMgr
|
||||
import player
|
||||
import introLogin
|
||||
import net
|
||||
import _mt_meshport as native
|
||||
|
||||
|
||||
class NetworkNotice(ui.Window):
|
||||
def __init__(self):
|
||||
ui.Window.__init__(self)
|
||||
self.label = ui.TextLine()
|
||||
self.label.SetHorizontalAlignCenter()
|
||||
self.hideAt = 0
|
||||
self.Show()
|
||||
|
||||
def OnUpdate(self):
|
||||
event = native.event()
|
||||
if event:
|
||||
messages = {1: '正在组网,等待动态分配 IP...',
|
||||
2: '组网成功', 3: '组网连接失败,请检查网络后重试'}
|
||||
self.label.SetText(player.AutoHuntLocalize(messages[event]))
|
||||
self.label.SetPackedFontColor(0xff66ee88 if event == 2 else 0xffffdd77)
|
||||
self.label.SetPosition(wndMgr.GetScreenWidth() / 2, 32)
|
||||
self.label.Show()
|
||||
self.label.SetTop()
|
||||
self.hideAt = app.GetTime() + (65 if event == 1 else 6)
|
||||
if self.hideAt and app.GetTime() >= self.hideAt:
|
||||
self.label.Hide()
|
||||
self.hideAt = 0
|
||||
|
||||
|
||||
notice = NetworkNotice()
|
||||
|
||||
# Original login popup uses the focus callback for its Cancel button. Stop only
|
||||
# the account/game transports still preparing; leave established sessions and
|
||||
# background channel queries alone. No credentials or Connect methods are wrapped.
|
||||
def _wrap_cancel(method):
|
||||
def Cancel(self, *args):
|
||||
if net.CancelPendingLogin():
|
||||
notice.label.Hide()
|
||||
notice.hideAt = 0
|
||||
return method(self, *args)
|
||||
return Cancel
|
||||
|
||||
introLogin.LoginWindow.SetPasswordEditLineFocus = _wrap_cancel(introLogin.LoginWindow.SetPasswordEditLineFocus)
|
||||
introLogin.LoginWindow.OnPressExitKey = _wrap_cancel(introLogin.LoginWindow.OnPressExitKey)
|
||||
introLogin.LoginWindow.Close = _wrap_cancel(introLogin.LoginWindow.Close)
|
||||
)PY";
|
||||
@@ -56,6 +56,9 @@ def _Select(self, slot):
|
||||
_last_time = app.GetTime()
|
||||
if _last[3]:
|
||||
self.ShowToolTip(_last[2])
|
||||
import sys
|
||||
actions = sys.modules.get('mt_item_actions')
|
||||
if actions:actions.ShowInventory(self, _last[2])
|
||||
return
|
||||
snapshot = _Snapshot(self, slot) if dragging and not mouse.isAttached() else None
|
||||
result = _OriginalSelect(self, slot)
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
#include "UserInterface/CRenderTargetManager.h"
|
||||
#include "EterBase/Timer.h"
|
||||
#include "PythonBoot.h"
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
#include "transport.h"
|
||||
#endif
|
||||
#include "../UserInterface/UserInterface.h"
|
||||
#include "PythonHost.h"
|
||||
#include "../EterLib/UIRenderCommands.h"
|
||||
@@ -250,6 +253,10 @@ void* fiber_main(void*)
|
||||
}
|
||||
|
||||
void init_2v0_gameplay_stubs();
|
||||
void StopAccountRegistration(); // PORT: drain registration before networking teardown.
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
void initMeshPort();
|
||||
#endif
|
||||
|
||||
namespace PythonBoot
|
||||
{
|
||||
@@ -899,6 +906,9 @@ bool run_main_script_body(const char* lpCmdLine, std::string* error)
|
||||
initChat();
|
||||
initTextTail();
|
||||
initnet();
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
initMeshPort();
|
||||
#endif
|
||||
initMiniMap();
|
||||
initEvent();
|
||||
initeffect();
|
||||
@@ -1011,6 +1021,10 @@ namespace PythonBoot
|
||||
#include "VipScript.inc"
|
||||
#include "ModelPreviewScript.inc"
|
||||
#include "BattlePassScript.inc"
|
||||
#include "ItemActionsScript.inc"
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
#include "MeshPortScript.inc"
|
||||
#endif
|
||||
|
||||
static void install_script_module(const char* c_szModule, const char* c_szScript)
|
||||
{
|
||||
@@ -1066,6 +1080,9 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
{
|
||||
install_script_module("mt_autohunt", c_szAutoHuntScript);
|
||||
install_script_module("mt_register", c_szRegisterScript);
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
install_script_module("mt_meshport", c_szMeshPortScript);
|
||||
#endif
|
||||
install_script_module("mt_framerate", c_szFrameRateOptionScript);
|
||||
install_script_module("mt_uiscale", c_szUIScaleOptionScript);
|
||||
install_script_module("mt_inventory", c_szInventoryPagesScript);
|
||||
@@ -1093,6 +1110,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
|
||||
install_script_module("mt_vip", c_szVipScript);
|
||||
install_script_module("mt_preview", c_szModelPreviewScript);
|
||||
install_script_module("mt_battlepass", c_szBattlePassScript);
|
||||
install_script_module("mt_item_actions", c_szItemActionsScript);
|
||||
if (g_touch_input)
|
||||
install_script_module("mt_mobile_hud", c_szMobileHUDScript);
|
||||
}
|
||||
@@ -1197,6 +1215,10 @@ void Stop()
|
||||
" getattr(_mm.mouseController, 'cursorDict', {}).clear()\n");
|
||||
PyGILState_Release(gil);
|
||||
}
|
||||
StopAccountRegistration();
|
||||
#ifdef MT_HAS_MESHPORT
|
||||
mt::meshport::shutdown(); // PORT: join SDK worker and stop mesh before Python/platform teardown.
|
||||
#endif
|
||||
g_launcher->Clear();
|
||||
g_game_singletons.reset();
|
||||
g_game_application.reset();
|
||||
|
||||
@@ -159,6 +159,8 @@ class RegisterDialog(ui.BoardWithTitleBar):
|
||||
ui.__mem_func__(self.Close))
|
||||
|
||||
def Destroy(self):
|
||||
if self.pending:
|
||||
net.CancelRegisterAccount()
|
||||
self.Hide()
|
||||
for row in (self.loginRow, self.passwordRow, self.confirmRow, self.socialRow):
|
||||
row.Destroy()
|
||||
@@ -178,6 +180,11 @@ class RegisterDialog(ui.BoardWithTitleBar):
|
||||
self.loginRow.edit.SetFocus()
|
||||
|
||||
def Close(self):
|
||||
if self.pending:
|
||||
net.CancelRegisterAccount()
|
||||
self.pending = False
|
||||
self.pendingPassword = ""
|
||||
self.registerButton.Enable()
|
||||
for row in (self.loginRow, self.passwordRow, self.confirmRow, self.socialRow):
|
||||
row.edit.KillFocus()
|
||||
self.Hide()
|
||||
|
||||
@@ -31,7 +31,7 @@ REASONS={'running':'洗练中','matched':'已获得目标属性','limit':'已达
|
||||
ERRORS={'rate':'操作过快,请稍后','invalid':'参数无效','item':'物品不存在','equipped':'请先卸下装备或结束交易','no_attr':'该物品不能洗练',
|
||||
'scroll':'没有可用的洗练道具','target':'目标属性超出可洗范围','running':'已有洗练在进行','busy':'当前状态不能洗练',
|
||||
'unsupported':'服务器尚未启用自动洗练','slot':'该条属性不能锁定','max':'最多锁定 2 条,且至少留 1 条可洗',
|
||||
'db':'锁定保存失败,请稍后再试'}
|
||||
'db':'锁定保存失败,请稍后再试','five_attr':'装备需要 5 条普通属性才能锁定','material':'锁定需要道具 50348,解锁需要道具 50349'}
|
||||
|
||||
|
||||
def Number(text,low=0,high=4294967295):
|
||||
@@ -188,7 +188,7 @@ class SwitchbotWindow(ui.Window):
|
||||
vnum=player.GetItemIndex(player.INVENTORY,cell)
|
||||
if not vnum:continue
|
||||
item.SelectItem(vnum);kind=item.GetItemType()
|
||||
if kind==item.ITEM_TYPE_USE and item.GetItemSubType()==USE_CHANGE_ATTRIBUTE:
|
||||
if kind==item.ITEM_TYPE_USE and item.GetItemSubType()==USE_CHANGE_ATTRIBUTE and vnum not in (50348,50349):
|
||||
scrolls[vnum]=scrolls.get(vnum,0)+player.GetItemCount(player.INVENTORY,cell)
|
||||
elif kind in (item.ITEM_TYPE_WEAPON,item.ITEM_TYPE_ARMOR) and any(player.GetItemAttribute(player.INVENTORY,cell,i)[0] for i in range(5)):
|
||||
items.append((cell,vnum))
|
||||
|
||||
Reference in New Issue
Block a user