This commit is contained in:
Tourswen
2025-11-08 00:29:54 +08:00
parent c67371b3d0
commit 2967da3fb1
28 changed files with 197 additions and 92 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>
<WulaFallenEmpire.EventDef>
<defName>Wula_UI_Legion_1</defName>
<label>和P.I.A的通讯</label>
<portraitPath>Wula/Events/Portraits/WULA_Legion_1</portraitPath>
<characterName>「军团」</characterName>
<descriptions>
<li>这里是P.I.A通讯信号良好等待输入。</li>
</descriptions>
<options>
<li>
<label>再见</label>
<optionEffects>
<li>
<effects>
<li Class="WulaFallenEmpire.Effect_CloseDialog" />
</effects>
</li>
</optionEffects>
</li>
</options>
</WulaFallenEmpire.EventDef>
</Defs>

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>
<StorytellerDef ParentName="BaseStoryteller">
<defName>WULA_Anisia</defName>
<label>URa-1138「艾妮西娅</label>
<description>位诞生于乌拉帝国黄金时代的合成人,是黄金时代禁忌科技的守密者。她在边缘世界一带强制唤醒了大量的旧时代乌拉帝国合成人,无人知晓她真正的目的。\n\n艾妮西娅喜欢大场面因此她不会安排任何小型袭击而是安排比其他叙事者所安排的大型袭击更加强大的袭击。不过在两次袭击间她将安排充足的时间让殖民地进行发展并让殖民者得到放松以充分消化战利品和修补战线</description>
<portraitLarge>Wula/Storyteller/WULA_Anisia</portraitLarge>
<portraitTiny>Wula/Storyteller/WULA_Anisia_TINY</portraitTiny>
<defName>WULA_Legion</defName>
<label>「军团</label>
<description>个超级AI负责控制调度乌拉帝国行星封锁机关P.I.A的舰队是帝国开发署扩张领地的先锋。当帝国需要对一个星球进行控制和介入时她会指挥庞大的先锋舰队攻占轨道以不容置疑的实力向星球宣示帝国的权威。\n\n作为讲述者她不会为你留下任何保护措施所有的袭击和恶性事件从落地开始就有可能生成并且袭击的频率要比常规情况下更高——尽管它们还是有周期规律的</description>
<portraitLarge>Wula/Storyteller/WULA_Legion</portraitLarge>
<portraitTiny>Wula/Storyteller/WULA_Legion_TINY</portraitTiny>
<listOrder>20</listOrder>
<comps>
<!-- Intro -->
@@ -13,9 +13,9 @@
<!-- 袭击生成器 -->
<li Class="StorytellerCompProperties_OnOffCycle">
<category>ThreatBig</category> <!-- 大型袭击 -->
<minDaysPassed>15.0</minDaysPassed> <!-- 最低在15日后开始生成 -->
<minDaysPassed>0</minDaysPassed>
<onDays>2</onDays> <!-- 每个周期(12天)有多少天允许生成袭击 -->
<offDays>9</offDays> <!-- 每个周期(12天)有多少天不生成袭击 -->
<offDays>5</offDays> <!-- 每个周期(12天)有多少天不生成袭击 -->
<minSpacingDays>0.25</minSpacingDays> <!-- 事件最小间隔 -->
<numIncidentsRange>2~3</numIncidentsRange> <!-- 事件点数 -->
<!-- <forceRaidEnemyBeforeDaysPassed>20</forceRaidEnemyBeforeDaysPassed> -->
@@ -23,11 +23,11 @@
<li>Map_RaidBeacon</li>
</disallowedTargetTags>
</li>
<!-- <li Class="StorytellerCompProperties_OnOffCycle">
<li Class="StorytellerCompProperties_OnOffCycle">
<category>ThreatSmall</category>
<minDaysPassed>11.0</minDaysPassed>
<onDays>4.6</onDays>
<offDays>6.0</offDays>
<minDaysPassed>0</minDaysPassed>
<onDays>2.6</onDays>
<offDays>3.0</offDays>
<numIncidentsRange>0.2~1</numIncidentsRange>
<acceptPercentFactorPerThreatPointsCurve>
<points>
@@ -35,7 +35,7 @@
<li>(2800, 0)</li>
</points>
</acceptPercentFactorPerThreatPointsCurve>
</li> -->
</li>
<li Class="StorytellerCompProperties_ThreatsGenerator">
<allowedTargetTags>
<li>Map_RaidBeacon</li>
@@ -55,17 +55,17 @@
<allowedTargetTags>
<li>Map_PlayerHome</li>
</allowedTargetTags>
<minDaysPassed>5</minDaysPassed>
<minDaysPassed>0</minDaysPassed>
<mtbDays>4.8</mtbDays>
</li>
<li Class="StorytellerCompProperties_ShipChunkDrop"/>
<li Class="StorytellerCompProperties_Disease">
<category>DiseaseHuman</category>
<minDaysPassed>9</minDaysPassed>
<minDaysPassed>0</minDaysPassed>
</li>
<li Class="StorytellerCompProperties_Disease">
<category>DiseaseAnimal</category>
<minDaysPassed>9</minDaysPassed>
<minDaysPassed>0</minDaysPassed>
</li>
<!-- Ally/neutral interaction -->
<li Class="StorytellerCompProperties_FactionInteraction">
@@ -170,7 +170,7 @@
<allowedTargetTags>
<li>World</li>
</allowedTargetTags>
<minDaysPassed>15</minDaysPassed>
<minDaysPassed>0</minDaysPassed>
<mtbDays>15</mtbDays>
</li>
<!-- Orbital trader -->
@@ -180,11 +180,6 @@
<offDays>8</offDays>
<numIncidentsRange>1</numIncidentsRange>
</li>
<!-- Triggered -->
<li Class="StorytellerCompProperties_Triggered">
<incident>StrangerInBlackJoin</incident>
<delayTicks>180</delayTicks>
</li>
</comps>
</StorytellerDef>
</Defs>

