mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 12:53:34 +08:00
WIP
This commit is contained in:
@@ -73,7 +73,7 @@ public class MyCheckBox : MonoBehaviour
|
||||
{
|
||||
if (labelText != null)
|
||||
{
|
||||
labelText.text = val;
|
||||
labelText.text = val.Translate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MyKeyBinder : MonoBehaviour
|
||||
public static RectTransform CreateKeyBinder(float x, float y, RectTransform parent, ConfigEntry<KeyboardShortcut> config, string label = "", int fontSize = 17)
|
||||
{
|
||||
var optionWindow = UIRoot.instance.optionWindow;
|
||||
var uikeyEntry = GameObject.Instantiate<UIKeyEntry>(optionWindow.entryPrefab);
|
||||
var uikeyEntry = Instantiate(optionWindow.entryPrefab);
|
||||
GameObject go;
|
||||
(go = uikeyEntry.gameObject).SetActive(true);
|
||||
go.name = "my-keybinder";
|
||||
@@ -65,7 +65,7 @@ public class MyKeyBinder : MonoBehaviour
|
||||
kb.setNoneKeyUIButton = uikeyEntry.setNoneKeyUIButton;
|
||||
|
||||
|
||||
kb.functionText.text = label;
|
||||
kb.functionText.text = label.Translate();
|
||||
kb.functionText.fontSize = 17;
|
||||
|
||||
((RectTransform)kb.keyText.transform).anchoredPosition = new Vector2(20f, -27f);
|
||||
@@ -79,23 +79,17 @@ public class MyKeyBinder : MonoBehaviour
|
||||
kb.rectTrans = rect;
|
||||
|
||||
//rect.sizeDelta = new Vector2(240f, 64f);
|
||||
GameObject.Destroy(uikeyEntry);
|
||||
Destroy(uikeyEntry);
|
||||
kb.setNoneKeyUIButton.gameObject.SetActive(false);
|
||||
|
||||
kb.SettingChanged();
|
||||
config.SettingChanged += (sender, args) => {
|
||||
config.SettingChanged += (_, _) => {
|
||||
kb.SettingChanged();
|
||||
};
|
||||
kb.inputUIButton.onClick += kb.OnInputUIButtonClick;
|
||||
kb.setDefaultUIButton.onClick += kb.OnSetDefaultKeyClick;
|
||||
//kb.setNoneKeyUIButton.onClick += kb.OnSetNoneKeyClick;
|
||||
return go.transform as RectTransform;
|
||||
|
||||
void ResetAnchor(RectTransform theRect)
|
||||
{
|
||||
theRect.anchorMax = Vector2.zero;
|
||||
theRect.anchorMin = Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MyWindow: ManualBehaviour
|
||||
var txt = gameObject.transform.Find("panel-bg/title-text")?.gameObject.GetComponent<Text>();
|
||||
if (txt)
|
||||
{
|
||||
txt.text = title;
|
||||
txt.text = title.Translate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MyWindow: ManualBehaviour
|
||||
var src = UIRoot.instance.uiGame.assemblerWindow.stateText;
|
||||
var txt = Instantiate(src);
|
||||
txt.gameObject.name = objName;
|
||||
txt.text = label;
|
||||
txt.text = label.Translate();
|
||||
txt.color = new Color(1f, 1f, 1f, 0.4f);
|
||||
txt.alignment = TextAnchor.MiddleLeft;
|
||||
txt.fontSize = fontSize;
|
||||
@@ -74,7 +74,7 @@ public class MyWindow: ManualBehaviour
|
||||
var btn = Instantiate(panel.cpuActiveButton);
|
||||
btn.gameObject.name = objName;
|
||||
var rect = Util.NormalizeRectWithTopLeft(btn, x, y, parent);
|
||||
rect.sizeDelta = new Vector2(120, rect.sizeDelta.y);
|
||||
rect.sizeDelta = new Vector2(150, rect.sizeDelta.y);
|
||||
var l = btn.gameObject.transform.Find("button-text").GetComponent<Localizer>();
|
||||
var t = btn.gameObject.transform.Find("button-text").GetComponent<Text>();
|
||||
if (l != null)
|
||||
@@ -99,6 +99,28 @@ public class MyWindow: ManualBehaviour
|
||||
return btn;
|
||||
}
|
||||
|
||||
protected UIButton AddFlatButton(float x, float y, RectTransform parent, string text = "", int fontSize = 12, string objName = "button", UnityAction onClick = null)
|
||||
{
|
||||
var panel = UIRoot.instance.uiGame.dysonEditor.controlPanel.hierarchy.layerPanel;
|
||||
var btn = Instantiate(panel.layerButtons[0]);
|
||||
btn.gameObject.name = objName;
|
||||
Util.NormalizeRectWithTopLeft(btn, x, y, parent);
|
||||
var t = btn.gameObject.transform.Find("Text").GetComponent<Text>();
|
||||
if (t != null)
|
||||
{
|
||||
t.text = text.Translate();
|
||||
}
|
||||
t.fontSize = fontSize;
|
||||
btn.button.onClick.RemoveAllListeners();
|
||||
_buttons[btn] = onClick;
|
||||
if (EventRegistered)
|
||||
{
|
||||
if (onClick != null)
|
||||
btn.button.onClick.AddListener(onClick);
|
||||
}
|
||||
return btn;
|
||||
}
|
||||
|
||||
protected InputField AddInputField(float x, float y, RectTransform parent, string text = "", int fontSize = 16, string objName = "input", UnityAction<string> onChanged = null, UnityAction<string> onEditEnd = null)
|
||||
{
|
||||
var stationWindow = UIRoot.instance.uiGame.stationWindow;
|
||||
@@ -169,7 +191,7 @@ public class MyWindow: ManualBehaviour
|
||||
|
||||
public class MyWindowWithTabs : MyWindow
|
||||
{
|
||||
private readonly List<Tuple<RectTransform, UIButton>> _tabs = new();
|
||||
protected readonly List<Tuple<RectTransform, UIButton>> Tabs = new();
|
||||
public override void TryClose()
|
||||
{
|
||||
_Close();
|
||||
@@ -202,11 +224,11 @@ public class MyWindowWithTabs : MyWindow
|
||||
}
|
||||
|
||||
var btnText = btn.transform.Find("Text").GetComponent<Text>();
|
||||
btnText.text = label;
|
||||
btnText.text = label.Translate();
|
||||
btnText.fontSize = 16;
|
||||
btn.data = index;
|
||||
|
||||
_tabs.Add(Tuple.Create(tabRect, btn));
|
||||
Tabs.Add(Tuple.Create(tabRect, btn));
|
||||
if (EventRegistered)
|
||||
{
|
||||
btn.onClick += OnTabButtonClick;
|
||||
@@ -218,7 +240,7 @@ public class MyWindowWithTabs : MyWindow
|
||||
{
|
||||
if (!EventRegistered)
|
||||
{
|
||||
foreach (var t in _tabs)
|
||||
foreach (var t in Tabs)
|
||||
{
|
||||
t.Item2.onClick += OnTabButtonClick;
|
||||
}
|
||||
@@ -230,7 +252,7 @@ public class MyWindowWithTabs : MyWindow
|
||||
{
|
||||
if (EventRegistered)
|
||||
{
|
||||
foreach (var t in _tabs)
|
||||
foreach (var t in Tabs)
|
||||
{
|
||||
t.Item2.onClick -= OnTabButtonClick;
|
||||
}
|
||||
@@ -242,17 +264,16 @@ public class MyWindowWithTabs : MyWindow
|
||||
|
||||
private void OnTabButtonClick(int index)
|
||||
{
|
||||
foreach (var t in _tabs)
|
||||
foreach (var (rectTransform, btn) in Tabs)
|
||||
{
|
||||
var btn = t.Item2;
|
||||
if (btn.data != index)
|
||||
{
|
||||
btn.highlighted = false;
|
||||
t.Item1.gameObject.SetActive(false);
|
||||
rectTransform.gameObject.SetActive(false);
|
||||
continue;
|
||||
}
|
||||
btn.highlighted = true;
|
||||
t.Item1.gameObject.SetActive(true);
|
||||
rectTransform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user