Add mobile touch UI and AVA2 biology system with server tools

This commit is contained in:
shen
2026-10-14 19:12:38 -07:00
parent e7f2202a94
commit 6472d17306
68 changed files with 4447 additions and 197 deletions
+457
View File
@@ -0,0 +1,457 @@
// PORT: AVA2 biology (bio.*), with native touch-sized controls and original command vocabulary.
static const char c_szBiologScript[] = R"PY(# -*- coding: utf-8 -*-
import app
import chat
import game
import grp
import item
import net
import player
import ui
import uiToolTip
import wndMgr
import weakref
import os
import sys
L = player.AutoHuntLocalize
g_window = None
g_entry = None
CATALOG = {1: {'index': 1, 'level': 30, 'material': 30006, 'count': 10, 'cooldown': 600, 'chance': 60, 'stone': 30220, 'bonuses': [{'point': 'POINT_DEF_GRADE_BONUS', 'label': '防御力', 'value': 30}], 'choose': False, 'enhancer': 71035, 'skip': 30250}, 2: {'index': 2, 'level': 40, 'material': 30047, 'count': 15, 'cooldown': 600, 'chance': 60, 'stone': 30221, 'bonuses': [{'point': 'POINT_ATT_GRADE_BONUS', 'label': '攻击力', 'value': 40}], 'choose': False, 'enhancer': 71035, 'skip': 30250}, 3: {'index': 3, 'level': 50, 'material': 30015, 'count': 15, 'cooldown': 900, 'chance': 60, 'stone': 30222, 'bonuses': [{'point': 'POINT_ATTBONUS_MONSTER', 'label': '对怪物伤害 %', 'value': 5}], 'choose': False, 'enhancer': 71035, 'skip': 30250}, 4: {'index': 4, 'level': 60, 'material': 30050, 'count': 20, 'cooldown': 900, 'chance': 60, 'stone': 30223, 'bonuses': [{'point': 'POINT_ATTBONUS_STONE', 'label': '对陨石伤害 %', 'value': 4}, {'point': 'POINT_ATTBONUS_BOSS', 'label': '对 Boss 伤害 %', 'value': 4}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 5: {'index': 5, 'level': 70, 'material': 300004, 'count': 25, 'cooldown': 1800, 'chance': 60, 'stone': 30224, 'bonuses': [{'point': 'POINT_ATTBONUS_BOSS', 'label': '对 Boss 伤害 %', 'value': 6}, {'point': 'POINT_ATTBONUS_STONE', 'label': '对陨石伤害 %', 'value': 6}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 6: {'index': 6, 'level': 80, 'material': 300005, 'count': 30, 'cooldown': 1800, 'chance': 60, 'stone': 30225, 'bonuses': [{'point': 'POINT_MAX_HP', 'label': '生命值', 'value': 1000}, {'point': 'POINT_CASTING_SPEED', 'label': '施法速度', 'value': 10}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 7: {'index': 7, 'level': 85, 'material': 300006, 'count': 40, 'cooldown': 2700, 'chance': 60, 'stone': 30226, 'bonuses': [{'point': 'POINT_RESIST_WARRIOR', 'label': '战士抗性 %', 'value': 10}, {'point': 'POINT_RESIST_ASSASSIN', 'label': '忍者抗性 %', 'value': 10}, {'point': 'POINT_RESIST_SURA', 'label': '修罗抗性 %', 'value': 10}, {'point': 'POINT_RESIST_SHAMAN', 'label': '萨满抗性 %', 'value': 10}], 'choose': False, 'enhancer': 71035, 'skip': 30250}, 8: {'index': 8, 'level': 90, 'material': 300007, 'count': 50, 'cooldown': 3600, 'chance': 60, 'stone': 30227, 'bonuses': [{'point': 'POINT_ATTBONUS_WARRIOR', 'label': '对战士伤害 %', 'value': 10}, {'point': 'POINT_ATTBONUS_ASSASSIN', 'label': '对忍者伤害 %', 'value': 10}, {'point': 'POINT_ATTBONUS_SURA', 'label': '对修罗伤害 %', 'value': 10}, {'point': 'POINT_ATTBONUS_SHAMAN', 'label': '对萨满伤害 %', 'value': 10}], 'choose': False, 'enhancer': 71035, 'skip': 30250}, 9: {'index': 9, 'level': 92, 'material': 300008, 'count': 10, 'cooldown': 7200, 'chance': 60, 'stone': 30228, 'bonuses': [{'point': 'POINT_MAX_HP', 'label': '生命值', 'value': 1200}, {'point': 'POINT_DEF_GRADE_BONUS', 'label': '防御力', 'value': 120}, {'point': 'POINT_ATT_GRADE_BONUS', 'label': '攻击力', 'value': 50}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 10: {'index': 10, 'level': 94, 'material': 300009, 'count': 20, 'cooldown': 7200, 'chance': 60, 'stone': 30229, 'bonuses': [{'point': 'POINT_MAX_HP', 'label': '生命值', 'value': 1500}, {'point': 'POINT_DEF_GRADE_BONUS', 'label': '防御力', 'value': 140}, {'point': 'POINT_ATT_GRADE_BONUS', 'label': '攻击力', 'value': 60}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 11: {'index': 11, 'level': 98, 'material': 300010, 'count': 35, 'cooldown': 10800, 'chance': 60, 'stone': 30230, 'bonuses': [{'point': 'POINT_ATTBONUS_MONSTER', 'label': '对怪物伤害 %', 'value': 10}, {'point': 'POINT_RESIST_HUMAN', 'label': '半人抗性 %', 'value': 10}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 12: {'index': 12, 'level': 100, 'material': 300011, 'count': 35, 'cooldown': 10800, 'chance': 60, 'stone': 30231, 'bonuses': [{'point': 'POINT_ATTBONUS_STONE', 'label': '对陨石伤害 %', 'value': 10}, {'point': 'POINT_MELEE_MAGIC_ATT_BONUS_PER', 'label': '近战及魔法攻击 %', 'value': 10}], 'choose': True, 'enhancer': 71035, 'skip': 30250}, 13: {'index': 13, 'level': 105, 'material': 300012, 'count': 35, 'cooldown': 10800, 'chance': 60, 'stone': 30232, 'bonuses': [{'point': 'POINT_ATTBONUS_BOSS', 'label': '对 Boss 伤害 %', 'value': 10}, {'point': 'POINT_ATTBONUS_HUMAN', 'label': '对半人伤害 %', 'value': 10}], 'choose': True, 'enhancer': 71035, 'skip': 30250}}
SHOP = [{'vnum': 30220, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 5000000}, {'vnum': 30221, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 7000000}, {'vnum': 30222, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 10000000}, {'vnum': 30223, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 13000000}, {'vnum': 30224, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 20000000}, {'vnum': 30225, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 25000000}, {'vnum': 30226, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 50000000}, {'vnum': 30227, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 100000000}, {'vnum': 30228, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 200000000}, {'vnum': 30229, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 200000000}, {'vnum': 30230, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 500000000}, {'vnum': 30231, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 500000000}, {'vnum': 30232, 'count': 1, 'cost': 0, 'amount': 0, 'gold': 500000000}, {'vnum': 300004, 'count': 1, 'cost': 30091, 'amount': 5, 'gold': 0}, {'vnum': 300005, 'count': 1, 'cost': 30197, 'amount': 3, 'gold': 0}, {'vnum': 300006, 'count': 1, 'cost': 30198, 'amount': 2, 'gold': 0}, {'vnum': 300007, 'count': 1, 'cost': 30196, 'amount': 2, 'gold': 0}, {'vnum': 300008, 'count': 1, 'cost': 70031, 'amount': 3, 'gold': 0}, {'vnum': 300009, 'count': 1, 'cost': 70031, 'amount': 5, 'gold': 0}, {'vnum': 300010, 'count': 1, 'cost': 30520, 'amount': 7, 'gold': 0}, {'vnum': 300011, 'count': 1, 'cost': 30521, 'amount': 7, 'gold': 0}, {'vnum': 300012, 'count': 1, 'cost': 30518, 'amount': 7, 'gold': 0}]
def BonusText(bonus):
return bonus['label'].replace(" %", "")+" +%d"%bonus['value']+("%" if bonus['label'].endswith("%") else "")
def Text(parent, x, y, text="", color=0xffe8dec8):
line = ui.TextLine()
line.SetParent(parent)
line.AddFlag("not_pick")
line.SetPosition(x, y)
line.SetText(L(text))
line.SetPackedFontColor(color)
line.Show()
return line
class Action(ui.Window):
def __init__(self, parent, x, y, width, text, event):
ui.Window.__init__(self)
if parent:
self.SetParent(parent)
self.SetPosition(x, y)
self.SetSize(width, 48)
self.event = event
self.enabled = True
self.down = False
self.label = Text(self, width/2, 24, text)
self.label.SetHorizontalAlignCenter()
self.label.SetVerticalAlignCenter()
self.Show()
def SetText(self, text):
self.label.SetText(L(text))
def SetEnabled(self, enabled):
self.enabled = bool(enabled)
self.label.SetPackedFontColor(0xffefdbac if enabled else 0xff817c70)
def OnRender(self):
x, y = self.GetGlobalPosition()
grp.SetColor(0xdd684f2f if self.down else 0xdd2d261d)
grp.RenderBar(x, y, self.GetWidth(), self.GetHeight())
grp.SetColor(0xffb99a66 if self.enabled else 0xff57534b)
grp.RenderBox(x, y, self.GetWidth(), self.GetHeight())
def OnMouseLeftButtonDown(self):
self.down = self.enabled
return True
def OnMouseLeftButtonUp(self):
invoke = self.down and self.enabled and self.IsIn()
self.down = False
if invoke:
self.event()
return True
def OnMouseOverOut(self):
self.down = False
class BiologWindow(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.SetWindowName("BiologWindow")
self.AddFlag("float")
self.AddFlag("movable")
self.SetSize(540, 400)
self.heading = Text(self, 22, 18, "生物学家研究", 0xffffd68b)
self.closeButton = Action(self, 470, 6, 48, "关闭", self.Hide)
self.title = Text(self, 22, 48)
self.phase = Text(self, 22, 68)
self.material = Text(self, 104, 92)
self.progress = Text(self, 104, 114)
self.owned = Text(self, 104, 136)
self.cooldown = Text(self, 22, 160)
self.reward = [Text(self, 22+(i%2)*260, 188+(i/2)*22) for i in range(4)]
self.message = Text(self, 22, 378, "正在同步研究进度", 0xffb3aa98)
self.icon = ui.ExpandedImageBox()
self.icon.SetParent(self)
self.icon.SetPosition(26, 92)
self.icon.AddFlag("not_pick")
self.tooltip = uiToolTip.ItemToolTip()
self.tooltip.Hide()
self.enhance = Action(self, 22, 288, 158, "精华:开启", lambda:self.Option(0))
self.skip = Action(self, 190, 288, 158, "跳过冷却:开启", lambda:self.Option(1))
self.reminder = Action(self, 358, 288, 160, "到期提醒:开启", lambda:self.Option(2))
self.submit = Action(self, 22, 344, 158, "提交材料", self.Act)
self.shopButton = Action(self, 190, 344, 158, "研究商店", self.Shop)
self.resetButton = Action(self, 358, 344, 160, "重选奖励", self.Reset)
self.choices = [Action(self, 22+(i%2)*260, 188+(i/2)*54, 238, "", lambda i=i:self.Gift(i)) for i in range(4)]
self.prev = Action(self, 22, 288, 158, "上一项", lambda:self.Browse(-1))
self.next = Action(self, 358, 288, 160, "下一项", lambda:self.Browse(1))
self.options = [True, True, True] # AVA2 defaults: enhancer, time skip, reminder.
self.index = 0
self.count = 0
self.deadline = 0
self.serverTime = 0
self.receivedAt = 0
self.pendingUntil = 0
self.nextQuery = app.GetTime()+1
self.queryStarted = 0
self.mode = "research"
self.bonuses = [0]*13
self.browse = 0
self.hasState = False
self.iconVnum = 0
self.iconHover = False
self.lastRemaining = 0
self.dimensions = None
self.LoadOptions()
self.Hide()
self.Refresh()
def OnRender(self):
x,y = self.GetGlobalPosition()
grp.SetColor(0xf51b1916)
grp.RenderBar(x,y,self.GetWidth(),self.GetHeight())
grp.SetColor(0xff9b7b48)
grp.RenderBox(x,y,self.GetWidth(),self.GetHeight())
def PreferencePath(self):
# Keep preferences outside a signed macOS app; Android falls back to its writable client dir.
base = os.environ.get("HOME", ".")
if sys.platform.startswith("linux"):
base = "."
folder = os.path.join(base, ".metin2", "biolog")
name = player.GetName()
return folder, os.path.join(folder, name.encode("hex")+".cfg")
def LoadOptions(self):
try:
folder,path = self.PreferencePath()
values = [int(x) for x in open(path,"r").read().strip().split("#")]
if len(values)==3 and all(type(x) in (bool,int) and x in (0,1) for x in values):
self.options = map(bool, values)
except (IOError, OSError, ValueError, TypeError):
pass
def Option(self, index):
self.options[index] = not self.options[index]
try:
folder,path = self.PreferencePath()
if not os.path.isdir(folder): os.makedirs(folder)
with open(path,"w") as stream: stream.write("#".join(str(int(x)) for x in self.options))
except (IOError,OSError):
pass
self.Refresh()
def Toggle(self):
if self.IsShow(): self.Hide()
else:
self.mode = "research"
self.SetCenterPosition()
self.Show()
self.SetTop()
self.Query()
def Query(self):
now = app.GetTime()
self.nextQuery = now+3
if not self.queryStarted:self.queryStarted=now
net.SendChatPacket("/bio status")
def SetData(self, words):
if len(words)!=3:return False
try:index,count,deadline=map(int,words)
except (ValueError,TypeError):return False
if index not in CATALOG or count<0 or count>CATALOG[index]['count']+1 or deadline<0:return False
self.index,self.count,self.deadline=index,count,deadline
self.receivedAt=app.GetTime()
self.hasState=True
self.pendingUntil=0
self.Refresh()
return True
def SetPhase(self, index, stone):
try:index=int(index)
except (ValueError,TypeError):return
if index not in CATALOG:return
self.index=index
self.count=CATALOG[index]['count']+(0 if stone else 1)
self.hasState=True
self.pendingUntil=0
self.Refresh()
def Phase(self):
if not self.hasState:return "loading"
if self.index>=14:return "complete"
row=CATALOG[self.index]
if self.count<row['count']:return "collect"
if row['stone'] and self.count==row['count']:return "stone"
return "gift"
def Remaining(self):
if not self.deadline:return 0
reference=self.serverTime if self.serverTime else app.GetGlobalTimeStamp()
return max(0,int(self.deadline-reference-(app.GetTime()-self.receivedAt)+0.999))
def ItemCount(self,vnum):
return player.GetItemCountByVnum(vnum) if vnum else 0
def CanAct(self):
if not self.hasState or app.GetTime()<self.pendingUntil:return False
if self.mode=="shop":
offer=SHOP[self.browse]
return self.ItemCount(offer['cost'])>=offer['amount'] if offer['cost'] else player.GetElk()>=offer['gold']
if self.mode=="reset" or self.index not in CATALOG:return False
row=CATALOG[self.index]
if player.GetStatus(player.LEVEL)<row['level']:return False
phase=self.Phase()
if phase=="collect":
return self.ItemCount(row['material'])>0 and (self.Remaining()==0 or (self.options[1] and self.ItemCount(row['skip'])>0))
return phase=="stone" and self.ItemCount(row['stone'])>0
def Act(self):
if not self.CanAct():return
self.pendingUntil=app.GetTime()+5
if self.mode=="shop":net.SendChatPacket("/bio buy %d"%self.browse)
else:net.SendChatPacket("/bio mission %d %d"%(int(self.options[0]),int(self.options[1])))
self.nextQuery=app.GetTime()+1
self.Refresh()
def Gift(self, choice):
if app.GetTime()<self.pendingUntil:return
index=self.ResetIndex() if self.mode=="reset" else self.index
if index not in CATALOG or choice>=len(CATALOG[index]['bonuses']):return
if self.mode=="reset":
if self.ItemCount(70028)<1 or self.bonuses[index-1]==choice+1:return
command="/bio reset %d %d"%(index,choice)
else:
if self.Phase()!="gift":return
command="/bio gift %d"%choice
self.pendingUntil=app.GetTime()+5
net.SendChatPacket(command)
self.nextQuery=app.GetTime()+1
self.Refresh()
def Shop(self):
self.mode="research" if self.mode=="shop" else "shop"
self.browse=0
self.Refresh()
def ResetEntries(self):
return [i+1 for i,value in enumerate(self.bonuses) if value and i+1<self.index and CATALOG[i+1]['choose']]
def ResetIndex(self):
entries=self.ResetEntries()
return entries[self.browse%len(entries)] if entries else 0
def Reset(self):
self.mode="research" if self.mode=="reset" else "reset"
self.browse=0
self.Refresh()
def Browse(self, delta):
count=len(SHOP) if self.mode=="shop" else len(self.ResetEntries())
if count:self.browse=(self.browse+delta)%count
self.Refresh()
def ItemName(self,vnum):
item.SelectItem(vnum)
return item.GetItemName()
def Refresh(self):
for button in self.choices+[self.prev,self.next]:button.Hide()
for line in self.reward:line.SetText("")
for button in (self.enhance,self.skip,self.reminder):button.Show()
self.submit.SetEnabled(self.CanAct())
for i,button in enumerate((self.enhance,self.skip,self.reminder)):
button.SetText(("精华:","跳过冷却:","到期提醒:")[i]+("开启" if self.options[i] else "关闭"))
button.SetEnabled(app.GetTime()>=self.pendingUntil)
self.shopButton.SetText("返回研究" if self.mode=="shop" else "研究商店")
self.resetButton.SetText("返回研究" if self.mode=="reset" else "重选奖励")
self.message.SetText(L("请求处理中……" if app.GetTime()<self.pendingUntil else ""))
if not self.hasState:
self.title.SetText(L("正在同步研究进度……"))
return
if self.index>=14 and self.mode=="research":
self.title.SetText(L("全部研究已完成"))
self.phase.SetText(L("30~105 级研究奖励已领取。"))
self.icon.Hide()
for line in (self.material,self.progress,self.owned,self.cooldown):line.SetText("")
self.submit.SetText("已完成")
return
if self.mode=="shop":
offer=SHOP[self.browse];vnum=offer['vnum']
self.title.SetText(L("研究商店 %d / %d")%(self.browse+1,len(SHOP)))
self.phase.SetText(L("与 AVA2 生物学家商店相同的物品与兑换条件。"))
self.progress.SetText(L("购买数量:%d")%offer['count'])
cost=(self.ItemName(offer['cost'])+L(" × %d")%offer['amount']) if offer['cost'] else L("金币 %d")%offer['gold']
self.cooldown.SetText(L("价格:")+cost)
self.submit.SetText("购买")
for b in (self.enhance,self.skip,self.reminder):b.Hide()
self.prev.Show();self.next.Show()
else:
index=self.ResetIndex() if self.mode=="reset" else self.index
if not index:
self.title.SetText(L("暂无可重选的奖励"))
self.phase.SetText(L("完成有奖励选项的研究后,可消耗重选道具。"))
self.icon.Hide()
for line in (self.material,self.progress,self.owned,self.cooldown):line.SetText("")
self.submit.SetEnabled(False)
return
row=CATALOG[index]
phase="gift" if self.mode=="reset" else self.Phase()
vnum=row['stone'] if phase=="stone" else row['material']
self.title.SetText(L("%d 级研究 · %d / 13")%(row['level'],index))
text={"collect":"收集材料", "stone":"提交任务石", "gift":"选择研究奖励"}.get(phase,"")
self.phase.SetText(L(text))
self.progress.SetText(L("进度:%d / %d")%(min(self.count,row['count']) if self.mode!="reset" else row['count'],row['count']))
remaining=self.Remaining() if phase=="collect" else 0
self.cooldown.SetText(L("冷却 %02d:%02d:%02d · 基础成功率 %d%%")%(remaining/3600,(remaining/60)%60,remaining%60,row['chance']))
self.submit.SetText("提交任务石" if phase=="stone" else "提交材料")
if phase=="gift":
for b in (self.enhance,self.skip,self.reminder):b.Hide()
for i,bonus in enumerate(row['bonuses']):
b=self.choices[i];b.SetText(BonusText(bonus));b.Show()
b.SetEnabled(app.GetTime()>=self.pendingUntil and (self.mode!="reset" or (self.ItemCount(70028)>0 and self.bonuses[index-1]!=i+1)))
else:
for line,bonus in zip(self.reward,row['bonuses']):line.SetText(L(BonusText(bonus)))
if self.mode=="reset":
for b in (self.enhance,self.skip,self.reminder):b.Hide()
self.prev.Show();self.next.Show()
self.message.SetText(L("消耗重选道具 ×1,当前选择:%d")%self.bonuses[index-1])
elif player.GetStatus(player.LEVEL)<row['level']:
self.message.SetText(L("需要角色等级 %d")%row['level'])
self.material.SetText(self.ItemName(vnum))
self.owned.SetText(L("背包持有:%d")%self.ItemCount(vnum))
if vnum!=self.iconVnum:
self.iconVnum=vnum
self.icon.LoadImage(item.GetIconImageFileName())
self.icon.SetScale(1.6,1.6)
self.icon.Show()
def OnUpdate(self):
now=app.GetTime()
# Keep the expiry reminder alive while the panel is closed, like AVA2's loop callback.
if now>=self.nextQuery and (self.IsShow() or not self.hasState):self.Query()
remaining=self.Remaining()
if self.options[2] and self.lastRemaining>0 and remaining==0 and self.Phase()=="collect":
chat.AppendChat(chat.CHAT_TYPE_NOTICE,L("[生物学家] 可以再次提交研究材料了。"))
self.lastRemaining=remaining
if not self.IsShow():return
dimensions=(wndMgr.GetScreenWidth(),wndMgr.GetScreenHeight())
if dimensions!=self.dimensions:
self.dimensions=dimensions
height=min(400,dimensions[1]-12)
self.SetSize(540,height)
self.message.SetPosition(22,height-20)
for b in (self.submit,self.shopButton,self.resetButton):b.SetPosition(b.GetLocalPosition()[0],height-56)
for b in (self.enhance,self.skip,self.reminder,self.prev,self.next):b.SetPosition(b.GetLocalPosition()[0],height-112)
self.SetCenterPosition()
self.Refresh()
x,y=self.GetGlobalPosition();mx,my=wndMgr.GetMousePosition()
hover=self.iconVnum and x+24<=mx<x+86 and y+92<=my<y+154
if hover and not self.iconHover:self.tooltip.SetItemToolTip(self.iconVnum)
elif not hover and self.iconHover:self.tooltip.Hide()
self.iconHover=hover
def Hide(self):
ui.Window.Hide(self)
if hasattr(self,"tooltip"):self.tooltip.Hide()
self.iconHover=False
def OnPressEscapeKey(self):
self.Hide()
return True
def Destroy(self):
self.Hide()
for b in self.choices+[self.submit,self.shopButton,self.resetButton,self.enhance,self.skip,self.reminder,self.closeButton,self.prev,self.next]:b.event=None
self.hasState=False
class Entry(Action):
def __init__(self, window):
Action.__init__(self, None, 0, 0, 64, "研究", Toggle)
self.minimap = weakref.proxy(window.interface.wndMiniMap)
self.SetWindowName("BiologEntry")
self.OnUpdate()
def OnUpdate(self):
x, y = self.minimap.GetGlobalPosition()
self.SetPosition(max(4, x - 68), y + 44)
if g_window and not g_window.IsShow():g_window.OnUpdate()
def Toggle():
if g_window:g_window.Toggle()
_open=game.GameWindow.Open
_close=game.GameWindow.Close
_command=game.GameWindow.BINARY_ServerCommand_Run
def Open(self):
global g_window,g_entry
_open(self)
g_window=BiologWindow()
g_entry=Entry(self)
g_entry.nextTick=0
def Close(self):
global g_window,g_entry
if g_entry:g_entry.Hide();g_entry.event=None;g_entry=None
if g_window:g_window.Destroy();g_window=None
_close(self)
def Command(self,line):
words=line.split()
if not words:return _command(self,line)
name=words[0]
if name in ("biodata","biostone","bioodul","bioempty","biotime","biobonuses","bioreselect","BioNotice"):
if not g_window:return 1
try:
if name=="biodata":g_window.SetData(words[1:])
elif name=="biostone" and len(words)==2:g_window.SetPhase(words[1],True)
elif name=="bioodul" and len(words)==2:g_window.SetPhase(words[1],False)
elif name=="bioempty":g_window.index=14;g_window.hasState=True;g_window.pendingUntil=0;g_window.Refresh()
elif name=="biotime" and len(words)==2:g_window.serverTime=int(words[1]);g_window.receivedAt=app.GetTime()
elif name=="biobonuses" and len(words)==14:
values=map(int,words[1:])
if all(0<=v<=4 for v in values):g_window.bonuses=values
elif name=="bioreselect":
if not g_window.IsShow():g_window.Toggle()
g_window.mode="reset";g_window.browse=0;g_window.Refresh()
elif name=="BioNotice" and len(words)>=2:
text={"level":"等级不足,暂时无法继续研究。","material":"研究材料不足。","cooldown":"冷却中,需要冷却药剂才能立即提交。","success":"研究成功,进度增加。","failure":"研究失败,材料已消耗。","stone":"请先准备所需任务石。","complete":"所有生物学家研究已完成。","busy":"请先关闭交易、商店或任务对话。","bought":"购买成功。","cost":"金币或兑换材料不足。","reset":"研究奖励已重新选择。","reset_item":"需要重选道具。"}.get(words[1],"")
if text:chat.AppendChat(chat.CHAT_TYPE_INFO,L(text))
g_window.pendingUntil=0
except (ValueError,TypeError,IndexError):pass
return 1
return _command(self,line)
game.GameWindow.Open=Open
game.GameWindow.Close=Close
game.GameWindow.BINARY_ServerCommand_Run=Command
)PY";