暂存选项隐藏派系检测
This commit is contained in:
Binary file not shown.
105
1.6/1.6/Defs/EventDefs/EventDef_Examples_HideWhenDisabled.xml
Normal file
105
1.6/1.6/Defs/EventDefs/EventDef_Examples_HideWhenDisabled.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>Wula_TestEvent_HideWhenDisabled</defName>
|
||||
<label>测试事件:隐藏禁用选项</label>
|
||||
<characterName>测试者</characterName>
|
||||
<descriptions>
|
||||
<li>这是一个用于演示新功能的测试事件。它包含多个选项,展示了不同的条件和可见性行为。当前机械族好感度: {MechanoidGoodwill}</li>
|
||||
</descriptions>
|
||||
<options>
|
||||
<!-- 选项 1: 设置 TestVar=1 并重新打开事件 -->
|
||||
<li>
|
||||
<label>选项一 (设置 TestVar = 1)</label>
|
||||
<optionEffects>
|
||||
<li Class="WulaFallenEmpire.ConditionalEffects">
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_SetVariable">
|
||||
<name>TestVar</name>
|
||||
<value>1</value>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.Effect_OpenDialog">
|
||||
<def>Wula_TestEvent_HideWhenDisabled</def>
|
||||
</li>
|
||||
</effects>
|
||||
</li>
|
||||
</optionEffects>
|
||||
</li>
|
||||
|
||||
<!-- 选项 2: 条件不满足时,显示为灰色禁用按钮 -->
|
||||
<li>
|
||||
<label>选项二 (需要 TestVar = 1, 禁用但可见)</label>
|
||||
<conditions>
|
||||
<li Class="WulaFallenEmpire.Condition_VariableEquals">
|
||||
<name>TestVar</name>
|
||||
<value>1</value>
|
||||
</li>
|
||||
</conditions>
|
||||
<optionEffects>
|
||||
<li Class="WulaFallenEmpire.ConditionalEffects">
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_CloseDialog" />
|
||||
</effects>
|
||||
</li>
|
||||
</optionEffects>
|
||||
</li>
|
||||
|
||||
<!-- 选项 3: 条件不满足时,完全隐藏 -->
|
||||
<li>
|
||||
<label>选项三 (需要 TestVar = 1, 禁用时隐藏)</label>
|
||||
<hideWhenDisabled>true</hideWhenDisabled>
|
||||
<conditions>
|
||||
<li Class="WulaFallenEmpire.Condition_VariableEquals">
|
||||
<name>TestVar</name>
|
||||
<value>1</value>
|
||||
</li>
|
||||
</conditions>
|
||||
<optionEffects>
|
||||
<li Class="WulaFallenEmpire.ConditionalEffects">
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_CloseDialog" />
|
||||
</effects>
|
||||
</li>
|
||||
</optionEffects>
|
||||
</li>
|
||||
|
||||
<!-- 选项 4: 移除 TestVar 并重新打开事件 -->
|
||||
<li>
|
||||
<label>选项四 (移除 TestVar)</label>
|
||||
<optionEffects>
|
||||
<li Class="WulaFallenEmpire.ConditionalEffects">
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_RemoveVariable">
|
||||
<name>TestVar</name>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.Effect_OpenDialog">
|
||||
<def>Wula_TestEvent_HideWhenDisabled</def>
|
||||
</li>
|
||||
</effects>
|
||||
</li>
|
||||
</optionEffects>
|
||||
</li>
|
||||
|
||||
<!-- 选项 5: 检查机械族好感度 -->
|
||||
<li>
|
||||
<label>选项五 (检查机械族好感度)</label>
|
||||
<optionEffects>
|
||||
<li Class="WulaFallenEmpire.ConditionalEffects">
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_CheckFactionGoodwill">
|
||||
<factionDef>Mechanoid</factionDef>
|
||||
<variableName>MechanoidGoodwill</variableName>
|
||||
</li>
|
||||
<li Class="WulaFallenEmpire.Effect_OpenDialog">
|
||||
<def>Wula_TestEvent_HideWhenDisabled</def>
|
||||
</li>
|
||||
</effects>
|
||||
</li>
|
||||
</optionEffects>
|
||||
</li>
|
||||
|
||||
</options>
|
||||
</WulaFallenEmpire.EventDef>
|
||||
|
||||
</Defs>
|
||||
1
MCP/python-sdk
Submodule
1
MCP/python-sdk
Submodule
Submodule MCP/python-sdk added at 959d4e39ae
@@ -194,6 +194,10 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
if (option.hideWhenDisabled)
|
||||
{
|
||||
continue; // Skip rendering this option entirely
|
||||
}
|
||||
Rect rect = listing.GetRect(30f);
|
||||
Widgets.ButtonText(rect, option.label, false, true, false);
|
||||
TooltipHandler.TipRegion(rect, GetDisabledReason(option, reason));
|
||||
|
||||
@@ -565,6 +565,37 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
public class Effect_CheckFactionGoodwill : Effect
|
||||
{
|
||||
public FactionDef factionDef;
|
||||
public string variableName;
|
||||
|
||||
public override void Execute(Dialog_CustomDisplay dialog = null)
|
||||
{
|
||||
if (factionDef == null)
|
||||
{
|
||||
Log.Error("Effect_CheckFactionGoodwill requires a factionDef.");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("Effect_CheckFactionGoodwill requires a variableName.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = Find.FactionManager.FirstFactionOfDef(factionDef);
|
||||
if (faction == null)
|
||||
{
|
||||
// Faction doesn't exist, store a default value (e.g., 0 or a specific marker)
|
||||
EventContext.SetVariable(variableName, 0);
|
||||
Log.Warning($"Faction with def {factionDef.defName} not found. Setting '{variableName}' to 0.");
|
||||
return;
|
||||
}
|
||||
|
||||
int goodwill = faction.GoodwillWith(Faction.OfPlayer);
|
||||
EventContext.SetVariable(variableName, goodwill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace WulaFallenEmpire
|
||||
public List<ConditionalEffects> optionEffects;
|
||||
public List<Condition> conditions;
|
||||
public string disabledReason;
|
||||
public bool hideWhenDisabled = false;
|
||||
}
|
||||
|
||||
public class ConditionalEffects
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\1.6\Assemblies\</OutputPath>
|
||||
<OutputPath>..\..\1.6\1.6\Assemblies\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
Reference in New Issue
Block a user