View File

@@ -831,7 +831,7 @@
</comps>
</ThingDef>
<!-- 制造-->
<!-- 订单-->
<ThingDef ParentName="BuildingBase">
<defName>WULA_WeaponArmor_Productor_Cleanzone</defName>
<label>乌拉帝国作业通讯台</label>
@@ -988,9 +988,9 @@
<overrideExistingFaction>false</overrideExistingFaction>
</li>
<li Class="WulaFallenEmpire.CompProperties_OpenCustomUI">
<uiDefName>Wula_UI_Main_1</uiDefName>
<label>联络乌拉帝国</label>
<failReason>无法接触通讯站</failReason>
<uiDefName>Wula_UI_Legion_1</uiDefName>
<label>联络行星封锁机关</label>
<failReason>无法接触。</failReason>
</li>
</comps>
</ThingDef>

View File

@@ -5,8 +5,9 @@
<label>自律核心数据包(射击)</label>
<description>包含了射击经验的自律核心数据包,可以被乌拉帝国拥有自律核心的武器吸收以提升其品质。</description>
<graphicData>
<texPath>Wula/Item/WULA_Dark_Matter_Item</texPath>
<texPath>Wula/Item/WULA_ExperienceDataPack</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.8</drawSize>
</graphicData>
<tickerType>Never</tickerType>
<smeltable>false</smeltable>
@@ -35,8 +36,9 @@
<label>自律核心数据包(近战)</label>
<description>包含了近战经验的自律核心数据包,可以被乌拉帝国拥有自律核心的武器吸收以提升其品质。</description>
<graphicData>
<texPath>Wula/Item/WULA_Dark_Matter_Item</texPath>
<texPath>Wula/Item/WULA_ExperienceDataPack</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.8</drawSize>
</graphicData>
<tickerType>Never</tickerType>
<smeltable>false</smeltable>
@@ -62,7 +64,7 @@
</ThingDef>
<!-- 近战 -->
<ThingDef Name="WULA_ExperienceCore_Weapon_Melee" ParentName="BaseMeleeWeapon_Blunt_Quality">
<ThingDef Name="WULA_ExperienceCore_Weapon_Melee" ParentName="BaseMeleeWeapon_Blunt_Quality" Abstract="True">
<comps>
<!-- 经验核心组件 -->
<li Class="WulaFallenEmpire.CompProperties_ExperienceCore">
@@ -428,7 +430,7 @@
</ThingDef>
<!-- 射弹武器 -->
<ThingDef Name="WULA_ExperienceCore_Weapon_Ranged" ParentName="BaseHumanMakeableGun">
<ThingDef Name="WULA_ExperienceCore_Weapon_Ranged" ParentName="BaseHumanMakeableGun" Abstract="True">
<comps>
<!-- 经验核心组件 -->
<li Class="WulaFallenEmpire.CompProperties_ExperienceCore">

View File

@@ -6,22 +6,22 @@
<!-- General Style -->
<labelFont>Small</labelFont>
<drawBorders>false</drawBorders>
<drawBorders>true</drawBorders>
<showDefName>false</showDefName>
<showLabel>true</showLabel>
<defaultBackgroundImagePath></defaultBackgroundImagePath>
<!-- Virtual Layout Dimensions -->
<lihuiSize>(500, 800)</lihuiSize>
<nameSize>(650, 130)</nameSize>
<textSize>(650, 350)</textSize>
<lihuiSize>(1093, 687)</lihuiSize>
<nameSize>(593, 530)</nameSize>
<textSize>(593, 330)</textSize>
<optionsWidth>750</optionsWidth>
<!-- Virtual Layout Offsets -->
<textNameOffset>0</textNameOffset>
<optionsTextOffset>0</optionsTextOffset>
<defaultWindowSize>(750, 600)</defaultWindowSize>
<defaultWindowSize>(693, 887)</defaultWindowSize>
<!-- New Layout Dimensions -->
<newLayoutNameSize>(200, 50)</newLayoutNameSize>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

