public override void Start() { headerpanel = (UIPanel)this.AddUIComponent(typeof(UIPanel)); headerpanel.height = 20; headerpanel.backgroundSprite = "GenericPanel"; headerpanel.color = new Color32(0, 0, 100, 200); headertext = headerpanel.AddUIComponent <UILabel>(); headertext.text = "CSL Stats Panel - Configuration, v" + System.Reflection.Assembly.GetAssembly(typeof(CSLStatsPanelMod)).GetName().Version;; headertext.CenterToParent(); myConfigWindowPanel = (ConfigSettingsWindow)this.AddUIComponent(typeof(ConfigSettingsWindow)); myConfigWindowPanel.width = this.width; myConfigWindowPanel.name = "CSLStatsConfigurationPanel"; myConfigWindowPanel.color = new Color32(0, 0, 0, 255); //myConfigWindowPanel.eventStatsConfigChanged += new ConfigSettingsWindow.eventStatsConfigChangedHandler(myConfigWindowPanel_eventStatsConfigChanged); //myConfigWindowPanel.eventModeConfigChanged += new ConfigSettingsWindow.eventConfigModeChangedHandler(myConfigWindowPanel_eventModeConfigChanged); //myConfigWindowPanel.eventConfigReset += new ConfigSettingsWindow.eventConfigResetHandler(myConfigWindowPanel_eventConfigReset); //myConfigWindowPanel.eventConfigTransparencyChanged += new ConfigSettingsWindow.eventConfigTransparencyChangeHandler(myConfigWindowPanel_eventConfigTransparencyChanged); myresizepanel = (UIResizeHandle)this.AddUIComponent(typeof(UIResizeHandle)); myresizepanel.name = "CSLStatsConfigurationResizePanel"; myresizepanel.height = 20; myresizepanel.color = new Color32(0, 0, 100, 200); myresizepanel.backgroundSprite = "GenericPanel"; //myresizepanel.anchor = UIAnchorStyle.Bottom; //myresizepanel.anchor = UIAnchorStyle.Right; //resizelabel = myresizepanel.AddUIComponent<UILabel>(); var CloseButton = (UIButton)myresizepanel.AddUIComponent(typeof(UIButton)); CloseButton.width = 125; CloseButton.height = 20; CloseButton.normalBgSprite = "ButtonMenu"; CloseButton.hoveredBgSprite = "ButtonMenuHovered"; CloseButton.focusedBgSprite = "ButtonMenuFocused"; CloseButton.pressedBgSprite = "ButtonMenuPressed"; CloseButton.textColor = new Color32(186, 217, 238, 0); CloseButton.disabledTextColor = new Color32(7, 7, 7, 255); CloseButton.hoveredTextColor = new Color32(7, 132, 255, 255); CloseButton.focusedTextColor = new Color32(255, 255, 255, 255); CloseButton.pressedTextColor = new Color32(30, 30, 44, 255); CloseButton.color = new Color32(CloseButton.color.r, CloseButton.color.g, CloseButton.color.b, 255); //CloseButton.transformPosition = new Vector3(1.2f, -0.93f); CloseButton.BringToFront(); CloseButton.text = "Close"; CloseButton.eventClick += new MouseEventHandler(CloseButton_eventClick); myresizepanel.FitChildrenVertically(); this.CenterToParent(); base.Start(); OnSizeChanged(); this.Update(); this.BringToFront(); }
public void init() { this.color = CSLStatsPanelConfigSettings.DefaultPanelColor; if (!CSLStatsPanelConfigSettings.m_EnableTransparency.value) { this.backgroundSprite = "GenericPanel"; } this.autoLayoutDirection = LayoutDirection.Vertical; this.autoLayoutStart = LayoutStart.TopLeft; this.autoLayoutPadding = new RectOffset(0, 0, 0, 0); this.autoLayout = true; headerpanel = (UIPanel)this.AddUIComponent(typeof(UIPanel)); headerpanel.height = 20; if (!CSLStatsPanelConfigSettings.m_EnableTransparency.value) { headerpanel.backgroundSprite = "GenericPanel"; } headerpanel.color = new Color32(0, 0, 100, 200); headertext = headerpanel.AddUIComponent <UILabel>(); headertext.text = "CSL Stats Panel"; if (CSLStatsPanelConfigSettings.m_EnableTransparency.value) { headertext.Hide(); } addStatsWindowPanel(); myresizepanel = (UIResizeHandle)this.AddUIComponent(typeof(UIResizeHandle)); myresizepanel.name = "CSLStatsResizePanel"; myresizepanel.height = 20; myresizepanel.color = new Color32(0, 0, 100, 200); if (!CSLStatsPanelConfigSettings.m_EnableTransparency.value) { myresizepanel.backgroundSprite = "GenericPanel"; } //myresizepanel.anchor = UIAnchorStyle.Bottom; //myresizepanel.anchor = UIAnchorStyle.Right; resizelabel = myresizepanel.AddUIComponent <UILabel>(); addConfigureButton(); setdefaultpos(); }
public override void Start() { // Generates the following UI: // /NAME-----------\ <-- UIDragHandle // |---------------|-| // | | |<-- _messageBox, _getscrollablepanel // | | | // |---------------| | // | | |<-- _chatText // |---------------|-| // |-|<-- _resize // ^ // ¦-- _scrollbar, _trackingsprite, _trackingthumb backgroundSprite = "GenericPanel"; name = "ChatLogPanel"; color = new Color32(22, 22, 22, 240); // Activates the dragging of the window _draghandle = AddUIComponent <UIDragHandle>(); _draghandle.name = "ChatLogPanelDragHandle"; // Grab the view for calculating width and height of game UIView view = UIView.GetAView(); // Center this window in the game relativePosition = new Vector3(10.0f, view.fixedHeight - 440.0f); width = 500; height = 310; minimumSize = new Vector2(300, 310); // Add resize component _resize = AddUIComponent <UIResizeHandle>(); _resize.position = new Vector2((width - 20), (-height + 10)); _resize.width = 20f; _resize.height = 20f; _resize.color = new Color32(255, 255, 255, 255); _resize.backgroundSprite = "GenericTabPressed"; _resize.name = "ChatLogPanelResize"; // Add scrollable panel component _scrollablepanel = AddUIComponent <UIScrollablePanel>(); _scrollablepanel.width = 490; _scrollablepanel.height = 240; _scrollablepanel.position = new Vector2(10, -30); _scrollablepanel.clipChildren = true; _scrollablepanel.name = "ChatLogPanelScrollablePanel"; // Add title _title = AddUIComponent <UILabel>(); _title.position = new Vector2(10, -5); _title.text = "Multiplayer Chat"; _title.textScale = 0.8f; _title.autoSize = true; _title.name = "ChatLogPanelTitle"; // Add messagebox component _messageBox = _scrollablepanel.AddUIComponent <UILabel>(); _messageBox.isVisible = true; _messageBox.isEnabled = true; _messageBox.autoSize = false; _messageBox.autoHeight = true; _messageBox.width = 470; _messageBox.height = 240; _messageBox.position = new Vector2(10, -30); _messageBox.textScale = 0.8f; _messageBox.wordWrap = true; _messageBox.name = "ChatLogPanelMessageBox"; // Add scrollbar component _scrollbar = AddUIComponent <UIScrollbar>(); _scrollbar.name = "Scrollbar"; _scrollbar.width = 20f; _scrollbar.height = _scrollablepanel.height; _scrollbar.orientation = UIOrientation.Vertical; _scrollbar.pivot = UIPivotPoint.TopLeft; _scrollbar.position = new Vector2(480, -30); _scrollbar.minValue = 0; _scrollbar.value = 0; _scrollbar.incrementAmount = 50; _scrollbar.name = "ChatLogPanelScrollBar"; // Add scrollbar background sprite component _trackingsprite = _scrollbar.AddUIComponent <UISlicedSprite>(); _trackingsprite.position = new Vector2(0, 0); _trackingsprite.autoSize = true; _trackingsprite.size = _trackingsprite.parent.size; _trackingsprite.fillDirection = UIFillDirection.Vertical; _trackingsprite.spriteName = "ScrollbarTrack"; _trackingsprite.name = "ChatLogPanelTrack"; _scrollbar.trackObject = _trackingsprite; _scrollbar.trackObject.height = _scrollbar.height; // Add scrollbar thumb component _trackingthumb = _scrollbar.AddUIComponent <UISlicedSprite>(); _trackingthumb.position = new Vector2(0, 0); _trackingthumb.fillDirection = UIFillDirection.Vertical; _trackingthumb.autoSize = true; _trackingthumb.width = _trackingthumb.parent.width - 8; _trackingthumb.spriteName = "ScrollbarThumb"; _trackingthumb.name = "ChatLogPanelThumb"; _scrollbar.thumbObject = _trackingthumb; _scrollbar.isVisible = true; _scrollbar.isEnabled = true; _scrollablepanel.verticalScrollbar = _scrollbar; // Add text field component (used for inputting) _chatText = (UITextField)AddUIComponent(typeof(UITextField)); _chatText.width = width; _chatText.height = 30; _chatText.position = new Vector2(0, -280); _chatText.atlas = UiHelpers.GetAtlas("Ingame"); _chatText.normalBgSprite = "TextFieldPanelHovered"; _chatText.builtinKeyNavigation = true; _chatText.isInteractive = true; _chatText.readOnly = false; _chatText.horizontalAlignment = UIHorizontalAlignment.Left; _chatText.eventKeyDown += OnChatKeyDown; _chatText.textColor = new Color32(0, 0, 0, 255); _chatText.padding = new RectOffset(6, 6, 6, 6); _chatText.selectionSprite = "EmptySprite"; _chatText.name = "ChatLogPanelChatText"; WelcomeChatMessage(); // Add resizable adjustments eventSizeChanged += (component, param) => { _scrollablepanel.width = (width - 30); _scrollablepanel.height = (height - 70); _messageBox.width = (width - 30); _chatText.width = width; _scrollbar.height = _scrollablepanel.height; _trackingsprite.size = _trackingsprite.parent.size; _chatText.position = new Vector3(0, (-height + 30)); _resize.position = new Vector2((width - 20), (-height + 10)); _scrollbar.position = new Vector2((width - 20), (-30)); }; base.Start(); }
private void OnEnable() { if (m_Initialized) { return; } #if DEBUG m_MainPanel = UIView.Find <UIPanel>(m_MainPanelName); if (m_MainPanel) { UnityEngine.Object.Destroy(m_MainPanel.gameObject); UnityEngine.Object.Destroy(m_MainPanel); m_MainPanel = null; Utils.Log("Cleared " + m_MainPanelName + " from previous sessions."); } #endif var objectOfType = UnityEngine.Object.FindObjectOfType <UIView>(); transform.parent = objectOfType.transform; m_MainPanel = fw.ui.UIHelper.MakeMainPanel(gameObject). SetAbsolutePosition(new Vector3(400, 20)). SetSize(new Vector2(500, 700)). SetName(m_MainPanelName). SetMinimumSize(new Vector2(500, 150)). GetPanel(); var panelIcon = fw.ui.UIHelper.AddSprite(m_MainPanel). SetSize(fw.ui.UIHelper.DefaultPanelIconSize). SetSpriteName(fw.CommonSprites.IconOutsideConnections.normal). MoveInnerTopLeftOf(m_MainPanel, new Vector3(8, 2)). SetAnchor(UIAnchorStyle.Top | UIAnchorStyle.Left). GetSprite(); var panelClose = fw.ui.UIHelper.AddButton(m_MainPanel). SetName("Close"). SetBackgroundSprites(fw.PreparedSpriteSets.IconClose). MoveInnerTopRightOf(m_MainPanel, new Vector3(5, 2)). SetAnchor(UIAnchorStyle.Top | UIAnchorStyle.Right). GetButton(); panelClose.eventClick += delegate { OnClose(); }; var panelHeadline = fw.ui.UIHelper.AddLabel(m_MainPanel, true). SetAutoSize(false). SetAutoHeight(true). SetTextScale(1f). SetRelativePosition(new Vector3(0, 10)). ClampHorizontallyBetween(panelIcon, panelClose, 5, 5). SetAnchor(UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right). SetName("PanelLabel"). SetText("Advanced Outside Connections Overview"). SetTextAlignment(UIHorizontalAlignment.Center). SwapZOrder(panelClose). GetLabel(); var dragHandle = fw.ui.UIHelper.AddDragHandle(m_MainPanel). SetRelativePosition(Vector3.zero). SetSize(new Vector2(m_MainPanel.width, fw.ui.UIHelper.DefaultDragHandleSize)). SetAnchor(UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right). SetTarget(m_MainPanel). SwapZOrder(panelClose). GetDragHandle(); InitTitlePanel(); m_BottomResizeHandle = fw.ui.UIHelper.AddResizeHandle(m_MainPanel, UIResizeHandle.ResizeEdge.Bottom).GetResizeHandle(); m_OutsideConnectionCountLabel = fw.ui.UIHelper.AddLabel(m_MainPanel, true). SetName("OutsideConnectionCount"). SetPrefix("Outside Connections-Count: "). SetAutoSize(true). MoveInnerBottomLeftOf(m_MainPanel, new Vector3(10, 7)). SwapZOrder(m_BottomResizeHandle). SetAnchor(UIAnchorStyle.Left | UIAnchorStyle.Bottom). GetLabel(); const int ScrollablePanelY = 85; m_Scrollbar = fw.ui.UIHelper.AddScrollbarWithTrack(m_MainPanel, UIOrientation.Vertical). SetHeight(m_MainPanel.height - ScrollablePanelY - m_BottomResizeHandle.height). MoveInnerRightOf(m_MainPanel). SetRelativeY(ScrollablePanelY). SetAnchor(UIAnchorStyle.Right | UIAnchorStyle.Top | UIAnchorStyle.Bottom). GetScrollbar(); m_ScrollablePanel = fw.ui.UIHelper.AddScrollablePanel(m_MainPanel, UIOrientation.Vertical). SetWidth(m_Scrollbar.absolutePosition.x - m_MainPanel.absolutePosition.x - 1). SetHeight(m_Scrollbar.height). MoveLeftOf(m_Scrollbar). SetRelativeY(ScrollablePanelY). SetAnchor(UIAnchorStyle.All). SetVerticalScrollbar(m_Scrollbar). //SetBackgroundSprite(fw.CommonSprites.EmptySprite). GetScrollabelPanel(); var detailPanelGO = new GameObject("AOCDetailMainPanelGO", new Type[] { typeof(OutsideConnectionDetailPanel) }); m_OutsideConnectionDetailPanel = detailPanelGO.GetComponent <OutsideConnectionDetailPanel>(); m_OutsideConnectionDetailPanel.eventNameChanged += OnConnectionNameChanged; m_OutsideConnectionDetailPanel.eventDirectionChanged += delegate(ushort buildingID, Building.Flags flag) { OnConnectionInfoChanged(buildingID); }; SetupEventsWithOutsideConnectionInfoViewPanel(true); m_MainPanel.Hide(); m_MainPanel.eventPositionChanged += OnPositionChanged; m_Initialized = true; }
public void Initialize() { // first, set up our panel stuff UIView uiv = UIView.GetAView(); if (uiv == null) { // log error return; } this.name = "BetterLoadPanelWrapper"; this.cachedName = "BetterLoadPanelWrapper"; this.stringUserData = "BetterLoadPanelWrapper"; this.backgroundSprite = "MenuPanel";// or MenuPanel2 int viewWidth = (int)uiv.GetScreenResolution().x; int viewHeight = (int)uiv.GetScreenResolution().y; this.clipChildren = false; this.canFocus = true; this.isInteractive = true; //this.autoLayout = true; //this.autoLayoutDirection = LayoutDirection.Vertical; //this.autoLayoutPadding = new RectOffset(0, 0, 1, 1); //this.autoLayoutStart = LayoutStart.TopLeft; if (CurrentRelativePosition == Vector3.zero) { this.useCenter = true; this.CenterToParent(); this.useCenter = false; CurrentRelativePosition = this.relativePosition; } else { this.relativePosition = CurrentRelativePosition; } this.minimumSize = new Vector2(1170, 450); this.width = viewWidth * 0.5f; this.height = viewHeight * 0.5f; //this.SendToBack(); float inset = 5; TitleSubPanel = AddUIComponent <UITitleSubPanel>(); TitleSubPanel.ParentBetterLoadPanelWrapper = this; TitleSubPanel.relativePosition = Vector3.zero; TitleSubPanel.width = this.width; TitleSubPanel.height = 40; ListPanel = AddUIComponent <UISortedSavedGamesPanel>(); ListPanel.ParentBetterLoadPanelWrapper = this; ListPanel.relativePosition = new Vector3(inset, TitleSubPanel.relativePosition.y + TitleSubPanel.height + inset); ListPanel.width = (this.width / 1.75f) - 2f * inset; // was width/2 ListPanel.height = this.height - ListPanel.relativePosition.y - inset; float detailinset = 30; DetailsPanel = AddUIComponent <UILoadPanelDetails>(); DetailsPanel.ParentBetterLoadPanelWrapper = this; DetailsPanel.relativePosition = new Vector3(ListPanel.relativePosition.x + ListPanel.width + detailinset, ListPanel.relativePosition.y + inset, 0); DetailsPanel.width = this.width - ListPanel.width - 2 * detailinset; DetailsPanel.height = ListPanel.height - 2 * detailinset; ResizeHandle = AddUIComponent <UIResizeHandle>(); ResizeHandle.AlignTo(this, UIAlignAnchor.BottomRight); ResizeHandle.isInteractive = true; ResizeHandle.edges = UIResizeHandle.ResizeEdge.Right | UIResizeHandle.ResizeEdge.Bottom; ResizeHandle.size = new Vector2(16, 16); ResizeHandle.backgroundSprite = "buttonresize"; ResizeHandle.relativePosition = new Vector3(ResizeHandle.relativePosition.x - 16, ResizeHandle.relativePosition.y - 16, 0); }
public override void Start() { UIView uiv = UIView.GetAView(); int viewWidth = (int)uiv.GetScreenResolution().x; int viewHeight = (int)uiv.GetScreenResolution().y; if (uiv == null) { Cleanup(); return; } this.autoSize = true; this.anchor = UIAnchorStyle.Top | UIAnchorStyle.CenterHorizontal; this.backgroundSprite = "GenericPanel"; this.color = new Color32(0, 0, 0, 0xff); this.height = 25.0f; this.relativePosition = new Vector3(0f, 0f, 0f); //this.opacity = 0.0f; this.width = (viewWidth / 2); this.maximumSize = new Vector2(viewWidth, 25f); this.minimumSize = new Vector2(27f, 25f); UISprite leftCover = this.AddUIComponent <UISprite>(); leftCover.spriteName = "GenericPanel"; leftCover.color = new Color32(0, 0, 0, 0xff); //leftCover.AlignTo(this, UIAlignAnchor.BottomRight); leftCover.relativePosition = new Vector3(0f, 0f); leftCover.size = new Vector2(26f, 26f); //leftCover.BringToFront(); leftCover.SendToBack(); UISprite rightCover = this.AddUIComponent <UISprite>(); rightCover.spriteName = "GenericPanel"; rightCover.color = new Color32(0, 0, 0, 0xff); rightCover.AlignTo(this, UIAlignAnchor.BottomRight); rightCover.size = new Vector2(26f, 26f); rightCover.relativePosition = new Vector3(rightCover.relativePosition.x - 26, rightCover.relativePosition.y - 26, 0); //rightCover.BringToFront(); rightCover.SendToBack(); UISprite chirpSprite = this.AddUIComponent <UISprite>(); chirpSprite.spriteName = "ChirperIcon"; chirpSprite.relativePosition = new Vector3(-1f, -1f); chirpSprite.size = new Vector2(27f, 27f); chirpSprite.BringToFront(); this.autoLayout = false; this.clipChildren = true; this.SendToBack(); UIDragHandle dh = (UIDragHandle)this.AddUIComponent(typeof(UIDragHandle)); dh.size = new Vector2(25f, 25f); dh.relativePosition = new Vector3(0f, 0f); UIResizeHandle rh = (UIResizeHandle)this.AddUIComponent(typeof(UIResizeHandle)); rh.backgroundSprite = "buttonresize"; rh.AlignTo(this, UIAlignAnchor.BottomRight); rh.size = new Vector2(18f, 18f); rh.relativePosition = new Vector3(rh.relativePosition.x - 20, rh.relativePosition.y - 20, 0); rh.BringToFront(); }