public override void Start() { // Generates the following UI: // |---------------| // | | <-- _messageBox // | | // |---------------| // | | <-- _chatText // |---------------| backgroundSprite = "GenericPanel"; name = "MPChatLogPanel"; color = new Color32(22, 22, 22, 240); // Activates the dragging of the window AddUIComponent(typeof(UIDragHandle)); // Grab the view for calculating width and height of game var view = UIView.GetAView(); // Center this window in the game relativePosition = new Vector3(10.0f, view.fixedHeight - 440.0f); width = 500; height = 300; // Create the message box _messageBox = (UIListBox)AddUIComponent(typeof(UIListBox)); _messageBox.isVisible = true; _messageBox.isEnabled = true; _messageBox.width = 480; _messageBox.height = 240; _messageBox.position = new Vector2(10, -10); _messageBox.multilineItems = true; _messageBox.textScale = 0.8f; _messageBox.itemHeight = 20; // Create the message text box (used for sending messages) _chatText = (UITextField)AddUIComponent(typeof(UITextField)); _chatText.width = width; _chatText.height = 30; _chatText.position = new Vector2(0, -270); _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"; base.Start(); }
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(); }
public override void Start() { // Generates the following UI: // |---------------| // | | <-- _messageBox // | | // |---------------| // | | <-- _chatText // |---------------| backgroundSprite = "GenericPanel"; name = ChatLogPanel.NAME; color = new Color32(22, 22, 22, 240); // Activates the dragging of the window AddUIComponent(typeof(UIDragHandle)); // Grab the view for calculating width and height of game var view = UIView.GetAView(); // Center this window in the game relativePosition = new Vector3(10.0f, view.fixedHeight - 440.0f); width = 500; height = 300; // Create the message box _messageBox = (UIListBox)AddUIComponent(typeof(UIListBox)); _messageBox.isVisible = true; _messageBox.isEnabled = true; _messageBox.width = 480; _messageBox.height = 240; _messageBox.position = new Vector2(10, -10); _messageBox.multilineItems = true; _messageBox.textScale = 0.8f; _messageBox.itemHeight = 20; _messageBox.multilineItems = true; // Create the message text box (used for sending messages) _chatText = (UITextField)AddUIComponent(typeof(UITextField)); _chatText.width = width; _chatText.height = 30; _chatText.position = new Vector2(0, -270); _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"; _initialOpacity = opacity; PrintGameMessage("Welcome to Cities: Skylines Multiplayer!"); PrintGameMessage("Press the ~ (tilde) key to show or hide the chat."); PrintGameMessage("Join our discord server at: https://discord.gg/RjACPhd"); PrintGameMessage("Type '/help' to see a list of commands and usage."); PrintGameMessage("Type '/support' to find out where to report bugs and get help."); base.Start(); }