View File

@@ -103,11 +103,13 @@ namespace WulaFallenEmpire
public override void DoWindowContents(Rect inRect)
{
// 绘制背景
if (background != null)
{
GUI.DrawTexture(inRect, background, ScaleMode.ScaleToFit);
}
// 调试信息def名称
if (Config.showDefName)
{
Text.Font = GameFont.Tiny;
@@ -116,34 +118,31 @@ namespace WulaFallenEmpire
GUI.color = Color.white;
}
if (Config.showLabel)
{
Text.Font = Config.labelFont;
Widgets.Label(new Rect(5, 20f, inRect.width - 10, 30f), def.label);
Text.Font = GameFont.Small;
}
// 使用新的布局参数
float scale = CalculateScale(inRect);
// 使用新的布局尺寸
float scaledLihuiWidth = Config.newLayoutLihuiSize.x * scale;
float scaledLihuiHeight = Config.newLayoutLihuiSize.y * scale;
float scaledTextWidth = Config.newLayoutTextSize.x * scale;
float scaledTextHeight = Config.newLayoutTextSize.y * scale;
float scaledOptionsWidth = Config.newLayoutOptionsWidth * scale;
float virtualWidth = Config.lihuiSize.x + Config.textSize.x;
float virtualHeight = Config.lihuiSize.y;
// 计算各元素高度
float labelHeight = 30f * scale;
float characterNameHeight = 25f * scale;
float descriptionHeight = scaledTextHeight;
float optionsHeight = CalculateOptionsHeight(def.options, scaledOptionsWidth, scale);
float scaleX = inRect.width / virtualWidth;
float scaleY = inRect.height / virtualHeight;
float scale = Mathf.Min(scaleX, scaleY) * 0.95f;
// 使用新的间距参数
float topMargin = Config.newLayoutPadding * scale;
float elementSpacing = Config.newLayoutTextNameOffset * scale;
float textOptionsSpacing = Config.newLayoutOptionsTextOffset * scale;
float scaledLihuiWidth = Config.lihuiSize.x * scale;
float scaledLihuiHeight = Config.lihuiSize.y * scale;
float scaledNameWidth = Config.nameSize.x * scale;
float scaledNameHeight = Config.nameSize.y * scale;
float scaledTextWidth = Config.textSize.x * scale;
float scaledTextHeight = Config.textSize.y * scale;
float scaledOptionsWidth = Config.optionsWidth * scale;
float currentY = topMargin;
float totalContentWidth = scaledLihuiWidth + scaledTextWidth;
float totalContentHeight = scaledLihuiHeight;
float startX = (inRect.width - totalContentWidth) / 2;
float startY = (inRect.height - totalContentHeight) / 2;
Rect lihuiRect = new Rect(startX, startY, scaledLihuiWidth, scaledLihuiHeight);
// 1. 立绘(水平居中,顶着顶部)
Rect lihuiRect = new Rect((inRect.width - scaledLihuiWidth) / 2, currentY, scaledLihuiWidth, scaledLihuiHeight);
if (portrait != null)
{
GUI.DrawTexture(lihuiRect, portrait, ScaleMode.ScaleToFit);
@@ -152,59 +151,146 @@ namespace WulaFallenEmpire
{
Widgets.DrawBox(lihuiRect);
}
currentY += scaledLihuiHeight + elementSpacing;
Rect nameRect = new Rect(lihuiRect.xMax, lihuiRect.y, scaledNameWidth, scaledNameHeight);
if (Config.drawBorders)
// 2. Label水平居中
if (Config.showLabel)
{
Widgets.DrawBox(nameRect);
Rect labelRect = new Rect(0, currentY, inRect.width, labelHeight);
Text.Anchor = TextAnchor.MiddleCenter;
Text.Font = Config.labelFont;
Widgets.Label(labelRect, def.label);
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;
if (Config.drawBorders)
{
Widgets.DrawBox(labelRect);
}
currentY += labelHeight + elementSpacing;
}
// 3. CharacterName水平居中
Rect nameRect = new Rect(0, currentY, inRect.width, characterNameHeight);
Text.Anchor = TextAnchor.MiddleCenter;
Text.Font = GameFont.Medium;
Widgets.Label(nameRect, def.characterName);
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;
if (Config.drawBorders)
{
Widgets.DrawBox(nameRect);
}
currentY += characterNameHeight + elementSpacing;
Rect textRect = new Rect(nameRect.x, nameRect.yMax + Config.textNameOffset * scale, scaledTextWidth, scaledTextHeight);
// 4. Descriptions水平居中
Rect textRect = new Rect((inRect.width - scaledTextWidth) / 2, currentY, scaledTextWidth, descriptionHeight);
if (Config.drawBorders)
{
Widgets.DrawBox(textRect);
}
Rect textInnerRect = textRect.ContractedBy(10f * scale);
Widgets.Label(textInnerRect, selectedDescription);
Rect optionRect = new Rect(nameRect.x, textRect.yMax + Config.optionsTextOffset * scale, scaledOptionsWidth, lihuiRect.height - nameRect.height - textRect.height - (Config.textNameOffset + Config.optionsTextOffset) * scale);
Listing_Standard listing = new Listing_Standard();
listing.Begin(optionRect.ContractedBy(10f * scale));
if (def.options != null)
{
foreach (var option in def.options)
{
string reason;
bool conditionsMet = AreConditionsMet(option.conditions, out reason);
// 增加内边距
float textInnerPadding = 15f * scale;
Rect textInnerRect = textRect.ContractedBy(textInnerPadding);
Widgets.LabelScrollable(textInnerRect, selectedDescription, ref scrollPosition);
currentY += descriptionHeight + textOptionsSpacing;
if (conditionsMet)
// 5. Options水平居中
Rect optionRect = new Rect((inRect.width - scaledOptionsWidth) / 2, currentY, scaledOptionsWidth, optionsHeight);
if (Config.drawBorders)
{
Widgets.DrawBox(optionRect);
}
// 增加内边距
float optionsInnerPadding = 10f * scale;
DrawOptions(optionRect.ContractedBy(optionsInnerPadding), def.options, scale);
}
// 计算缩放比例 - 使用新的布局参数
private float CalculateScale(Rect inRect)
{
float virtualWidth = Mathf.Max(
Config.newLayoutLihuiSize.x,
Config.newLayoutTextSize.x,
Config.newLayoutOptionsWidth
);
float scaleX = inRect.width / virtualWidth;
return Mathf.Min(scaleX, 1.0f) * 0.85f; // 稍微减少缩放以留出更多边距
}
// 计算选项区域高度
private float CalculateOptionsHeight(List<EventOption> options, float optionsWidth, float scale)
{
if (options == null || options.Count == 0)
return 0f;
float totalHeight = 0f;
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
foreach (var option in options)
{
string reason;
bool conditionsMet = AreConditionsMet(option.conditions, out reason);
if (!conditionsMet && option.hideWhenDisabled)
{
continue;
}
// 增加选项高度和间距
totalHeight += 35f * scale; // 每个选项高度
totalHeight += 8f * scale; // 选项间距
}
return totalHeight;
}
// 绘制选项
private void DrawOptions(Rect rect, List<EventOption> options, float scale)
{
if (options == null || options.Count == 0)
return;
Listing_Standard listing = new Listing_Standard();
listing.Begin(rect);
// 增加选项之间的间距
listing.verticalSpacing = 8f * scale;
foreach (var option in options)
{
string reason;
bool conditionsMet = AreConditionsMet(option.conditions, out reason);
if (conditionsMet)
{
if (listing.ButtonText(option.label))
{
if (listing.ButtonText(option.label))
{
HandleAction(option.optionEffects);
}
}
else
{
if (option.hideWhenDisabled)
{
continue;
}
Rect rect = listing.GetRect(30f);
Widgets.ButtonText(rect, option.label, false, true, false);
TooltipHandler.TipRegion(rect, GetDisabledReason(option, reason));
HandleAction(option.optionEffects);
}
}
else
{
if (option.hideWhenDisabled)
{
continue;
}
Rect buttonRect = listing.GetRect(35f * scale); // 增加按钮高度
Widgets.ButtonText(buttonRect, option.label, false, true, false);
TooltipHandler.TipRegion(buttonRect, GetDisabledReason(option, reason));
}
}
listing.End();
}
// 滚动位置用于描述文本
private Vector2 scrollPosition = Vector2.zero;
private void HandleAction(List<ConditionalEffects> conditionalEffects)
{
if (conditionalEffects.NullOrEmpty())
@@ -258,16 +344,14 @@ namespace WulaFallenEmpire
private string FormatDescription(string description)
{
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
// Use regex to find all placeholders like {variableName}
return Regex.Replace(description, @"\{(.+?)\}", match =>
{
string varName = match.Groups[1].Value;
if (eventVarManager.HasVariable(varName))
{
// Important: GetVariable<object> to get any type
return eventVarManager.GetVariable<object>(varName)?.ToString() ?? "";
}
return match.Value; // Keep placeholder if variable not found
return match.Value;
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB