mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 21:42:19 +08:00
WIP
This commit is contained in:
@@ -145,6 +145,7 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
public static void UIRoot__OnOpen_Postfix()
|
public static void UIRoot__OnOpen_Postfix()
|
||||||
{
|
{
|
||||||
if (_initialized) return;
|
if (_initialized) return;
|
||||||
|
{
|
||||||
var mainMenu = UIRoot.instance.uiMainMenu;
|
var mainMenu = UIRoot.instance.uiMainMenu;
|
||||||
var src = mainMenu.newGameButton.gameObject;
|
var src = mainMenu.newGameButton.gameObject;
|
||||||
var parent = src.transform.parent;
|
var parent = src.transform.parent;
|
||||||
@@ -153,16 +154,44 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
var btnConfig = btn.GetComponent<UIMainMenuButton>();
|
var btnConfig = btn.GetComponent<UIMainMenuButton>();
|
||||||
btnConfig.text.text = "CheatEnabler Config";
|
btnConfig.text.text = "CheatEnabler Config";
|
||||||
btnConfig.text.fontSize = btnConfig.text.fontSize * 7 / 8;
|
btnConfig.text.fontSize = btnConfig.text.fontSize * 7 / 8;
|
||||||
I18N.OnInitialized += () =>
|
I18N.OnInitialized += () => { btnConfig.text.text = "CheatEnabler Config".Translate(); };
|
||||||
{
|
|
||||||
btnConfig.text.text = "CheatEnabler Config".Translate();
|
|
||||||
};
|
|
||||||
btnConfig.transform.SetParent(parent);
|
btnConfig.transform.SetParent(parent);
|
||||||
var vec = ((RectTransform)mainMenu.exitButton.transform).anchoredPosition3D;
|
var vec = ((RectTransform)mainMenu.exitButton.transform).anchoredPosition3D;
|
||||||
var vec2 = ((RectTransform)mainMenu.creditsButton.transform).anchoredPosition3D;
|
var vec2 = ((RectTransform)mainMenu.creditsButton.transform).anchoredPosition3D;
|
||||||
var transform1 = (RectTransform)btn.transform;
|
var transform1 = (RectTransform)btn.transform;
|
||||||
transform1.anchoredPosition3D = new Vector3(vec.x, vec.y + (vec.y - vec2.y) * 2, vec.z);
|
transform1.anchoredPosition3D = new Vector3(vec.x, vec.y + (vec.y - vec2.y) * 2, vec.z);
|
||||||
|
btnConfig.button.onClick.RemoveAllListeners();
|
||||||
btnConfig.button.onClick.AddListener(ShowConfigWindow);
|
btnConfig.button.onClick.AddListener(ShowConfigWindow);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
var panel = UIRoot.instance.uiGame.planetGlobe;
|
||||||
|
var src = panel.button2;
|
||||||
|
var sandboxMenu = UIRoot.instance.uiGame.sandboxMenu;
|
||||||
|
var icon = sandboxMenu.categoryButtons[6].transform.Find("icon")?.GetComponent<Image>()?.sprite;
|
||||||
|
var b = GameObject.Instantiate<Button>(src, src.transform.parent);
|
||||||
|
var panelButtonGo = b.gameObject;
|
||||||
|
var rect = (RectTransform)panelButtonGo.transform;
|
||||||
|
var btn = panelButtonGo.GetComponent<UIButton>();
|
||||||
|
var img = panelButtonGo.transform.Find("button-2/icon")?.GetComponent<Image>();
|
||||||
|
if (img != null)
|
||||||
|
{
|
||||||
|
img.sprite = icon;
|
||||||
|
}
|
||||||
|
if (panelButtonGo != null && btn != null)
|
||||||
|
{
|
||||||
|
panelButtonGo.name = "open-cheatenabler-config";
|
||||||
|
rect.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||||||
|
rect.anchoredPosition3D = new Vector3(128f, -105f, 0f);
|
||||||
|
b.onClick.RemoveAllListeners();
|
||||||
|
btn.onClick += (_) => { ShowConfigWindow(); };
|
||||||
|
btn.tips.tipTitle = "CheatEnabler Config";
|
||||||
|
I18N.OnInitialized += () => { btn.tips.tipTitle = "CheatEnabler Config".Translate(); };
|
||||||
|
btn.tips.tipText = null;
|
||||||
|
btn.tips.corner = 9;
|
||||||
|
btn.tips.offset = new Vector2(-20f, -20f);
|
||||||
|
panelButtonGo.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user