Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packer/Packer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ManifestObject
public string[] Dependencies { get; set; } =
{
"CommonAPI-CommonAPI-1.6.7", "nebula-NebulaMultiplayerModApi-2.1.0", "starfi5h-ErrorAnalyzer-1.3.3",
// "Shad0wlife-AssemblerUI-2.3.0",
"starfi5h-ModFixerOne-2.1.0",// "Shad0wlife-AssemblerUI-2.3.0",
};

internal static ManifestObject DebugObject()
Expand Down
29 changes: 20 additions & 9 deletions src/Patches/QuantumStorage/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,35 @@ public static void Init()
UIRoot.instance.uiGame.storageWindow.transform);

Transform orbitPickerTransform = orbitPicker.transform;
((RectTransform)orbitPickerTransform).localPosition = new Vector3(90, -443, 0);

((RectTransform)orbitPickerTransform).localPosition = new Vector3(90, -410, 0);

//orbitPicker
//child(0): title
//child(1): auto-orbit-label
//child(2): auto-orbit-switch[1]
//child(3): apply-planet-button[1]
//child(4): btn-group[22]

Transform titleTransform = orbitPickerTransform.GetChild(0).transform;
((RectTransform)titleTransform).localPosition = new Vector3(-120, -33, 0);
((RectTransform)titleTransform).localPosition = new Vector3(-120, -65, 0);

Object.DestroyImmediate(titleTransform.GetComponent<Localizer>());
Text component = titleTransform.GetComponent<Text>();
component.fontSize = 16;
component.text = "选择量子频道".TranslateFromJson();

for (var i = 1; i < orbitPickerTransform.childCount; i++) orbitPickerTransform.GetChild(i).gameObject.SetActive(false);
orbitPickerTransform.GetChild(1).gameObject.SetActive(false);
orbitPickerTransform.GetChild(2).gameObject.SetActive(false);
orbitPickerTransform.GetChild(3).gameObject.SetActive(false);

var btn_group_Transform = orbitPickerTransform.GetChild(4);

// todo
// for (var i = 3; i < 13; i++)
for (var i = 0; i < btn_group_Transform.childCount; i++)
{
// Transform transform = orbitPickerTransform.GetChild(i);
// transform.gameObject.SetActive(true);
// transform.GetComponent<Button>().interactable = true;
// btn-group结构是:无、编辑轨道、20个轨道
// 量子箱只要10个频道,所以保留索引2到11
Transform transform = btn_group_Transform.GetChild(i);
transform.gameObject.SetActive(i >= 2 && i <= 11);
}

Array.Resize(ref orbitPicker.orbitButtons, 11);
Expand Down
42 changes: 24 additions & 18 deletions src/Patches/UI/IconSetPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,39 @@ namespace ProjectGenesis.Patches
{
public static class IconSetPatches
{
/// <summary>
/// 屏蔽所有ID>2000的科技图标
/// </summary>
[HarmonyPatch(typeof(IconSet), nameof(IconSet.Create))]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> IconSet_Create_Transpiler(IEnumerable<CodeInstruction> instructions)
{
var matcher = new CodeMatcher(instructions);

// 找到 iconSprite != null 的检查位置
// 定位跳转目标 (IL_05f8: brfalse IL_06ff)
// 注意这个能匹配到两个地方,需要的刚好是第一个地方
matcher.MatchForward(false,
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(UnityEngine.Object), "op_Inequality")));

// 获取跳转标签 (IL_06ff)
object label = matcher.Advance(1).Operand;

// 获取 techProto 局部变量
object techProtoLocal = matcher.Advance(-7).Operand;

// 移动到 brfalse IL_06ff 之后
matcher.Advance(8);

// 插入 ID 检查: if (techProto.ID >= 2000) goto IL_06ff
matcher.Insert(
new CodeInstruction(OpCodes.Ldloc_S, techProtoLocal),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(TechProto), nameof(TechProto.ID))),
new CodeInstruction(OpCodes.Ldc_I4, 2000),
new CodeInstruction(OpCodes.Bge, label));
new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(TechProto), nameof(TechProto.iconSprite)))
);
// 抓取 brfalse 指向的 Label
var targetLabel = matcher.Clone().Advance(5).Operand;
// 拿到存储的 techProto 局部变量
var techProtoLocal = matcher.Clone().Advance(-1).Operand;
// 在IL_05f8之后插入:if (IsInvalidTech(techProto)) goto targetLabel;
matcher.Advance(6).InsertAndAdvance(
new CodeInstruction(OpCodes.Ldloc, techProtoLocal), // 将 techProto 压栈
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(IconSetPatches), nameof(IsInvalidTech))), // 调用静态方法
new CodeInstruction(OpCodes.Brtrue, targetLabel) // 如果返回值为 true (ID > 2000),则跳转
);

return matcher.InstructionEnumeration();
}

