mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 15:12:17 +08:00
Compare commits
2 Commits
ed8d7d61ff
...
2377f92589
| Author | SHA1 | Date | |
|---|---|---|---|
| 2377f92589 | |||
| 788ed4275e |
@@ -27,20 +27,30 @@ public static class PlanetFunctions
|
|||||||
{
|
{
|
||||||
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var package = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, etd.id);
|
var added = player.TryAddItemToPackage(sc.storage[i].itemId, sc.storage[i].count, 0, true, etd.id);
|
||||||
UIItemup.Up(sc.storage[i].itemId, package);
|
UIItemup.Up(sc.storage[i].itemId, added);
|
||||||
|
sc.storage[i].count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sc.storage[i].count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sc.storage = new StationStore[sc.storage.Length];
|
|
||||||
sc.needs = new int[sc.needs.Length];
|
|
||||||
}
|
}
|
||||||
if (toBag)
|
if (toBag)
|
||||||
{
|
{
|
||||||
player.controller.actionBuild.DoDismantleObject(etd.id);
|
int protoId = 0;
|
||||||
|
factory.DismantleFinally(player, etd.id, ref protoId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
factory.RemoveEntityWithComponents(etd.id, false);
|
var objId = etd.id;
|
||||||
|
factory.BeforeDismantleObject(objId);
|
||||||
|
factory.RemoveEntityWithComponents(objId, false);
|
||||||
|
factory.OnDismantleObject(objId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,28 +116,52 @@ public static class PlanetFunctions
|
|||||||
|
|
||||||
//planet.data = new PlanetRawData(planet.precision);
|
//planet.data = new PlanetRawData(planet.precision);
|
||||||
//planet.data.CalcVerts();
|
//planet.data.CalcVerts();
|
||||||
|
var stationPool = factory.transport?.stationPool;
|
||||||
|
if (stationPool != null)
|
||||||
|
{
|
||||||
|
foreach (var sc in stationPool)
|
||||||
|
{
|
||||||
|
if (sc is not { id: > 0 }) continue;
|
||||||
|
for (var i = sc.storage.Length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sc.storage[i].count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var physics = planet.physics;
|
||||||
|
var gpuiManager = GameMain.gpuiManager;
|
||||||
|
var blockContainer = factory.blockContainer;
|
||||||
|
var audio = planet.audio;
|
||||||
for (var id = factory.entityCursor - 1; id > 0; id--)
|
for (var id = factory.entityCursor - 1; id > 0; id--)
|
||||||
{
|
{
|
||||||
ref var ed = ref factory.entityPool[id];
|
ref var ed = ref factory.entityPool[id];
|
||||||
if (ed.id != id) continue;
|
if (ed.id != id) continue;
|
||||||
|
|
||||||
|
factory.BeforeDismantleObject(id);
|
||||||
|
|
||||||
if (ed.colliderId != 0)
|
if (ed.colliderId != 0)
|
||||||
{
|
{
|
||||||
planet.physics.RemoveLinkedColliderData(ed.colliderId);
|
physics.RemoveLinkedColliderData(ed.colliderId);
|
||||||
planet.physics.NotifyObjectRemove(EObjectType.Entity, ed.id);
|
physics.NotifyObjectRemove(EObjectType.Entity, ed.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ed.modelId != 0)
|
if (ed.modelId != 0)
|
||||||
{
|
{
|
||||||
GameMain.gpuiManager.RemoveModel(ed.modelIndex, ed.modelId);
|
gpuiManager.RemoveModel(ed.modelIndex, ed.modelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ed.mmblockId != 0)
|
if (ed.mmblockId != 0)
|
||||||
{
|
{
|
||||||
factory.blockContainer.RemoveMiniBlock(ed.mmblockId);
|
blockContainer.RemoveMiniBlock(ed.mmblockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ed.audioId == 0) continue;
|
if (ed.audioId != 0)
|
||||||
planet.audio?.RemoveAudioData(ed.audioId);
|
{
|
||||||
|
audio.RemoveAudioData(ed.audioId);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory.OnDismantleObject(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var id = factory.prebuildCursor - 1; id > 0; id--)
|
for (var id = factory.prebuildCursor - 1; id > 0; id--)
|
||||||
@@ -136,11 +170,11 @@ public static class PlanetFunctions
|
|||||||
if (pb.id != id) continue;
|
if (pb.id != id) continue;
|
||||||
if (pb.colliderId != 0)
|
if (pb.colliderId != 0)
|
||||||
{
|
{
|
||||||
planet.physics.RemoveLinkedColliderData(pb.colliderId);
|
physics.RemoveLinkedColliderData(pb.colliderId);
|
||||||
}
|
}
|
||||||
if (pb.modelId != 0)
|
if (pb.modelId != 0)
|
||||||
{
|
{
|
||||||
GameMain.gpuiManager.RemovePrebuildModel(pb.modelIndex, pb.modelId);
|
gpuiManager.RemovePrebuildModel(pb.modelIndex, pb.modelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,19 +215,6 @@ public static class PlanetFunctions
|
|||||||
UIRoot.instance.uiGame.dfAssaultTip.ClearAllSpots();
|
UIRoot.instance.uiGame.dfAssaultTip.ClearAllSpots();
|
||||||
}
|
}
|
||||||
|
|
||||||
var stationPool = factory.transport?.stationPool;
|
|
||||||
if (stationPool != null)
|
|
||||||
{
|
|
||||||
foreach (var sc in stationPool)
|
|
||||||
{
|
|
||||||
if (sc is not { id: > 0 }) continue;
|
|
||||||
sc.storage = new StationStore[sc.storage.Length];
|
|
||||||
sc.needs = new int[sc.needs.Length];
|
|
||||||
int protoId = factory.entityPool[sc.entityId].protoId;
|
|
||||||
factory.DismantleFinally(player, sc.entityId, ref protoId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var planetId = planet.id;
|
var planetId = planet.id;
|
||||||
var gameScenario = GameMain.gameScenario;
|
var gameScenario = GameMain.gameScenario;
|
||||||
if (gameScenario != null)
|
if (gameScenario != null)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ public class MyComboBox : MonoBehaviour
|
|||||||
{
|
{
|
||||||
private RectTransform _rectTrans;
|
private RectTransform _rectTrans;
|
||||||
private UIComboBox _comboBox;
|
private UIComboBox _comboBox;
|
||||||
private Text _text;
|
|
||||||
public Action<int> OnSelChanged;
|
public Action<int> OnSelChanged;
|
||||||
|
|
||||||
private static GameObject _baseObject;
|
private static GameObject _baseObject;
|
||||||
@@ -34,7 +33,6 @@ public class MyComboBox : MonoBehaviour
|
|||||||
if (fontSource)
|
if (fontSource)
|
||||||
{
|
{
|
||||||
var txtComp = cbctrl.m_ListItemRes.GetComponentInChildren<Text>();
|
var txtComp = cbctrl.m_ListItemRes.GetComponentInChildren<Text>();
|
||||||
UXAssist.Logger.LogDebug($"txtComp: [{txtComp}]");
|
|
||||||
if (txtComp)
|
if (txtComp)
|
||||||
{
|
{
|
||||||
txtComp.font = fontSource.font;
|
txtComp.font = fontSource.font;
|
||||||
@@ -42,7 +40,6 @@ public class MyComboBox : MonoBehaviour
|
|||||||
txtComp.fontStyle = fontSource.fontStyle;
|
txtComp.fontStyle = fontSource.fontStyle;
|
||||||
}
|
}
|
||||||
txtComp = rect.Find("Main Button/Text")?.GetComponent<Text>();
|
txtComp = rect.Find("Main Button/Text")?.GetComponent<Text>();
|
||||||
UXAssist.Logger.LogDebug($"txtComp: [{txtComp}]");
|
|
||||||
if (txtComp)
|
if (txtComp)
|
||||||
{
|
{
|
||||||
txtComp.font = fontSource.font;
|
txtComp.font = fontSource.font;
|
||||||
@@ -63,8 +60,6 @@ public class MyComboBox : MonoBehaviour
|
|||||||
var cb = gameObject.AddComponent<MyComboBox>();
|
var cb = gameObject.AddComponent<MyComboBox>();
|
||||||
var rtrans = Util.NormalizeRectWithTopLeft(cb, x, y, parent);
|
var rtrans = Util.NormalizeRectWithTopLeft(cb, x, y, parent);
|
||||||
cb._rectTrans = rtrans;
|
cb._rectTrans = rtrans;
|
||||||
cb._text = gameObject.transform.Find("Main Button/Text")?.GetComponent<Text>();
|
|
||||||
UXAssist.Logger.LogDebug($"cb._text: [{cb._text}]");
|
|
||||||
var box = rtrans.GetComponent<UIComboBox>();
|
var box = rtrans.GetComponent<UIComboBox>();
|
||||||
cb._comboBox = box;
|
cb._comboBox = box;
|
||||||
box.onItemIndexChange.AddListener(() => { cb.OnSelChanged?.Invoke(box.itemIndex); });
|
box.onItemIndexChange.AddListener(() => { cb.OnSelChanged?.Invoke(box.itemIndex); });
|
||||||
@@ -81,21 +76,11 @@ public class MyComboBox : MonoBehaviour
|
|||||||
private void UpdateComboBoxPosition()
|
private void UpdateComboBoxPosition()
|
||||||
{
|
{
|
||||||
var rtrans = (RectTransform)_comboBox.transform;
|
var rtrans = (RectTransform)_comboBox.transform;
|
||||||
var oldPosition = rtrans.localPosition;
|
|
||||||
var pwidth = _text.preferredWidth;
|
|
||||||
rtrans.localPosition = new Vector3(pwidth + 5f, oldPosition.y, oldPosition.z);
|
|
||||||
_rectTrans.sizeDelta = new Vector2(rtrans.localPosition.x + 5f + rtrans.sizeDelta.x, _rectTrans.sizeDelta.y);
|
_rectTrans.sizeDelta = new Vector2(rtrans.localPosition.x + 5f + rtrans.sizeDelta.x, _rectTrans.sizeDelta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPrompt(string prompt)
|
|
||||||
{
|
|
||||||
_text.text = prompt.Translate();
|
|
||||||
UpdateComboBoxPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetFontSize(int size)
|
public void SetFontSize(int size)
|
||||||
{
|
{
|
||||||
_text.fontSize = size;
|
|
||||||
_comboBox.ItemButtons.ForEach(b => b.GetComponentInChildren<Text>().fontSize = size);
|
_comboBox.ItemButtons.ForEach(b => b.GetComponentInChildren<Text>().fontSize = size);
|
||||||
_comboBox.m_ListItemRes.GetComponentInChildren<Text>().fontSize = size;
|
_comboBox.m_ListItemRes.GetComponentInChildren<Text>().fontSize = size;
|
||||||
var txtComp = _comboBox.transform.Find("Main Button")?.GetComponentInChildren<Text>();
|
var txtComp = _comboBox.transform.Find("Main Button")?.GetComponentInChildren<Text>();
|
||||||
@@ -137,12 +122,6 @@ public class MyComboBox : MonoBehaviour
|
|||||||
config.SettingChanged += _configChanged;
|
config.SettingChanged += _configChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyComboBox WithPrompt(string prompt)
|
|
||||||
{
|
|
||||||
SetPrompt(prompt);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyComboBox WithFontSize(int size)
|
public MyComboBox WithFontSize(int size)
|
||||||
{
|
{
|
||||||
SetFontSize(size);
|
SetFontSize(size);
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ public class MyConfigWindow : MyWindowWithTabs
|
|||||||
base._OnCreate();
|
base._OnCreate();
|
||||||
_windowTrans = GetComponent<RectTransform>();
|
_windowTrans = GetComponent<RectTransform>();
|
||||||
OnUICreated?.Invoke(this, _windowTrans);
|
OnUICreated?.Invoke(this, _windowTrans);
|
||||||
AutoFitWindowSize();
|
|
||||||
SetCurrentTab(0);
|
SetCurrentTab(0);
|
||||||
OnUpdateUI?.Invoke();
|
OnUpdateUI?.Invoke();
|
||||||
|
// Delay 500ms to run AutoFitWindowSize() after the window is created
|
||||||
|
// Invoke(nameof(AutoFitWindowSize), 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _OnDestroy()
|
public override void _OnDestroy()
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class MyWindow : ManualBehaviour
|
|||||||
var go = Instantiate(UIRoot.instance.uiGame.inserterWindow.gameObject);
|
var go = Instantiate(UIRoot.instance.uiGame.inserterWindow.gameObject);
|
||||||
go.SetActive(false);
|
go.SetActive(false);
|
||||||
go.name = "my-window";
|
go.name = "my-window";
|
||||||
Destroy(go.GetComponent<UITankWindow>());
|
Destroy(go.GetComponent<UIInserterWindow>());
|
||||||
for (var i = go.transform.childCount - 1; i >= 0; i--)
|
for (var i = go.transform.childCount - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var child = go.transform.GetChild(i).gameObject;
|
var child = go.transform.GetChild(i).gameObject;
|
||||||
@@ -63,6 +63,11 @@ public class MyWindow : ManualBehaviour
|
|||||||
return (T)win;
|
return (T)win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void _OnOpen()
|
||||||
|
{
|
||||||
|
AutoFitWindowSize();
|
||||||
|
}
|
||||||
|
|
||||||
public override void _OnFree()
|
public override void _OnFree()
|
||||||
{
|
{
|
||||||
OnFree?.Invoke();
|
OnFree?.Invoke();
|
||||||
@@ -99,6 +104,15 @@ public class MyWindow : ManualBehaviour
|
|||||||
{
|
{
|
||||||
var trans = GetComponent<RectTransform>();
|
var trans = GetComponent<RectTransform>();
|
||||||
trans.sizeDelta = new Vector2(_maxX + Margin + TabWidth + Spacing + Margin, MaxY + TitleHeight + Margin);
|
trans.sizeDelta = new Vector2(_maxX + Margin + TabWidth + Spacing + Margin, MaxY + TitleHeight + Margin);
|
||||||
|
// var panelBgTrans = trans.Find("panel-bg")?.GetComponent<RectTransform>();
|
||||||
|
// if (panelBgTrans != null)
|
||||||
|
// {
|
||||||
|
// panelBgTrans.anchorMax = new Vector2(0f, 1f);
|
||||||
|
// panelBgTrans.anchorMin = new Vector2(0f, 1f);
|
||||||
|
// panelBgTrans.pivot = new Vector2(0f, 1f);
|
||||||
|
// panelBgTrans.localPosition = new Vector3(0f, 0f, 0f);
|
||||||
|
// panelBgTrans.sizeDelta = new Vector2(_maxX + Margin + TabWidth + Spacing + Margin, MaxY + TitleHeight + Margin);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddElement(float x, float y, RectTransform rect, RectTransform parent = null)
|
private static void AddElement(float x, float y, RectTransform rect, RectTransform parent = null)
|
||||||
@@ -212,9 +226,9 @@ public class MyWindow : ManualBehaviour
|
|||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyComboBox AddComboBox(float x, float y, RectTransform parent, string label = "", int fontSize = 15)
|
public MyComboBox AddComboBox(float x, float y, RectTransform parent, int fontSize = 15)
|
||||||
{
|
{
|
||||||
var comboBox = MyComboBox.CreateComboBox(x, y, parent).WithPrompt(label).WithFontSize(fontSize);
|
var comboBox = MyComboBox.CreateComboBox(x, y, parent).WithFontSize(fontSize);
|
||||||
_maxX = Math.Max(_maxX, x + comboBox.Width);
|
_maxX = Math.Max(_maxX, x + comboBox.Width);
|
||||||
MaxY = Math.Max(MaxY, y + comboBox.Height);
|
MaxY = Math.Max(MaxY, y + comboBox.Height);
|
||||||
return comboBox;
|
return comboBox;
|
||||||
|
|||||||
@@ -333,7 +333,8 @@ public static class UIConfigWindow
|
|||||||
x = 0f;
|
x = 0f;
|
||||||
}
|
}
|
||||||
y += 36f;
|
y += 36f;
|
||||||
wnd.AddComboBox(x + 2f, y, tab1, "Process priority").WithItems("High", "Above Normal", "Normal", "Below Normal", "Idle").WithSize(100f, 0f).WithConfigEntry(WindowFunctions.ProcessPriority);
|
txt = wnd.AddText2(x + 2f, y, tab1, "Process priority", 15, "process-priority");
|
||||||
|
wnd.AddComboBox(x + 7f + txt.preferredWidth, y, tab1).WithItems("High", "Above Normal", "Normal", "Below Normal", "Idle").WithSize(100f, 0f).WithConfigEntry(WindowFunctions.ProcessPriority);
|
||||||
|
|
||||||
var tab2 = wnd.AddTab(trans, "Factory");
|
var tab2 = wnd.AddTab(trans, "Factory");
|
||||||
x = 0f;
|
x = 0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user