using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Pinkpz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Pinkpz")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlanetBookmarks")]
[assembly: AssemblyTitle("PlanetBookmarks")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PlanetBookmarks
{
internal class BookmarkPanel
{
private class SavedRow
{
public int PlanetId;
public Image Bar;
public Image Bg;
public Text Name;
public Text Info;
public Text DelText;
public Text State;
}
private class PickRow
{
public int PlanetId;
public Image Bg;
public Image Bar;
}
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__ClosePanel;
}
private const float W = 470f;
private const float H = 612f;
private const float Pad = 14f;
public RectTransform Root;
private RectTransform savedContent;
private RectTransform pickContent;
private Text countLabel;
private Text selectedLabel;
private Text selectedInfo;
private Image selectedBar;
private InputField searchField;
private InputField nameField;
private readonly List<SavedRow> savedRows = new List<SavedRow>();
private readonly List<PickRow> pickRows = new List<PickRow>();
private int selectedPlanetId;
private bool nameIsAuto = true;
private bool settingName;
private int deleteArmedId;
private float deleteArmedUntil;
private float refreshTimer;
private bool pickerDirty = true;
public bool Visible
{
get
{
if ((Object)(object)Root != (Object)null)
{
return ((Component)Root).gameObject.activeSelf;
}
return false;
}
}
public BookmarkPanel(Transform parent)
{
Build(parent);
((Component)Root).gameObject.SetActive(false);
}
private void Build(Transform parent)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Expected O, but got Unknown
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Expected O, but got Unknown
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Unknown result type (might be due to invalid IL or missing references)
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_058d: Unknown result type (might be due to invalid IL or missing references)
//IL_0598: Unknown result type (might be due to invalid IL or missing references)
//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
//IL_05b1: Expected O, but got Unknown
//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
//IL_05c7: Expected O, but got Unknown
//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0603: Unknown result type (might be due to invalid IL or missing references)
//IL_0612: Unknown result type (might be due to invalid IL or missing references)
//IL_061c: Expected O, but got Unknown
//IL_0628: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Expected O, but got Unknown
//IL_0662: Unknown result type (might be due to invalid IL or missing references)
//IL_0671: Unknown result type (might be due to invalid IL or missing references)
//IL_067c: Unknown result type (might be due to invalid IL or missing references)
//IL_068b: Unknown result type (might be due to invalid IL or missing references)
//IL_0695: Expected O, but got Unknown
//IL_06df: Unknown result type (might be due to invalid IL or missing references)
//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0708: Unknown result type (might be due to invalid IL or missing references)
//IL_0712: Expected O, but got Unknown
//IL_0742: Unknown result type (might be due to invalid IL or missing references)
//IL_0751: Unknown result type (might be due to invalid IL or missing references)
//IL_075c: Unknown result type (might be due to invalid IL or missing references)
//IL_076b: Unknown result type (might be due to invalid IL or missing references)
//IL_0775: Expected O, but got Unknown
//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
//IL_07de: Unknown result type (might be due to invalid IL or missing references)
//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0802: Expected O, but got Unknown
//IL_080e: Unknown result type (might be due to invalid IL or missing references)
//IL_0818: Expected O, but got Unknown
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Expected O, but got Unknown
Image val = Kit.RoundBox("PlanetBookmarks_Panel", parent, Kit.PanelBg);
((Graphic)val).raycastTarget = true;
Root = ((Graphic)val).rectTransform;
RectTransform root = Root;
Vector2 anchorMin = (Root.anchorMax = Vector2.zero);
root.anchorMin = anchorMin;
Root.pivot = new Vector2(0f, 1f);
Root.sizeDelta = new Vector2(470f, 612f);
Kit.Frame((Transform)(object)Root, Kit.FrameCol);
Image val2 = Kit.RoundBox("header", (Transform)(object)Root, Kit.HeaderBg);
((Graphic)val2).raycastTarget = true;
Kit.Place(((Graphic)val2).rectTransform, new Vector2(0f, 1f), new Vector2(1f, -1f), new Vector2(468f, 34f));
((Component)val2).gameObject.AddComponent<DragHandle>().Target = Root;
Kit.Place(((Graphic)Kit.Plain("accent", ((Component)val2).transform, Kit.Blue)).rectTransform, new Vector2(0f, 0.5f), new Vector2(0f, 0f), new Vector2(3f, 20f));
Kit.Place(((Graphic)Kit.Plain("line", ((Component)val2).transform, new Color(Kit.Blue.r, Kit.Blue.g, Kit.Blue.b, 0.35f))).rectTransform, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(468f, 1f));
Text obj = Kit.Label("title", ((Component)val2).transform, "PLANET BOOKMARKS", 16, (TextAnchor)3, Kit.TextMain, gameFont: true);
obj.fontStyle = (FontStyle)1;
Kit.Place(((Graphic)obj).rectTransform, new Vector2(0f, 0.5f), new Vector2(14f, 0f), new Vector2(240f, 30f));
countLabel = Kit.Label("count", ((Component)val2).transform, "", 12, (TextAnchor)5, Kit.TextSub);
Kit.Place(((Graphic)countLabel).rectTransform, new Vector2(1f, 0.5f), new Vector2(-44f, 0f), new Vector2(120f, 30f));
Button obj2 = Kit.Btn("close", ((Component)val2).transform, "X", 13, Kit.Red);
Kit.Place((RectTransform)((Component)obj2).transform, new Vector2(1f, 0.5f), new Vector2(-8f, 0f), new Vector2(26f, 22f));
ButtonClickedEvent onClick = obj2.onClick;
object obj3 = <>O.<0>__ClosePanel;
if (obj3 == null)
{
UnityAction val3 = Host.ClosePanel;
<>O.<0>__ClosePanel = val3;
obj3 = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj3);
float num = -44f;
Section("SAVED PLANETS", "click a planet: guide on / off", num);
num -= 22f;
savedContent = Kit.ScrollList("saved", (Transform)(object)Root, 4f);
Kit.Place((RectTransform)((Transform)savedContent).parent, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(442f, 222f));
num -= 234f;
Kit.Place(((Graphic)Kit.Plain("divider", (Transform)(object)Root, new Color(Kit.Blue.r, Kit.Blue.g, Kit.Blue.b, 0.18f))).rectTransform, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(442f, 1f));
num -= 10f;
Section("ADD / RENAME / ZOOM", "choose a planet, then save or zoom", num);
num -= 22f;
Image val4 = Kit.RoundBox("selected", (Transform)(object)Root, Kit.RowBg);
Kit.Place(((Graphic)val4).rectTransform, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(268f, 38f));
Kit.Frame(((Component)val4).transform, new Color(Kit.FrameCol.r, Kit.FrameCol.g, Kit.FrameCol.b, 0.35f));
selectedBar = Kit.Plain("bar", ((Component)val4).transform, Kit.TextSub);
Kit.Place(((Graphic)selectedBar).rectTransform, new Vector2(0f, 0.5f), new Vector2(2f, 0f), new Vector2(3f, 28f));
selectedLabel = Kit.Label("name", ((Component)val4).transform, "No planet chosen", 14, (TextAnchor)0, Kit.TextMain);
Kit.Stretch(((Graphic)selectedLabel).rectTransform, 12f, 2f, 8f, 3f);
selectedInfo = Kit.Label("info", ((Component)val4).transform, "pick one in the list below", 11, (TextAnchor)6, Kit.TextSub);
Kit.Stretch(((Graphic)selectedInfo).rectTransform, 12f, 3f, 8f, 2f);
Button obj4 = Kit.Btn("here", (Transform)(object)Root, "HERE", 13, Kit.Blue);
Kit.Place((RectTransform)((Component)obj4).transform, new Vector2(1f, 1f), new Vector2(-14f, num), new Vector2(70f, 38f));
((UnityEvent)obj4.onClick).AddListener(new UnityAction(SelectCurrentPlanet));
Button obj5 = Kit.Btn("zoom", (Transform)(object)Root, "ZOOM TO", 13, Kit.Orange);
Kit.Place((RectTransform)((Component)obj5).transform, new Vector2(1f, 1f), new Vector2(-92f, num), new Vector2(88f, 38f));
((UnityEvent)obj5.onClick).AddListener(new UnityAction(ZoomSelected));
num -= 46f;
searchField = Kit.Field("search", (Transform)(object)Root, "Search planet or star...", 30);
Kit.Place((RectTransform)((Component)searchField).transform, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(442f, 28f));
((UnityEvent<string>)(object)searchField.onValueChanged).AddListener((UnityAction<string>)delegate
{
RebuildPicker();
});
num -= 34f;
pickContent = Kit.ScrollList("picker", (Transform)(object)Root, 2f);
Kit.Place((RectTransform)((Transform)pickContent).parent, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(442f, 156f));
num -= 166f;
nameField = Kit.Field("name", (Transform)(object)Root, "Your name for this planet...", 40);
Kit.Place((RectTransform)((Component)nameField).transform, new Vector2(0f, 1f), new Vector2(14f, num), new Vector2(346f, 32f));
((UnityEvent<string>)(object)nameField.onValueChanged).AddListener((UnityAction<string>)delegate
{
if (!settingName)
{
nameIsAuto = false;
}
});
((UnityEvent<string>)(object)nameField.onEndEdit).AddListener((UnityAction<string>)delegate
{
if (Input.GetKey((KeyCode)13) || Input.GetKey((KeyCode)271))
{
SaveSelected();
}
});
Button obj6 = Kit.Btn("save", (Transform)(object)Root, "SAVE", 14, Kit.Orange);
Kit.Place((RectTransform)((Component)obj6).transform, new Vector2(1f, 1f), new Vector2(-14f, num), new Vector2(88f, 32f));
((UnityEvent)obj6.onClick).AddListener(new UnityAction(SaveSelected));
}
private void Section(string title, string hint, float y)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
Text obj = Kit.Label("section", (Transform)(object)Root, title, 13, (TextAnchor)3, Kit.Blue, gameFont: true);
obj.fontStyle = (FontStyle)1;
Kit.Place(((Graphic)obj).rectTransform, new Vector2(0f, 1f), new Vector2(14f, y), new Vector2(200f, 18f));
Kit.Place(((Graphic)Kit.Label("hint", (Transform)(object)Root, hint, 11, (TextAnchor)5, Kit.TextSub)).rectTransform, new Vector2(1f, 1f), new Vector2(-14f, y), new Vector2(240f, 18f));
}
public void Open(Vector2 buttonPos, float buttonSize, Vector2 canvasSize)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
((Component)Root).gameObject.SetActive(true);
((Transform)Root).SetAsLastSibling();
float num = ((buttonPos.x < canvasSize.x * 0.5f) ? (buttonPos.x + buttonSize * 0.5f + 12f) : (buttonPos.x - buttonSize * 0.5f - 12f - 470f));
float num2 = buttonPos.y + 306f;
Root.anchoredPosition = new Vector2(num, num2);
Host.ClampToScreen(Root);
RebuildSaved();
pickerDirty = true;
RebuildPicker();
if (selectedPlanetId == 0)
{
SelectCurrentPlanet(tellIfNone: false);
}
RefreshDynamic();
}
public void Close()
{
((Component)Root).gameObject.SetActive(false);
deleteArmedId = 0;
}
public void OnGalaxyChanged()
{
selectedPlanetId = 0;
SetName("", auto: true);
if ((Object)(object)searchField != (Object)null)
{
searchField.text = "";
}
pickerDirty = true;
if (Visible)
{
RebuildSaved();
RebuildPicker();
UpdateSelectedBox();
}
}
public void Tick()
{
if (Visible)
{
if (deleteArmedId != 0 && Time.unscaledTime > deleteArmedUntil)
{
deleteArmedId = 0;
RefreshDynamic();
}
refreshTimer -= Time.unscaledDeltaTime;
if (refreshTimer <= 0f)
{
refreshTimer = 0.5f;
RefreshDynamic();
}
}
}
private void RebuildSaved()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
Kit.Clear((Transform)(object)savedContent);
savedRows.Clear();
if (Store.Items.Count == 0)
{
Text obj = Kit.Label("empty", (Transform)(object)savedContent, "No saved planets yet.\nChoose one below, give it a name and press SAVE.", 13, (TextAnchor)4, Kit.TextSub);
obj.horizontalOverflow = (HorizontalWrapMode)0;
Kit.Height((Component)(object)obj, 120f);
}
foreach (Bookmark item in Store.Items)
{
savedRows.Add(AddSavedRow(item));
}
countLabel.text = ((Store.Items.Count == 1) ? "1 saved" : (Store.Items.Count + " saved"));
RefreshDynamic();
}
private SavedRow AddSavedRow(Bookmark b)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Expected O, but got Unknown
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Expected O, but got Unknown
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Expected O, but got Unknown
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Expected O, but got Unknown
SavedRow obj = new SavedRow
{
PlanetId = b.PlanetId
};
int id = b.PlanetId;
Image val = Kit.RoundBox("row", (Transform)(object)savedContent, Color.white);
((Graphic)val).raycastTarget = true;
Kit.Height((Component)(object)val, 48f);
Button obj2 = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj2).targetGraphic = (Graphic)(object)val;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj2).navigation = navigation;
ColorBlock colors = ((Selectable)obj2).colors;
((ColorBlock)(ref colors)).normalColor = Kit.RowBg;
((ColorBlock)(ref colors)).highlightedColor = new Color(0.12f, 0.22f, 0.32f, 1f);
((ColorBlock)(ref colors)).pressedColor = new Color(0.18f, 0.32f, 0.46f, 1f);
((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
((ColorBlock)(ref colors)).fadeDuration = 0.08f;
((Selectable)obj2).colors = colors;
((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
{
ToggleGuide(id);
Select(id);
});
obj.Bg = val;
obj.Bar = Kit.Plain("bar", ((Component)val).transform, Kit.Blue);
Kit.Place(((Graphic)obj.Bar).rectTransform, new Vector2(0f, 0.5f), new Vector2(2f, 0f), new Vector2(3f, 36f));
obj.Name = Kit.Label("name", ((Component)val).transform, b.Name, 15, (TextAnchor)0, Kit.TextMain);
obj.Name.fontStyle = (FontStyle)1;
obj.Name.horizontalOverflow = (HorizontalWrapMode)0;
obj.Name.verticalOverflow = (VerticalWrapMode)0;
Kit.Stretch(((Graphic)obj.Name).rectTransform, 13f, 22f, 150f, 5f);
obj.Info = Kit.Label("info", ((Component)val).transform, "", 11, (TextAnchor)6, Kit.TextSub);
obj.Info.horizontalOverflow = (HorizontalWrapMode)0;
obj.Info.verticalOverflow = (VerticalWrapMode)0;
Kit.Stretch(((Graphic)obj.Info).rectTransform, 13f, 5f, 104f, 25f);
obj.State = Kit.Label("state", ((Component)val).transform, "", 11, (TextAnchor)2, Kit.Orange, gameFont: true);
Kit.Place(((Graphic)obj.State).rectTransform, new Vector2(1f, 1f), new Vector2(-104f, -5f), new Vector2(60f, 16f));
Button obj3 = Kit.Btn("edit", ((Component)val).transform, "EDIT", 11, Kit.Blue);
Kit.Place((RectTransform)((Component)obj3).transform, new Vector2(1f, 0.5f), new Vector2(-52f, 0f), new Vector2(44f, 24f));
((UnityEvent)obj3.onClick).AddListener((UnityAction)delegate
{
EditBookmark(id);
});
Text label;
Button obj4 = Kit.Btn("del", ((Component)val).transform, "DEL", 11, Kit.Red, out label);
Kit.Place((RectTransform)((Component)obj4).transform, new Vector2(1f, 0.5f), new Vector2(-6f, 0f), new Vector2(44f, 24f));
((UnityEvent)obj4.onClick).AddListener((UnityAction)delegate
{
DeleteBookmark(id);
});
obj.DelText = label;
return obj;
}
private void RefreshDynamic()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
int num = CurrentGuide();
foreach (SavedRow savedRow in savedRows)
{
PlanetData val = Planet(savedRow.PlanetId);
bool flag = val != null && val.astroId == num;
((Graphic)savedRow.Bar).color = ((val == null) ? Kit.TextSub : (flag ? Kit.Orange : Kit.Blue));
savedRow.State.text = (flag ? "GUIDING" : "");
savedRow.Info.text = ((val == null) ? "planet not found in this galaxy" : Describe(val));
savedRow.DelText.text = ((deleteArmedId == savedRow.PlanetId) ? "SURE?" : "DEL");
}
foreach (PickRow pickRow in pickRows)
{
((Graphic)pickRow.Bar).color = (Color)((pickRow.PlanetId == selectedPlanetId) ? Kit.Orange : new Color(0f, 0f, 0f, 0f));
}
UpdateSelectedBox();
}
private void ToggleGuide(int planetId)
{
PlanetData val = Planet(planetId);
Player mainPlayer = GameMain.mainPlayer;
if (val == null || mainPlayer == null || mainPlayer.navigation == null)
{
Kit.Popup("Planet not found in this galaxy");
return;
}
Bookmark bookmark = Store.Find(planetId);
string text = ((bookmark != null) ? bookmark.Name : val.displayName);
PlayerNavigation navigation = mainPlayer.navigation;
if (navigation.indicatorAstroId == val.astroId)
{
navigation.indicatorAstroId = 0;
Kit.Popup("Guide off: " + text);
}
else
{
navigation.indicatorAstroId = val.astroId;
Kit.Popup("Guiding to " + text);
}
RefreshDynamic();
}
private void EditBookmark(int planetId)
{
Bookmark bookmark = Store.Find(planetId);
if (bookmark != null)
{
selectedPlanetId = planetId;
SetName(bookmark.Name, auto: false);
RefreshDynamic();
nameField.ActivateInputField();
nameField.MoveTextEnd(false);
}
}
private void DeleteBookmark(int planetId)
{
if (deleteArmedId != planetId)
{
deleteArmedId = planetId;
deleteArmedUntil = Time.unscaledTime + 3f;
RefreshDynamic();
return;
}
Bookmark bookmark = Store.Find(planetId);
deleteArmedId = 0;
Store.Remove(planetId);
Store.Save();
RebuildSaved();
pickerDirty = true;
RebuildPicker();
if (bookmark != null)
{
Kit.Popup("Deleted: " + bookmark.Name);
}
}
private void RebuildPicker()
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
if (!Visible && !pickerDirty)
{
return;
}
pickerDirty = false;
Kit.Clear((Transform)(object)pickContent);
pickRows.Clear();
GalaxyData galaxy = GameMain.galaxy;
Player mainPlayer = GameMain.mainPlayer;
if (galaxy == null || galaxy.stars == null)
{
return;
}
string text = (searchField.text ?? "").Trim().ToLowerInvariant();
List<KeyValuePair<double, PlanetData>> list = new List<KeyValuePair<double, PlanetData>>();
StarData[] stars = galaxy.stars;
foreach (StarData val in stars)
{
if (val == null || val.planets == null)
{
continue;
}
double num;
if (mainPlayer == null)
{
num = 0.0;
}
else
{
VectorLF3 val2 = val.uPosition - mainPlayer.uPosition;
num = ((VectorLF3)(ref val2)).magnitude;
}
double num2 = num;
string text2 = (val.displayName ?? "").ToLowerInvariant();
int num3 = Math.Min(val.planetCount, val.planets.Length);
for (int j = 0; j < num3; j++)
{
PlanetData val3 = val.planets[j];
if (val3 == null)
{
continue;
}
if (text.Length > 0)
{
Bookmark bookmark = Store.Find(val3.id);
if (!(val3.displayName ?? "").ToLowerInvariant().Contains(text) && !text2.Contains(text) && (bookmark == null || !bookmark.Name.ToLowerInvariant().Contains(text)))
{
continue;
}
}
list.Add(new KeyValuePair<double, PlanetData>(num2 + (double)j * 0.001, val3));
}
}
list.Sort((KeyValuePair<double, PlanetData> a, KeyValuePair<double, PlanetData> b) => a.Key.CompareTo(b.Key));
int val4 = Math.Max(10, PlanetBookmarksPlugin.MaxPickerRows.Value);
int num4 = Math.Min(list.Count, val4);
int num5 = -1;
for (int num6 = 0; num6 < num4; num6++)
{
PlanetData value = list[num6].Value;
if (value.star != null && value.star.id != num5)
{
num5 = value.star.id;
AddStarHeader(value.star);
}
pickRows.Add(AddPickRow(value));
}
if (list.Count == 0)
{
Kit.Height((Component)(object)Kit.Label("none", (Transform)(object)pickContent, "No planet matches", 12, (TextAnchor)4, Kit.TextSub), 40f);
}
else if (list.Count > num4)
{
Kit.Height((Component)(object)Kit.Label("more", (Transform)(object)pickContent, "+" + (list.Count - num4) + " more - type in the search box", 11, (TextAnchor)4, Kit.TextSub), 24f);
}
RefreshDynamic();
}
private void AddStarHeader(StarData star)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
Kit.Height((Component)(object)Kit.Label("star", (Transform)(object)pickContent, (star.displayName ?? "?") + " " + StarDistance(star), 11, (TextAnchor)6, new Color(Kit.Blue.r, Kit.Blue.g, Kit.Blue.b, 0.85f), gameFont: true), 20f);
}
private PickRow AddPickRow(PlanetData p)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
PickRow obj = new PickRow
{
PlanetId = p.id
};
int id = p.id;
Image val = Kit.RoundBox("planet", (Transform)(object)pickContent, Color.white);
((Graphic)val).raycastTarget = true;
Kit.Height((Component)(object)val, 26f);
Button obj2 = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj2).targetGraphic = (Graphic)(object)val;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj2).navigation = navigation;
ColorBlock colors = ((Selectable)obj2).colors;
((ColorBlock)(ref colors)).normalColor = new Color(0.06f, 0.1f, 0.15f, 0.85f);
((ColorBlock)(ref colors)).highlightedColor = new Color(0.12f, 0.22f, 0.32f, 1f);
((ColorBlock)(ref colors)).pressedColor = new Color(0.18f, 0.32f, 0.46f, 1f);
((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
((ColorBlock)(ref colors)).fadeDuration = 0.06f;
((Selectable)obj2).colors = colors;
((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
{
Select(id);
});
obj.Bg = val;
obj.Bar = Kit.Plain("bar", ((Component)val).transform, new Color(0f, 0f, 0f, 0f));
Kit.Place(((Graphic)obj.Bar).rectTransform, new Vector2(0f, 0.5f), new Vector2(2f, 0f), new Vector2(3f, 18f));
Bookmark bookmark = Store.Find(p.id);
Text obj3 = Kit.Label(text: p.displayName + ((bookmark != null) ? (" [" + bookmark.Name + "]") : ""), name: "name", parent: ((Component)val).transform, size: 13, align: (TextAnchor)3, color: (bookmark != null) ? Kit.Orange : Kit.TextMain);
obj3.horizontalOverflow = (HorizontalWrapMode)0;
obj3.verticalOverflow = (VerticalWrapMode)0;
Kit.Stretch(((Graphic)obj3).rectTransform, 12f, 0f, 118f);
Kit.Stretch(((Graphic)Kit.Label("type", ((Component)val).transform, SafeType(p), 11, (TextAnchor)5, Kit.TextSub)).rectTransform, 0f, 0f, 8f);
return obj;
}
private void Select(int planetId)
{
selectedPlanetId = planetId;
if (nameIsAuto || string.IsNullOrEmpty(nameField.text))
{
Bookmark bookmark = Store.Find(planetId);
PlanetData val = Planet(planetId);
SetName((bookmark != null) ? bookmark.Name : ((val != null) ? val.displayName : ""), auto: true);
}
RefreshDynamic();
}
private void ZoomSelected()
{
PlanetData val = ((selectedPlanetId != 0) ? Planet(selectedPlanetId) : null);
if (val == null)
{
Kit.Popup("Choose a planet first");
return;
}
Host.Deselect();
Zoom.Request(val);
}
private void SelectCurrentPlanet()
{
SelectCurrentPlanet(tellIfNone: true);
}
private void SelectCurrentPlanet(bool tellIfNone)
{
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet == null)
{
if (tellIfNone)
{
Kit.Popup("You are not on a planet");
}
}
else
{
Select(localPlanet.id);
}
}
private void UpdateSelectedBox()
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
PlanetData val = ((selectedPlanetId != 0) ? Planet(selectedPlanetId) : null);
if (val == null)
{
selectedLabel.text = "No planet chosen";
selectedInfo.text = "pick one below, a saved planet, or HERE";
((Graphic)selectedBar).color = Kit.TextSub;
return;
}
Bookmark bookmark = Store.Find(val.id);
selectedLabel.text = val.displayName + ((bookmark != null) ? (" (saved as \"" + bookmark.Name + "\")") : "");
selectedInfo.text = ((val.star != null) ? val.star.displayName : "?") + " · " + SafeType(val) + " · " + Distance(val);
((Graphic)selectedBar).color = Kit.Orange;
}
private void SaveSelected()
{
PlanetData val = ((selectedPlanetId != 0) ? Planet(selectedPlanetId) : null);
if (val == null)
{
Kit.Popup("Choose a planet first");
return;
}
string text = Store.Clean(nameField.text);
if (text.Length == 0)
{
text = val.displayName;
}
bool flag = Store.Find(val.id) != null;
Store.Upsert(val.id, text);
Store.Save();
RebuildSaved();
pickerDirty = true;
RebuildPicker();
Kit.Popup((flag ? "Renamed: " : "Saved: ") + text);
SetName("", auto: true);
Host.Deselect();
}
private void SetName(string s, bool auto)
{
if (!((Object)(object)nameField == (Object)null))
{
settingName = true;
nameField.text = s ?? "";
settingName = false;
nameIsAuto = auto;
}
}
private static PlanetData Planet(int id)
{
GalaxyData galaxy = GameMain.galaxy;
if (galaxy == null || id <= 0)
{
return null;
}
return galaxy.PlanetById(id);
}
private static int CurrentGuide()
{
Player mainPlayer = GameMain.mainPlayer;
if (mainPlayer == null || mainPlayer.navigation == null)
{
return 0;
}
return mainPlayer.navigation.indicatorAstroId;
}
private static string SafeType(PlanetData p)
{
try
{
return p.typeString ?? "";
}
catch (Exception)
{
return "";
}
}
private static string Describe(PlanetData p)
{
string text = ((p.star != null) ? p.star.displayName : "?");
return p.displayName + " · " + text + " · " + Distance(p);
}
private static string Distance(PlanetData p)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
Player mainPlayer = GameMain.mainPlayer;
if (mainPlayer == null)
{
return "";
}
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet != null && localPlanet.id == p.id)
{
return "you are here";
}
StarData localStar = GameMain.localStar;
if (localStar != null && p.star != null && localStar.id == p.star.id)
{
VectorLF3 val = p.uPosition - mainPlayer.uPosition;
return (((VectorLF3)(ref val)).magnitude / 40000.0).ToString("0.00") + " AU";
}
if (p.star == null)
{
return "";
}
return StarDistance(p.star);
}
private static string StarDistance(StarData s)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
Player mainPlayer = GameMain.mainPlayer;
if (mainPlayer == null)
{
return "";
}
StarData localStar = GameMain.localStar;
if (localStar != null && localStar.id == s.id)
{
return "this system";
}
VectorLF3 val = s.uPosition - mainPlayer.uPosition;
return (((VectorLF3)(ref val)).magnitude / 2400000.0).ToString("0.0") + " ly";
}
}
internal class FloatingButton : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
public Action OnClick;
public Image Glow;
public Image Icon;
public GameObject Tip;
public RectTransform Target;
private bool dragged;
private bool hover;
private void Update()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Glow == (Object)null))
{
bool panelOpen = Host.PanelOpen;
float num = ((hover || dragged) ? 0.55f : (panelOpen ? 0.35f : 0f));
Color color = (panelOpen ? Kit.Orange : Kit.Blue);
color.a = Mathf.MoveTowards(((Graphic)Glow).color.a, num, Time.unscaledDeltaTime * 3f);
((Graphic)Glow).color = color;
if ((Object)(object)Icon != (Object)null)
{
float num2 = Mathf.MoveTowards(((Transform)((Graphic)Icon).rectTransform).localScale.x, hover ? 1.08f : 1f, Time.unscaledDeltaTime * 1.5f);
((Transform)((Graphic)Icon).rectTransform).localScale = new Vector3(num2, num2, 1f);
}
}
}
public void OnPointerDown(PointerEventData e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.button == 0)
{
dragged = false;
}
}
public void OnBeginDrag(PointerEventData e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.button == 0)
{
dragged = true;
if ((Object)(object)Tip != (Object)null)
{
Tip.SetActive(false);
}
}
}
public void OnDrag(PointerEventData e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.button == 0 && !((Object)(object)Target == (Object)null))
{
RectTransform target = Target;
target.anchoredPosition += e.delta / Host.Scale;
Host.ClampToScreen(Target);
}
}
public void OnEndDrag(PointerEventData e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.button == 0)
{
Host.SaveButtonPosition();
}
}
public void OnPointerClick(PointerEventData e)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)e.button == 0)
{
if (dragged)
{
dragged = false;
}
else
{
OnClick?.Invoke();
}
}
}
public void OnPointerEnter(PointerEventData e)
{
hover = true;
if ((Object)(object)Tip != (Object)null && !dragged)
{
Tip.SetActive(true);
}
}
public void OnPointerExit(PointerEventData e)
{
hover = false;
if ((Object)(object)Tip != (Object)null)
{
Tip.SetActive(false);
}
}
}
internal class DragHandle : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler
{
public RectTransform Target;
public void OnBeginDrag(PointerEventData e)
{
if ((Object)(object)Target != (Object)null)
{
((Transform)Target).SetAsLastSibling();
}
}
public void OnDrag(PointerEventData e)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Target == (Object)null) && (int)e.button == 0)
{
RectTransform target = Target;
target.anchoredPosition += e.delta / Host.Scale;
Host.ClampToScreen(Target);
}
}
}
internal static class Host
{
private static GameObject root;
private static Canvas canvas;
private static CanvasScaler scaler;
private static RectTransform canvasRect;
private static RectTransform button;
private static BookmarkPanel panel;
private static bool failed;
public static float Scale
{
get
{
if (!((Object)(object)canvas != (Object)null) || !(canvas.scaleFactor > 0.01f))
{
return 1f;
}
return canvas.scaleFactor;
}
}
public static bool PanelOpen
{
get
{
if (panel != null)
{
return panel.Visible;
}
return false;
}
}
public static RectTransform ButtonRect => button;
public static void Tick()
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (failed)
{
return;
}
try
{
if (!ShouldShow())
{
if ((Object)(object)root != (Object)null && root.activeSelf)
{
Deselect();
root.SetActive(false);
}
return;
}
if ((Object)(object)root == (Object)null)
{
Build();
}
if (!root.activeSelf)
{
root.SetActive(true);
}
SyncScale();
if (Store.Sync() && panel != null)
{
panel.OnGalaxyChanged();
}
KeyboardShortcut value = PlanetBookmarksPlugin.ToggleKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown() && !VFInput.inputing)
{
TogglePanel();
}
panel.Tick();
Zoom.Tick();
}
catch (Exception ex)
{
failed = true;
PlanetBookmarksPlugin.Log.LogError((object)("PlanetBookmarks UI stopped: " + ex));
}
}
private static bool ShouldShow()
{
if ((Object)(object)GameMain.instance == (Object)null || GameMain.instance.isMenuDemo || !GameMain.isRunning)
{
return false;
}
if (GameMain.mainPlayer == null || GameMain.data == null || GameMain.galaxy == null)
{
return false;
}
UIRoot instance = UIRoot.instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.uiGame == (Object)null || !((ManualBehaviour)instance.uiGame).active)
{
return false;
}
UIGame uiGame = instance.uiGame;
if ((Object)(object)uiGame.techTree != (Object)null && ((ManualBehaviour)uiGame.techTree).active)
{
return false;
}
if ((Object)(object)uiGame.dysonEditor != (Object)null && ((ManualBehaviour)uiGame.dysonEditor).active)
{
return false;
}
if ((Object)(object)uiGame.dashboard != (Object)null && ((ManualBehaviour)uiGame.dashboard).active)
{
return false;
}
if ((Object)(object)uiGame.escMenu != (Object)null && ((ManualBehaviour)uiGame.escMenu).active)
{
return false;
}
return true;
}
private static void Build()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
root = new GameObject("PlanetBookmarks_Canvas");
Object.DontDestroyOnLoad((Object)(object)root);
root.layer = 5;
canvas = root.AddComponent<Canvas>();
canvas.renderMode = (RenderMode)0;
Canvas val = (((Object)(object)UIRoot.instance != (Object)null) ? UIRoot.instance.overlayCanvas : null);
canvas.sortingOrder = (((Object)(object)val != (Object)null) ? (val.sortingOrder + 2) : 100);
scaler = root.AddComponent<CanvasScaler>();
scaler.uiScaleMode = (ScaleMode)0;
root.AddComponent<GraphicRaycaster>();
canvasRect = (RectTransform)root.transform;
SyncScale();
panel = new BookmarkPanel(root.transform);
BuildButton();
}
private static void SyncScale()
{
Canvas val = (((Object)(object)UIRoot.instance != (Object)null) ? UIRoot.instance.overlayCanvas : null);
float num = (((Object)(object)val != (Object)null && val.scaleFactor > 0.01f) ? val.scaleFactor : 1f);
if (Math.Abs(scaler.scaleFactor - num) > 0.0001f)
{
scaler.scaleFactor = num;
}
}
private static Vector2 CanvasSize()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
Vector2 val;
if (!((Object)(object)canvasRect != (Object)null))
{
val = Vector2.zero;
}
else
{
Rect rect = canvasRect.rect;
val = ((Rect)(ref rect)).size;
}
Vector2 val2 = val;
if (val2.x < 10f || val2.y < 10f)
{
((Vector2)(ref val2))..ctor((float)Screen.width / Scale, (float)Screen.height / Scale);
}
return val2;
}
private static void BuildButton()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Clamp(PlanetBookmarksPlugin.ButtonSize.Value, 24f, 128f);
button = Kit.NewRect("PlanetBookmarks_Button", root.transform);
Vector2 val = (button.anchorMin = (button.anchorMax = Vector2.zero));
button.pivot = new Vector2(0.5f, 0.5f);
button.sizeDelta = new Vector2(num, num);
Image val3 = Kit.Plain("glow", (Transform)(object)button, new Color(Kit.Blue.r, Kit.Blue.g, Kit.Blue.b, 0f));
val3.sprite = Kit.GlowSprite;
Kit.Stretch(((Graphic)val3).rectTransform, (0f - num) * 0.35f, (0f - num) * 0.35f, (0f - num) * 0.35f, (0f - num) * 0.35f);
Image val4 = Kit.Plain("icon", (Transform)(object)button, Color.white);
val4.sprite = Kit.IconSprite;
((Graphic)val4).raycastTarget = true;
val4.preserveAspect = true;
Kit.Stretch(((Graphic)val4).rectTransform);
Image val5 = Kit.RoundBox("tip", (Transform)(object)button, new Color(0.03f, 0.06f, 0.095f, 0.95f));
Kit.Frame(((Component)val5).transform, Kit.FrameCol);
RectTransform rectTransform = ((Graphic)val5).rectTransform;
((Vector2)(ref val))..ctor(0.5f, 1f);
rectTransform.anchorMax = val;
rectTransform.anchorMin = val;
rectTransform.pivot = new Vector2(0.5f, 0f);
rectTransform.anchoredPosition = new Vector2(0f, 6f);
rectTransform.sizeDelta = new Vector2(200f, 40f);
Kit.Stretch(((Graphic)Kit.Label("t1", (Transform)(object)rectTransform, "Planet Bookmarks", 14, (TextAnchor)1, Kit.TextMain, gameFont: true)).rectTransform, 4f, 0f, 4f, 4f);
Kit.Stretch(((Graphic)Kit.Label("t2", (Transform)(object)rectTransform, "click: open · drag: move", 12, (TextAnchor)7, Kit.TextSub)).rectTransform, 4f, 4f, 4f);
((Component)val5).gameObject.SetActive(false);
FloatingButton floatingButton = ((Component)val4).gameObject.AddComponent<FloatingButton>();
floatingButton.OnClick = TogglePanel;
floatingButton.Glow = val3;
floatingButton.Icon = val4;
floatingButton.Tip = ((Component)val5).gameObject;
floatingButton.Target = button;
Vector2 val6 = CanvasSize();
float num2 = PlanetBookmarksPlugin.ButtonX.Value;
float num3 = PlanetBookmarksPlugin.ButtonY.Value;
if (num2 < 0f || num3 < 0f)
{
num2 = 42f;
num3 = val6.y * 0.62f;
}
button.anchoredPosition = new Vector2(num2, num3);
ClampToScreen(button);
}
public static void TogglePanel()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (panel != null)
{
if (panel.Visible)
{
ClosePanel();
}
else
{
panel.Open(button.anchoredPosition, button.sizeDelta.x, CanvasSize());
}
}
}
public static void ClosePanel()
{
if (panel != null)
{
Deselect();
panel.Close();
}
}
public static void Deselect()
{
EventSystem current = EventSystem.current;
if (!((Object)(object)current == (Object)null) && !((Object)(object)root == (Object)null))
{
GameObject currentSelectedGameObject = current.currentSelectedGameObject;
if ((Object)(object)currentSelectedGameObject != (Object)null && currentSelectedGameObject.transform.IsChildOf(root.transform))
{
current.SetSelectedGameObject((GameObject)null);
}
}
}
public static void ClampToScreen(RectTransform r)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = CanvasSize();
Vector2 sizeDelta = r.sizeDelta;
Vector2 anchoredPosition = r.anchoredPosition;
float num = r.pivot.x * sizeDelta.x;
float num2 = val.x - (1f - r.pivot.x) * sizeDelta.x;
float num3 = r.pivot.y * sizeDelta.y;
float num4 = val.y - (1f - r.pivot.y) * sizeDelta.y;
anchoredPosition.x = ((num2 >= num) ? Mathf.Clamp(anchoredPosition.x, num, num2) : num);
anchoredPosition.y = ((num4 >= num3) ? Mathf.Clamp(anchoredPosition.y, num3, num4) : num4);
r.anchoredPosition = anchoredPosition;
}
public static void SaveButtonPosition()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)button == (Object)null))
{
PlanetBookmarksPlugin.ButtonX.Value = Mathf.Round(button.anchoredPosition.x);
PlanetBookmarksPlugin.ButtonY.Value = Mathf.Round(button.anchoredPosition.y);
}
}
}
internal static class Kit
{
public static readonly Color PanelBg = new Color(0.03f, 0.06f, 0.095f, 0.95f);
public static readonly Color HeaderBg = new Color(0.09f, 0.15f, 0.22f, 0.97f);
public static readonly Color FrameCol = new Color(0.36f, 0.64f, 0.9f, 0.55f);
public static readonly Color Blue = new Color(0.45f, 0.78f, 1f, 1f);
public static readonly Color Orange = new Color(1f, 0.62f, 0.22f, 1f);
public static readonly Color Red = new Color(1f, 0.38f, 0.32f, 1f);
public static readonly Color TextMain = new Color(0.9f, 0.95f, 1f, 1f);
public static readonly Color TextSub = new Color(0.58f, 0.7f, 0.8f, 1f);
public static readonly Color RowBg = new Color(0.07f, 0.12f, 0.18f, 0.92f);
public static readonly Color FieldBg = new Color(0.02f, 0.04f, 0.07f, 0.95f);
private static Font titleFont;
private static Font bodyFont;
private static Sprite fillSprite;
private static Sprite frameSprite;
private static Sprite iconSprite;
private static Sprite glowSprite;
public static Font TitleFont
{
get
{
if ((Object)(object)titleFont == (Object)null)
{
titleFont = FindGameFont() ?? BodyFont;
}
return titleFont;
}
}
public static Font BodyFont
{
get
{
if ((Object)(object)bodyFont == (Object)null)
{
bodyFont = Font.CreateDynamicFontFromOSFont(new string[3] { "Segoe UI", "Arial", "Tahoma" }, 14);
}
return bodyFont;
}
}
public static Sprite FillSprite
{
get
{
if (!((Object)(object)fillSprite != (Object)null))
{
return fillSprite = Rounded(32, 5f, 0f);
}
return fillSprite;
}
}
public static Sprite FrameSprite
{
get
{
if (!((Object)(object)frameSprite != (Object)null))
{
return frameSprite = Rounded(32, 5f, 1.2f);
}
return frameSprite;
}
}
public static Sprite IconSprite
{
get
{
if (!((Object)(object)iconSprite != (Object)null))
{
return iconSprite = MakeIcon(96);
}
return iconSprite;
}
}
public static Sprite GlowSprite
{
get
{
if (!((Object)(object)glowSprite != (Object)null))
{
return glowSprite = MakeGlow(64);
}
return glowSprite;
}
}
private static Font FindGameFont()
{
try
{
UIRoot instance = UIRoot.instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.uiGame == (Object)null)
{
return null;
}
Text[] componentsInChildren = ((Component)instance.uiGame).GetComponentsInChildren<Text>(true);
foreach (Text val in componentsInChildren)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null && !((Object)val.font).name.StartsWith("Arial", StringComparison.OrdinalIgnoreCase))
{
return val.font;
}
}
}
catch (Exception)
{
}
return null;
}
private static float Clamp01(float v)
{
if (!(v < 0f))
{
if (!(v > 1f))
{
return v;
}
return 1f;
}
return 0f;
}
private static Sprite Rounded(int size, float radius, float border)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
{
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1,
hideFlags = (HideFlags)61
};
Color32[] array = (Color32[])(object)new Color32[size * size];
float num = (float)size * 0.5f;
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num2 = Mathf.Abs((float)j + 0.5f - num) - (num - radius);
float num3 = Mathf.Abs((float)i + 0.5f - num) - (num - radius);
float num4 = Mathf.Max(num2, 0f);
float num5 = Mathf.Max(num3, 0f);
float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5) + Mathf.Min(Mathf.Max(num2, num3), 0f) - radius;
float num7 = Clamp01(0.5f - num6);
if (border > 0f)
{
num7 *= Clamp01(num6 + border + 0.5f);
}
array[i * size + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num7 * 255f));
}
}
val.SetPixels32(array);
val.Apply();
float num8 = radius + 3f;
return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(num8, num8, num8, num8));
}
private static Sprite MakeIcon(int size)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
{
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1,
hideFlags = (HideFlags)61
};
Color[] array = (Color[])(object)new Color[size * size];
float num = (float)size / 64f;
float num2 = (float)size * 0.5f;
float num3 = Mathf.Cos(-0.38f);
float num4 = Mathf.Sin(-0.38f);
Color val2 = default(Color);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num5 = (float)j + 0.5f - num2;
float num6 = (float)i + 0.5f - num2;
float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
float num8 = Clamp01(31f * num - num7 + 0.5f);
val2 = Over(val2, new Color(0.035f, 0.07f, 0.11f, 0.92f * num8));
val2 = Over(src: new Color(0.45f, 0.78f, 1f, Clamp01(1.4f * num - Mathf.Abs(num7 - 29.5f * num) + 0.5f)), dst: val2);
float num9 = num5 + 2f * num;
float num10 = num6 + 2f * num;
float num11 = Mathf.Sqrt(num9 * num9 + num10 * num10);
float num12 = Clamp01(11f * num - num11 + 0.5f);
float num13 = num9 * num3 - num10 * num4;
float num14 = num9 * num4 + num10 * num3;
float num15 = Mathf.Sqrt(num13 * num13 / (441f * num * num) + num14 * num14 / (49f * num * num));
float num16 = Clamp01(1.1f * num - Mathf.Abs(num15 - 1f) * 9f * num + 0.5f);
bool num17 = num14 > 0f;
if (num17)
{
val2 = Over(val2, new Color(1f, 0.62f, 0.22f, num16));
}
if (num12 > 0f)
{
float num18 = Clamp01(0.55f + (0f - num9 + num10) / (22f * num));
Color src = Color.Lerp(new Color(0.18f, 0.38f, 0.62f), new Color(0.62f, 0.86f, 1f), num18);
src.a = num12;
val2 = Over(val2, src);
}
if (!num17)
{
val2 = Over(val2, new Color(1f, 0.62f, 0.22f, num16));
}
float num19 = num5 - 14f * num;
float num20 = num6 - 17f * num;
float num21 = Clamp01(4.2f * num - Mathf.Sqrt(num19 * num19 + num20 * num20) + 0.5f);
float num22 = 0f;
if (num20 < 0f && num20 > -8f * num)
{
num22 = Clamp01((num20 + 8f * num) * 0.55f - Mathf.Abs(num19) + 0.5f);
}
float num23 = Mathf.Max(num21, num22);
val2 = Over(val2, new Color(1f, 0.62f, 0.22f, num23));
float num24 = Clamp01(1.6f * num - Mathf.Sqrt(num19 * num19 + num20 * num20) + 0.5f);
val2 = Over(val2, new Color(0.035f, 0.07f, 0.11f, num24));
val2.a *= ((num8 > 0f) ? 1f : 0f);
array[i * size + j] = val2;
}
}
val.SetPixels(array);
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f);
}
private static Sprite MakeGlow(int size)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
{
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1,
hideFlags = (HideFlags)61
};
Color[] array = (Color[])(object)new Color[size * size];
float num = (float)size * 0.5f;
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num2 = ((float)j + 0.5f - num) / num;
float num3 = ((float)i + 0.5f - num) / num;
float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
float num5 = Clamp01(1f - num4);
array[i * size + j] = new Color(1f, 1f, 1f, num5 * num5);
}
}
val.SetPixels(array);
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f);
}
private static Color Over(Color dst, Color src)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
float num = src.a + dst.a * (1f - src.a);
if (num <= 0f)
{
return new Color(0f, 0f, 0f, 0f);
}
float num2 = dst.a * (1f - src.a);
return new Color((src.r * src.a + dst.r * num2) / num, (src.g * src.a + dst.g * num2) / num, (src.b * src.a + dst.b * num2) / num, num);
}
public static RectTransform NewRect(string name, Transform parent)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) })
{
layer = (((Object)(object)parent != (Object)null) ? ((Component)parent).gameObject.layer : 5)
}.GetComponent<RectTransform>();
((Transform)component).SetParent(parent, false);
return component;
}
public static void Place(RectTransform r, Vector2 corner, Vector2 pos, Vector2 size)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
r.anchorMin = corner;
r.anchorMax = corner;
r.pivot = corner;
r.anchoredPosition = pos;
r.sizeDelta = size;
}
public static void Stretch(RectTransform r, float l = 0f, float b = 0f, float rt = 0f, float t = 0f)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
r.anchorMin = Vector2.zero;
r.anchorMax = Vector2.one;
r.pivot = new Vector2(0.5f, 0.5f);
r.offsetMin = new Vector2(l, b);
r.offsetMax = new Vector2(0f - rt, 0f - t);
}
public static Image Plain(string name, Transform parent, Color c)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Image obj = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>();
((Graphic)obj).color = c;
((Graphic)obj).raycastTarget = false;
return obj;
}
public static Image RoundBox(string name, Transform parent, Color c)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
Image obj = Plain(name, parent, c);
obj.sprite = FillSprite;
obj.type = (Type)1;
return obj;
}
public static Image Frame(Transform parent, Color c)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Image obj = Plain("frame", parent, c);
obj.sprite = FrameSprite;
obj.type = (Type)1;
Stretch(((Graphic)obj).rectTransform);
return obj;
}
public static Text Label(string name, Transform parent, string text, int size, TextAnchor align, Color color, bool gameFont = false)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Text obj = ((Component)NewRect(name, parent)).gameObject.AddComponent<Text>();
obj.font = (gameFont ? TitleFont : BodyFont);
obj.fontSize = size;
obj.alignment = align;
((Graphic)obj).color = color;
obj.text = text;
((Graphic)obj).raycastTarget = false;
obj.supportRichText = false;
obj.horizontalOverflow = (HorizontalWrapMode)1;
obj.verticalOverflow = (VerticalWrapMode)1;
return obj;
}
public static Button Btn(string name, Transform parent, string text, int size, Color accent, out Text label)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
Image val = RoundBox(name, parent, Color.white);
((Graphic)val).raycastTarget = true;
Button obj = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj).targetGraphic = (Graphic)(object)val;
ColorBlock colors = ((Selectable)obj).colors;
((ColorBlock)(ref colors)).normalColor = new Color(accent.r * 0.22f, accent.g * 0.22f, accent.b * 0.22f, 0.95f);
((ColorBlock)(ref colors)).highlightedColor = new Color(accent.r * 0.42f, accent.g * 0.42f, accent.b * 0.42f, 1f);
((ColorBlock)(ref colors)).pressedColor = new Color(accent.r * 0.65f, accent.g * 0.65f, accent.b * 0.65f, 1f);
((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
((ColorBlock)(ref colors)).disabledColor = new Color(0.12f, 0.12f, 0.12f, 0.6f);
((ColorBlock)(ref colors)).colorMultiplier = 1f;
((ColorBlock)(ref colors)).fadeDuration = 0.08f;
((Selectable)obj).colors = colors;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj).navigation = navigation;
Frame(((Component)val).transform, new Color(accent.r, accent.g, accent.b, 0.75f));
label = Label("text", ((Component)val).transform, text, size, (TextAnchor)4, TextMain, gameFont: true);
Stretch(((Graphic)label).rectTransform);
return obj;
}
public static Button Btn(string name, Transform parent, string text, int size, Color accent)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
Text label;
return Btn(name, parent, text, size, accent, out label);
}
public static InputField Field(string name, Transform parent, string placeholder, int limit)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
Image val = RoundBox(name, parent, FieldBg);
((Graphic)val).raycastTarget = true;
Frame(((Component)val).transform, new Color(FrameCol.r, FrameCol.g, FrameCol.b, 0.45f));
Text val2 = Label("placeholder", ((Component)val).transform, placeholder, 14, (TextAnchor)3, new Color(0.5f, 0.6f, 0.7f, 0.6f));
val2.fontStyle = (FontStyle)2;
Stretch(((Graphic)val2).rectTransform, 9f, 2f, 9f, 2f);
Text val3 = Label("text", ((Component)val).transform, "", 14, (TextAnchor)3, TextMain);
val3.horizontalOverflow = (HorizontalWrapMode)1;
Stretch(((Graphic)val3).rectTransform, 9f, 2f, 9f, 2f);
InputField obj = ((Component)val).gameObject.AddComponent<InputField>();
((Selectable)obj).targetGraphic = (Graphic)(object)val;
obj.textComponent = val3;
obj.placeholder = (Graphic)(object)val2;
obj.characterLimit = limit;
obj.lineType = (LineType)0;
obj.caretColor = Blue;
obj.customCaretColor = true;
obj.selectionColor = new Color(0.45f, 0.78f, 1f, 0.35f);
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj).navigation = navigation;
ColorBlock colors = ((Selectable)obj).colors;
((ColorBlock)(ref colors)).normalColor = Color.white;
((ColorBlock)(ref colors)).highlightedColor = new Color(1.25f, 1.25f, 1.25f, 1f);
((ColorBlock)(ref colors)).selectedColor = Color.white;
((ColorBlock)(ref colors)).pressedColor = Color.white;
((Selectable)obj).colors = colors;
return obj;
}
public static RectTransform ScrollList(string name, Transform parent, float spacing)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
Image val = RoundBox(name, parent, new Color(0f, 0f, 0f, 0.25f));
((Graphic)val).raycastTarget = true;
((Component)val).gameObject.AddComponent<RectMask2D>();
RectTransform val2 = NewRect("content", ((Component)val).transform);
val2.anchorMin = new Vector2(0f, 1f);
val2.anchorMax = new Vector2(1f, 1f);
val2.pivot = new Vector2(0.5f, 1f);
val2.sizeDelta = new Vector2(-18f, 0f);
val2.anchoredPosition = new Vector2(-5f, 0f);
VerticalLayoutGroup obj = ((Component)val2).gameObject.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)obj).spacing = spacing;
((LayoutGroup)obj).childAlignment = (TextAnchor)0;
((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
((LayoutGroup)obj).padding = new RectOffset(0, 0, 4, 6);
((Component)val2).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
Image val3 = Plain("bar", ((Component)val).transform, new Color(1f, 1f, 1f, 0.05f));
((Graphic)val3).raycastTarget = true;
RectTransform rectTransform = ((Graphic)val3).rectTransform;
rectTransform.anchorMin = new Vector2(1f, 0f);
rectTransform.anchorMax = new Vector2(1f, 1f);
rectTransform.pivot = new Vector2(1f, 0.5f);
rectTransform.sizeDelta = new Vector2(6f, -8f);
rectTransform.anchoredPosition = new Vector2(-3f, 0f);
Image val4 = RoundBox("handle", ((Component)val3).transform, new Color(0.45f, 0.78f, 1f, 0.55f));
((Graphic)val4).raycastTarget = true;
Stretch(((Graphic)val4).rectTransform);
Scrollbar val5 = ((Component)val3).gameObject.AddComponent<Scrollbar>();
val5.direction = (Direction)2;
val5.handleRect = ((Graphic)val4).rectTransform;
((Selectable)val5).targetGraphic = (Graphic)(object)val4;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)val5).navigation = navigation;
ScrollRect obj2 = ((Component)val).gameObject.AddComponent<ScrollRect>();
obj2.content = val2;
obj2.viewport = ((Graphic)val).rectTransform;
obj2.horizontal = false;
obj2.vertical = true;
obj2.movementType = (MovementType)2;
obj2.scrollSensitivity = 28f;
obj2.verticalScrollbar = val5;
obj2.verticalScrollbarVisibility = (ScrollbarVisibility)1;
return val2;
}
public static void Height(Component c, float h)
{
LayoutElement val = c.gameObject.GetComponent<LayoutElement>();
if ((Object)(object)val == (Object)null)
{
val = c.gameObject.AddComponent<LayoutElement>();
}
val.preferredHeight = h;
val.minHeight = h;
}
public static void Clear(Transform t)
{
for (int num = t.childCount - 1; num >= 0; num--)
{
GameObject gameObject = ((Component)t.GetChild(num)).gameObject;
gameObject.SetActive(false);
gameObject.transform.SetParent((Transform)null, false);
Object.Destroy((Object)(object)gameObject);
}
}
public static void Popup(string text)
{
try
{
UIRealtimeTip.Popup(text, false, 0);
}
catch (Exception)
{
}
}
}
[BepInPlugin("pinkpz.dsp.planetbookmarks", "PlanetBookmarks", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class PlanetBookmarksPlugin : BaseUnityPlugin
{
public const string GUID = "pinkpz.dsp.planetbookmarks";
public const string NAME = "PlanetBookmarks";
public const string VERSION = "1.0.0";
internal static ManualLogSource Log;
internal static ConfigEntry<float> ButtonX;
internal static ConfigEntry<float> ButtonY;
internal static ConfigEntry<float> ButtonSize;
internal static ConfigEntry<KeyboardShortcut> ToggleKey;
internal static ConfigEntry<int> MaxPickerRows;
private void Awake()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
ButtonX = ((BaseUnityPlugin)this).Config.Bind<float>("Button", "PositionX", -1f, "Floating button position (UI units from the left edge). -1 = default. Updated when you drag the button.");
ButtonY = ((BaseUnityPlugin)this).Config.Bind<float>("Button", "PositionY", -1f, "Floating button position (UI units from the bottom edge). -1 = default. Updated when you drag the button.");
ButtonSize = ((BaseUnityPlugin)this).Config.Bind<float>("Button", "Size", 46f, "Floating button size.");
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Button", "ToggleKey", KeyboardShortcut.Empty, "Optional keyboard shortcut that opens / closes the panel (empty = none).");
MaxPickerRows = ((BaseUnityPlugin)this).Config.Bind<int>("Panel", "MaxPickerRows", 150, "How many planets the picker list shows at once (nearest first). Type in the search box to find others.");
Log.LogInfo((object)"PlanetBookmarks 1.0.0 loaded");
}
private void Update()
{
Host.Tick();
}
}
internal class Bookmark
{
public int PlanetId;
public string Name;
}
internal static class Store
{
public static readonly List<Bookmark> Items = new List<Bookmark>();
private static string loadedKey;
public static string Folder => Path.Combine(Paths.ConfigPath, "PlanetBookmarks");
private static string FilePath => Path.Combine(Folder, "galaxy_" + loadedKey + ".txt");
public static string CurrentKey()
{
GameData data = GameMain.data;
if (data == null || data.gameDesc == null)
{
return null;
}
return data.gameDesc.galaxySeed + "_" + data.gameDesc.starCount;
}
public static bool Sync()
{
string text = CurrentKey();
if (text == null || text == loadedKey)
{
return false;
}
loadedKey = text;
Load();
return true;
}
private static void Load()
{
Items.Clear();
try
{
if (!File.Exists(FilePath))
{
return;
}
string[] array = File.ReadAllLines(FilePath, Encoding.UTF8);
foreach (string text in array)
{
int num = text.IndexOf('\t');
if (num > 0 && int.TryParse(text.Substring(0, num), out var result) && result > 0)
{
string text2 = text.Substring(num + 1).Trim();
if (text2.Length != 0 && Find(result) == null)
{
Items.Add(new Bookmark
{
PlanetId = result,
Name = text2
});
}
}
}
}
catch (Exception ex)
{
PlanetBookmarksPlugin.Log.LogError((object)("Could not read bookmarks: " + ex));
}
}
public static void Save()
{
if (loadedKey == null)
{
return;
}
try
{
Directory.CreateDirectory(Folder);
StringBuilder stringBuilder = new StringBuilder();
foreach (Bookmark item in Items)
{
stringBuilder.Append(item.PlanetId).Append('\t').Append(item.Name)
.Append('\n');
}
File.WriteAllText(FilePath, stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
}
catch (Exception ex)
{
PlanetBookmarksPlugin.Log.LogError((object)("Could not save bookmarks: " + ex));
}
}
public static Bookmark Find(int planetId)
{
foreach (Bookmark item in Items)
{
if (item.PlanetId == planetId)
{
return item;
}
}
return null;
}
public static void Upsert(int planetId, string name)
{
name = Clean(name);
Bookmark bookmark = Find(planetId);
if (bookmark != null)
{
bookmark.Name = name;
return;
}
Items.Add(new Bookmark
{
PlanetId = planetId,
Name = name
});
}
public static void Remove(int planetId)
{
Items.RemoveAll((Bookmark b) => b.PlanetId == planetId);
}
public static string Clean(string s)
{
if (s == null)
{
return "";
}
s = s.Replace('\t', ' ').Replace('\r', ' ').Replace('\n', ' ')
.Trim();
if (s.Length <= 40)
{
return s;
}
return s.Substring(0, 40);
}
}
internal static class Zoom
{
private static int pendingId;
private static int waitFrames;
private static int giveUpFrames;
public static void Request(PlanetData p)
{
UIGame val = Game();
if (p != null && !((Object)(object)val == (Object)null) && !((Object)(object)val.starmap == (Object)null))
{
pendingId = p.id;
giveUpFrames = 60;
if (!((ManualBehaviour)val.starmap).active)
{
val.OpenStarmap();
waitFrames = 2;
}
else
{
waitFrames = 0;
}
Tick();
}
}
public static void Tick()
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
if (pendingId == 0)
{
return;
}
UIGame val = Game();
if ((Object)(object)val == (Object)null || (Object)(object)val.starmap == (Object)null || !((ManualBehaviour)val.starmap).active || (Object)(object)val.starmap.screenCameraController == (Object)null)
{
if (--giveUpFrames <= 0)
{
pendingId = 0;
}
return;
}
if (waitFrames > 0)
{
waitFrames--;
return;
}
GalaxyData galaxy = GameMain.galaxy;
PlanetData val2 = ((galaxy != null) ? galaxy.PlanetById(pendingId) : null);
pendingId = 0;
if (val2 != null)
{
UIStarmap starmap = val.starmap;
if (val2.star != null)
{
starmap.SetViewStar(val2.star, false);
}
double num = (double)val2.realRadius * 0.00025;
starmap.screenCameraController.SetViewTarget(val2, (StarData)null, (EnemyDFHiveSystem)null, (Player)null, VectorLF3.zero, num * 3.0, num * 6.0, true, false);
}
}
private static UIGame Game()
{
UIRoot instance = UIRoot.instance;
if (!((Object)(object)instance != (Object)null))
{
return null;
}
return instance.uiGame;
}
}
}