菜单功能
No files matched your search
@@ -1,5 +1,6 @@
|
||||
# coding=utf-8
|
||||
import time
|
||||
from math import *
|
||||
|
||||
|
||||
class GraduallySum(object):
|
||||
|
||||
@@ -72,7 +72,7 @@ class SystemTools(object):
|
||||
"""
|
||||
return self.ListenForEvent(namespace=MOD_NAME, systemName='BlueFoxClientSystem')
|
||||
|
||||
def ListenForEvent(self, eventName=None, namespace=MC_SYSTEM_NAMESPACE, systemName=MC_SYSTEM_NAME, priority=0):
|
||||
def ListenForEvent(self, namespace=MC_SYSTEM_NAMESPACE, systemName=MC_SYSTEM_NAME, eventName=None, priority=0):
|
||||
"""
|
||||
监听事件,binding的服务端可监听服务端事件,binding的客户端则可监听客户端事件
|
||||
:param eventName: 可选:事件名 or 不传入参数.若不传入参数,则将函数名称视为事件名称
|
||||
@@ -99,13 +99,14 @@ class SystemTools(object):
|
||||
self.bindingInstance.ListenForEvent(*eventName)
|
||||
self.lastListened.add(eventName)
|
||||
|
||||
def FilterListener(self, eventName, namespace=MC_SYSTEM_NAMESPACE, systemName=MC_SYSTEM_NAME, priority=0):
|
||||
def FilterListener(self, namespace=MC_SYSTEM_NAMESPACE, systemName=MC_SYSTEM_NAME, eventName=None, priority=0):
|
||||
"""
|
||||
滤过监听器, 通常用于优化代码可读性
|
||||
"""
|
||||
|
||||
def Filter(*args):
|
||||
# type:(Callable) -> Callable
|
||||
|
||||
def Listener(func):
|
||||
_filter = EventFilter(func, self.bindingInstance, *args)
|
||||
EventName = (namespace, systemName, eventName, _filter, _filter.Filter, priority)
|
||||
|
||||
@@ -5,7 +5,7 @@ import mod.client.extraClientApi as clientApi
|
||||
import mod.server.extraServerApi as serverApi
|
||||
|
||||
if False:
|
||||
pass
|
||||
from typing import *
|
||||
IsDebug = 1
|
||||
|
||||
|
||||
@@ -156,3 +156,7 @@ if not serverApi.IsInServer():
|
||||
viewBinder = clientApi.GetViewBinderCls()
|
||||
baseScreen = clientApi.GetScreenNodeCls()
|
||||
customUIScreenProxy = clientApi.GetUIScreenProxyCls()
|
||||
RootScreenPathHead = (
|
||||
'variables_button_mappings_and_controls/safezone_screen_matrix/'
|
||||
'inner_matrix/safezone_screen_panel/root_screen_panel'
|
||||
)
|
||||
@@ -3,22 +3,24 @@ from ...BlueFoxTools.ModConfig import MOD_NAME
|
||||
from ...BlueFoxTools.SpecialFunciton.BlueFoxSystem import BlueFoxClientSystem
|
||||
from ...BlueFoxTools.SystemTools import SystemTools
|
||||
from ...BlueFoxTools.ToolsConfig import *
|
||||
from ...BlueFoxTools.EventFilter import BlueFoxFilterEnum as ef
|
||||
|
||||
|
||||
class MainClient(BlueFoxClientSystem):
|
||||
systemTools = SystemTools.GetTools('MainClient')
|
||||
mcListener = systemTools.ListenForEvent()
|
||||
blueFox = systemTools.GetBlueFoxServerListener()
|
||||
blueFoxListener = systemTools.GetBlueFoxServerListener()
|
||||
mainServer = systemTools.ListenForEvent(
|
||||
namespace=MOD_NAME, systemName='MainServer'
|
||||
)
|
||||
blockUse = systemTools.FilterListener('ClientBlockUseEvent')
|
||||
blockUseListener = systemTools.FilterListener(eventName='ClientItemUseOnEvent')
|
||||
|
||||
def __init__(self, *args):
|
||||
super(MainClient, self).__init__(*args)
|
||||
self.systemTools.Binding(self)
|
||||
self.usingCd = False
|
||||
|
||||
@blueFox
|
||||
@blueFoxListener
|
||||
def PlaySound(self, args):
|
||||
posDim = args['posDim']
|
||||
pitch = args['pitch']
|
||||
@@ -27,13 +29,11 @@ class MainClient(BlueFoxClientSystem):
|
||||
args['soundName'], posDim[:3], pitch=pitch
|
||||
)
|
||||
|
||||
# @blockUse(ef.ClientEvent.NormalEvent.NotInCd('rtdd:blockUse', 0.2))
|
||||
# def BlockUseNotIn02(self, args):
|
||||
# print args
|
||||
# blockName = args['blockName']
|
||||
# if blockName in blockName:
|
||||
# args['cancel'] = True
|
||||
@blockUseListener(ef.ClientEvent.NormalEvent.NotInCd('rtdd:ItemUseOnEvent', 0.2))
|
||||
def ClientItemUseOnEventNotInCd02(self, args):
|
||||
if args['itemName'] == 'rtdd:recipe_book':
|
||||
clientApi.PushScreen(MOD_NAME, 'CookRecipe', {})
|
||||
|
||||
@blueFox
|
||||
@blueFoxListener
|
||||
def PlayAttackAnim(self, args):
|
||||
clientCompFactory.CreatePlayer(LevelId).Swing()
|
||||
@@ -0,0 +1 @@
|
||||
import MainClient
|
||||
@@ -0,0 +1 @@
|
||||
import MainServer
|
||||
@@ -0,0 +1,124 @@
|
||||
# coding=utf-8
|
||||
from ...BlueFoxTools.ScreenTools import ScreenTools
|
||||
from ...BlueFoxTools.ScreenTools import ButtonTouchTypeEnum as btte
|
||||
from ...BlueFoxTools.SystemTools import SystemTools
|
||||
from ...BlueFoxTools.ToolsConfig import *
|
||||
|
||||
allCookRecipe = [
|
||||
{
|
||||
'publicResult': 'rtdd:oilpan', # 共有步骤产生的结果
|
||||
'publicStep': [
|
||||
{'itemName': 'rtdd:spatula', 'count': 1},
|
||||
{'itemName': 'rtdd:oilcan', 'count': 1},
|
||||
{},
|
||||
], # 共有步骤
|
||||
'splitStep': [
|
||||
{
|
||||
'result': 'rtdd:plate_24', # 分步骤产生的结果
|
||||
'items': [{}, {}, {}], # 分步骤的物品
|
||||
}
|
||||
], # 分步骤,一页最多8个分步骤
|
||||
}, # 这是一页显示的数据
|
||||
{
|
||||
'publicResult': 'rtdd:oilpan',
|
||||
'publicStep': [
|
||||
{'itemName': 'rtdd:spatula', 'count': 1},
|
||||
{'itemName': 'rtdd:oilcan', 'count': 1},
|
||||
{},
|
||||
],
|
||||
'splitStep': []
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ScreenTools.AutoRegister('rtdd_caipu.RecipeScreen')
|
||||
class CookRecipe(baseScreen):
|
||||
screenTools = ScreenTools.GetTools('CookRecipe')
|
||||
buttonBinder = screenTools.ButtonCallFuncBackBinder
|
||||
|
||||
def __init__(self, *args):
|
||||
super(CookRecipe, self).__init__(*args)
|
||||
self.page = 0
|
||||
self.pageData = allCookRecipe[self.page]
|
||||
|
||||
def Create(self):
|
||||
self.screenTools.Binding(self)
|
||||
lastButton = self.GetBaseUIControl(RootScreenPathHead + '/image/stack_panel1/last').asButton()
|
||||
nextButton = self.GetBaseUIControl(RootScreenPathHead + '/image/stack_panel1/next').asButton()
|
||||
lastButton.AddTouchEventParams()
|
||||
nextButton.AddTouchEventParams()
|
||||
lastButton.SetButtonTouchUpCallback(self.LastPage)
|
||||
nextButton.SetButtonTouchUpCallback(self.NextPage)
|
||||
|
||||
self.anyStepControlRoot = self.GetBaseUIControl(RootScreenPathHead + '/image/stack_panel')
|
||||
self.anyStemControlItemCells = []
|
||||
for i in range(1, 5):
|
||||
self.anyStemControlItemCells.append(
|
||||
self.anyStepControlRoot.GetChildByName('item_cell{}'.format(i)).GetChildByName(
|
||||
'item_renderer'
|
||||
).asItemRenderer()
|
||||
)
|
||||
self.splitStepControlRoot = self.GetBaseUIControl(RootScreenPathHead + '/image/recipe3')
|
||||
self.splitStepControl = []
|
||||
for i in range(1, 5):
|
||||
self.splitStepControl.append(
|
||||
self.splitStepControlRoot.GetChildByName('recipe_list{}'.format(i))
|
||||
)
|
||||
self.Build()
|
||||
|
||||
def RenderItem(self, itemRender, itemInfo):
|
||||
if not itemInfo:
|
||||
itemRender.SetUiItem('minecraft:air', 0)
|
||||
return
|
||||
itemName = itemInfo['itemName']
|
||||
count = itemInfo['count']
|
||||
itemRender.SetUiItem(itemName, 0)
|
||||
if count <= 1:
|
||||
itemRender.GetChildByName('label').SetVisible(False, False)
|
||||
else:
|
||||
itemRender.GetChildByName('label').SetVisible(True, False)
|
||||
itemRender.GetChildByName('label').asLabel().SetText(str(count), False)
|
||||
|
||||
def Build(self):
|
||||
self.RenderItem(
|
||||
self.anyStemControlItemCells[0],
|
||||
{'itemName': self.pageData.get('publicResult', ''), 'count': 1}
|
||||
)
|
||||
for _ in range(1, 4):
|
||||
self.RenderItem(
|
||||
self.anyStemControlItemCells[_],
|
||||
self.pageData.get('publicStep', [{}, {}, {}, ])[_ - 1]
|
||||
)
|
||||
splitStep = self.pageData.get('splitStep', [])
|
||||
for index in range(4):
|
||||
control = self.splitStepControl[index]
|
||||
control.SetVisible(True, False)
|
||||
for j in range(1, 3):
|
||||
infoIndex = index * 2 + j - 1
|
||||
control_j = control.GetChildByName('recipe{}'.format(j)).GetChildByName('recipe')
|
||||
if infoIndex >= len(splitStep):
|
||||
control_j.SetVisible(False, False)
|
||||
continue
|
||||
control_j.SetVisible(True, False)
|
||||
splitStepInfo = splitStep[infoIndex]
|
||||
for k in range(1, 4):
|
||||
itemCell = control_j.GetChildByName('item{}'.format(k)).asItemRenderer()
|
||||
self.RenderItem(itemCell, splitStepInfo.get('items', [{}, {}, {}])[k - 1])
|
||||
itemCell = control_j.GetChildByName('item4').asItemRenderer()
|
||||
self.RenderItem(itemCell, {'itemName': splitStepInfo.get('result', ''), 'count': 1})
|
||||
|
||||
def LastPage(self, args):
|
||||
if self.page <= 0: return
|
||||
self.page -= 1
|
||||
self.pageData = allCookRecipe[self.page]
|
||||
self.Build()
|
||||
|
||||
def NextPage(self, args):
|
||||
if self.page >= len(allCookRecipe) - 1: return
|
||||
self.page += 1
|
||||
self.pageData = allCookRecipe[self.page]
|
||||
self.Build()
|
||||
|
||||
@buttonBinder(btte.TouchUp, RootScreenPathHead + '/close')
|
||||
def Close(self, args):
|
||||
clientApi.PopScreen()
|
||||
@@ -0,0 +1 @@
|
||||
import CookRecipe
|
||||
@@ -0,0 +1,3 @@
|
||||
import Client
|
||||
import Server
|
||||
import Ui
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding=utf-8
|
||||
from BlueFoxTools.ModLoader import *
|
||||
from xiangyemod.service.FeatureDispatcher import FeatureDispatcher
|
||||
from xiangyemod.dongwuyangzhi.service.AnimalService import AnimalService
|
||||
@@ -32,5 +33,8 @@ if not serverApi.IsInServer():
|
||||
# 客户端进程: 导入客户端拦截系统(继承 BlueFoxClientSystem, 框架自动注册),
|
||||
# 提前取消右键默认行为, 消除服务端拦截的"闪一下"
|
||||
from xiangyemod.service.ClientFeatureDispatcher import ClientFeatureDispatcher
|
||||
|
||||
pass
|
||||
import System
|
||||
|
||||
LoadMod()
|
||||
@@ -81,12 +81,16 @@ class ClientFeatureDispatcher(BlueFoxClientSystem):
|
||||
|
||||
def Destroy(self):
|
||||
print "===== ClientFeatureDispatcher Destroy ====="
|
||||
self.UnListenForEvent(clientApi.GetEngineNamespace(),
|
||||
self.UnListenForEvent(
|
||||
clientApi.GetEngineNamespace(),
|
||||
clientApi.GetEngineSystemName(),
|
||||
"ClientItemUseOnEvent", self, self.OnItemUseOn)
|
||||
self.UnListenForEvent(clientApi.GetEngineNamespace(),
|
||||
"ClientItemUseOnEvent", self, self.OnItemUseOn
|
||||
)
|
||||
self.UnListenForEvent(
|
||||
clientApi.GetEngineNamespace(),
|
||||
clientApi.GetEngineSystemName(),
|
||||
"ClientItemTryUseEvent", self, self.OnItemTryUse)
|
||||
"ClientItemTryUseEvent", self, self.OnItemTryUse
|
||||
)
|
||||
|
||||
# ============================================================================
|
||||
# 入口1: 手持物品右键方块表面 -> 白名单组合才 ret (取消默认放置/吃)
|
||||
@@ -238,7 +242,6 @@ class ClientFeatureDispatcher(BlueFoxClientSystem):
|
||||
if _pc and (time.time() - _pc) < 0.2 and itemName in BLOCKUSE_CANCEL_ITEMS:
|
||||
args["cancel"] = True
|
||||
|
||||
|
||||
# 注: 客户端系统需在客户端进程被实例化。modMain 只能在服务端 import 服务端
|
||||
# 系统; 客户端系统由 BlueFox 框架自动注册其子类。为确保本类被加载, 需在
|
||||
# modMain 客户端分支(IsInServer()==False)里 import 本模块。
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"format_version": "1.10",
|
||||
"minecraft:item": {
|
||||
"components": {
|
||||
"minecraft:max_stack_size": 1
|
||||
},
|
||||
"description": {
|
||||
"category": "items",
|
||||
"identifier": "rtdd:recipe_book"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"format_version": "1.10",
|
||||
"minecraft:item": {
|
||||
"components": {
|
||||
"minecraft:icon": "rtdd:recipe_book"
|
||||
},
|
||||
"description": {
|
||||
"identifier": "rtdd:recipe_book"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1243,5 +1243,6 @@ item.rtdd:vegetable.name=青菜碎
|
||||
item.rtdd:qingcai.name=青菜
|
||||
item.rtdd:rice_balls.name=饭团
|
||||
item.rtdd:boiled_egg.name=水煮蛋
|
||||
item.rtdd:recipe_book.name=乡野装饰:菜谱
|
||||
entity.villager_v2.name=村民
|
||||
item.spawn_egg.entity.villager_v2.name=村民生物蛋
|
||||
@@ -7,6 +7,9 @@
|
||||
"beef_tenderloin": {
|
||||
"textures": "textures/items/beef_tenderloin"
|
||||
},
|
||||
"boiled_egg": {
|
||||
"textures": "textures/items/boiled_egg"
|
||||
},
|
||||
"brownrice": {
|
||||
"textures": "textures/items/rice"
|
||||
},
|
||||
@@ -19,6 +22,15 @@
|
||||
"crab": {
|
||||
"textures": "textures/items/crab"
|
||||
},
|
||||
"cream_0": {
|
||||
"textures": "textures/items/cream_0"
|
||||
},
|
||||
"crushed_carrots": {
|
||||
"textures": "textures/items/crushed_carrots"
|
||||
},
|
||||
"crushed_scallions": {
|
||||
"textures": "textures/items/crushed_scallions"
|
||||
},
|
||||
"crushedgarlic": {
|
||||
"textures": "textures/items/crushedgarlic"
|
||||
},
|
||||
@@ -76,9 +88,24 @@
|
||||
"potandspoon": {
|
||||
"textures": "textures/items/pot_and_spoon"
|
||||
},
|
||||
"potato_wedges": {
|
||||
"textures": "textures/items/potato_wedges"
|
||||
},
|
||||
"qingcai": {
|
||||
"textures": "textures/items/meiqiedeqingcai"
|
||||
},
|
||||
"rawsquidwhiskersr": {
|
||||
"textures": "textures/items/rawsquidwhiskersr"
|
||||
},
|
||||
"rice_balls": {
|
||||
"textures": "textures/items/rice_balls"
|
||||
},
|
||||
"rice_seeds": {
|
||||
"textures": "textures/items/rice_seeds"
|
||||
},
|
||||
"rtdd:recipe_book": {
|
||||
"textures": "textures/items/rtdd/rtdd_recipe_book"
|
||||
},
|
||||
"rtdd:soybean": {
|
||||
"textures": "textures/items/soybean"
|
||||
},
|
||||
@@ -106,32 +133,8 @@
|
||||
"thedriedfish": {
|
||||
"textures": "textures/items/thedriedfish"
|
||||
},
|
||||
"boiled_egg": {
|
||||
"textures": "textures/items/boiled_egg"
|
||||
},
|
||||
"cream_0": {
|
||||
"textures": "textures/items/cream_0"
|
||||
},
|
||||
"crushed_carrots": {
|
||||
"textures": "textures/items/crushed_carrots"
|
||||
},
|
||||
"crushed_scallions": {
|
||||
"textures": "textures/items/crushed_scallions"
|
||||
},
|
||||
"potato_wedges": {
|
||||
"textures": "textures/items/potato_wedges"
|
||||
},
|
||||
"rice_balls": {
|
||||
"textures": "textures/items/rice_balls"
|
||||
},
|
||||
"rice_seeds": {
|
||||
"textures": "textures/items/rice_seeds"
|
||||
},
|
||||
"vegetable": {
|
||||
"textures": "textures/items/vegetable"
|
||||
},
|
||||
"qingcai": {
|
||||
"textures": "textures/items/meiqiedeqingcai"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 345 B |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 565 B |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 220 B |
|
After Width: | Height: | Size: 217 B |
|
After Width: | Height: | Size: 256 B |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 124 B |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ui_defs": [
|
||||
"ui/rtdd_caipu.json"
|
||||
]
|
||||
}
|
||||