// 返回 true 表示需要跳转(即 ID > 2000)
public static bool IsInvalidTech(TechProto proto)
{
if (proto == null) return false;
return proto.ID > 2000;
}
}
}
3 changes: 1 addition & 2 deletions src/Patches/UI/ResearchLabPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public static class ResearchLabPatches
public static void UILabWindow_OnCreate_Postfix(UILabWindow __instance)
{
__instance.GetComponent<RectTransform>().sizeDelta = new Vector2(640, 430);
// todo
// __instance.transform.Find("matrix-group/lines").gameObject.SetActive(false);
__instance.transform.Find("matrix-group/matrix/lines").gameObject.SetActive(false);

const int len = 9;

Expand Down
51 changes: 32 additions & 19 deletions src/Patches/UI/UIOptionWindowPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,27 @@ public static class UIOptionWindowPatches
private static UIToggle LDBToolCacheToggle, HideTechModeToggle, ShowMessageToggle;

private static UIComboBox ProductOverflowComboBox;
/// <summary>
/// 包含左边字体(名称)、中间勾选框、右边字体(额外说明)
/// </summary>
private static GameObject QueryObj;
private static GameObject TipLevelObj;
/// <summary>
/// 包含左边字体(名称)
/// </summary>
private static GameObject TipLevelTextObj;
/// <summary>
/// 包含中间下拉框、右边字体(额外说明)
/// </summary>
private static GameObject TipLevelComboboxAndTextObj;

private static void Init()
{
QueryObj = GameObject.Find(
"UI Root/Overlay Canvas/Top Windows/Option Window/details/content-3/list/scroll-view/viewport/content/demolish-query");

TipLevelObj = GameObject.Find("UI Root/Overlay Canvas/Top Windows/Option Window/details/content-5/tiplevel");

Transform pageParent = TipLevelObj.transform.parent;
TipLevelTextObj = GameObject.Find("UI Root/Overlay Canvas/Top Windows/Option Window/details/content-5/labels/tiplevel");
TipLevelComboboxAndTextObj = GameObject.Find("UI Root/Overlay Canvas/Top Windows/Option Window/details/content-5/comps/ComboBox");
Transform pageParent = TipLevelComboboxAndTextObj.transform.parent.parent;

CreateSettingObject(pageParent, "gb-ldbtc-setting", "UseLDBToolCache".TranslateFromJson(),
"UseLDBToolCacheAdditionalText".TranslateFromJson(), new Vector2(30, -220), LDBToolCacheEntry.Value,
Expand All @@ -39,8 +49,7 @@ private static void Init()

CreateSettingObject(pageParent, "gb-csl-setting", "ProductOverflow".TranslateFromJson(),
"ProductOverflowAdditionalText".TranslateFromJson(),
new List<string>
{
new List<string> {
"默认设置".TranslateFromJson(),
"启用全部".TranslateFromJson(),
"禁用全部".TranslateFromJson(),
Expand Down Expand Up @@ -71,16 +80,20 @@ private static void CreateSettingObject(Transform parent, string name, string te
private static void CreateSettingObject(Transform parent, string name, string text, string additionalText, List<string> values,
Vector2 position, int index, out UIComboBox comboBox)
{
GameObject settingObj = Object.Instantiate(TipLevelObj, parent);

settingObj.name = name;
Object.DestroyImmediate(settingObj.GetComponent<Localizer>());
settingObj.GetComponent<Text>().text = text;

var settingObjTransform = (RectTransform)settingObj.transform;
settingObjTransform.anchoredPosition = position;

comboBox = settingObj.GetComponentInChildren<UIComboBox>();
GameObject textObj = Object.Instantiate(TipLevelTextObj, parent);
Object.DestroyImmediate(textObj.GetComponent<Localizer>());
textObj.GetComponent<Text>().text = text;
var textObjTransform = (RectTransform)textObj.transform;
textObjTransform.anchoredPosition = position;

GameObject comboBoxObj = Object.Instantiate(TipLevelComboboxAndTextObj, parent);
comboBoxObj.name = name;
Object.DestroyImmediate(comboBoxObj.GetComponent<Localizer>());
// comboBoxObj.transform.Find("Main Button/Text").GetComponent<Text>().text = text;
var comboBoxObjTransform = (RectTransform)comboBoxObj.transform;
comboBoxObjTransform.anchoredPosition = new Vector2(position.x + 310, position.y);

comboBox = comboBoxObj.GetComponentInChildren<UIComboBox>();
comboBox.Items = values;
comboBox.ItemButtons = new List<Button>();
comboBox.UpdateItems();
Expand All @@ -90,13 +103,13 @@ private static void CreateSettingObject(Transform parent, string name, string te

if (string.IsNullOrEmpty(additionalText)) return;

GameObject gameObject = Object.Instantiate(QueryObj.transform.GetChild(1).gameObject, settingObjTransform);
GameObject gameObject = Object.Instantiate(QueryObj.transform.GetChild(1).gameObject, comboBoxObjTransform);

Object.DestroyImmediate(gameObject.GetComponent<Localizer>());
gameObject.GetComponent<Text>().text = additionalText;

var gameObjectTransform = (RectTransform)gameObject.transform;
gameObjectTransform.anchoredPosition = new Vector2(680, 0);
gameObjectTransform.anchoredPosition = new Vector2(420, 0);
}

[HarmonyPatch(typeof(UIOptionWindow), nameof(UIOptionWindow._OnOpen))]
Expand Down
3 changes: 3 additions & 0 deletions src/ProjectGenesis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ private void PostAddDataAction()
};
vegeProto.Preload();

LabComponent.matrixPoints = new int[9];

LabComponent.matrixIds = new[]
{
ProtoID.I电磁矩阵, ProtoID.I能量矩阵, ProtoID.I结构矩阵, ProtoID.I信息矩阵,
Expand Down Expand Up @@ -283,6 +285,7 @@ private void PostAddDataAction()
ModelProto.InitMaxModelIndex();
ModelProto.InitModelIndices();
ModelProto.InitModelOrders();
RecipeProto.InitRecipeItems();
RecipeProto.InitFractionatorNeeds();
SignalProtoSet.InitSignalKeyIdPairs();
RaycastLogic.LoadStatic();
Expand Down