private void CreateFindReplace(bool isFind = true) { winDialog = new Window(isFind ? "Find" : "Replace") { X = Win.Bounds.Width / 2 - 30, Y = Win.Bounds.Height / 2 - 10, ColorScheme = Colors.Menu }; var tabView = new TabView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; tabView.AddTab(new TabView.Tab("Find", FindTab()), isFind); var replace = ReplaceTab(); tabView.AddTab(new TabView.Tab("Replace", replace), !isFind); tabView.SelectedTabChanged += (s, e) => tabView.SelectedTab.View.FocusFirst(); winDialog.Add(tabView); Win.Add(winDialog); winDialog.Width = replace.Width + 4; winDialog.Height = replace.Height + 4; winDialog.SuperView.BringSubviewToFront(winDialog); winDialog.SetFocus(); }
/*** Tabview ***/ void BuildTabview(VisualElement root) { mTabView = new TabView(); mTabView.LoadStyle("PlasticWindow/PlasticWindow"); mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.PendingChangesViewTitle), new VisualElement()).clicked += () => { // TODO: Add view switch to Pending Changes here }; mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.ChangesetsViewTitle), new VisualElement()).clicked += () => { // TODO: Add view switch to Changesets here }; mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.IncomingChangesViewTitle), new VisualElement()).clicked += () => { // TODO: Add view switch to Incoming Changes here }; VisualElement controlsContainer = new VisualElement() { name = "ControlsContainer" }; controlsContainer.AddToClassList("row"); mRefreshButton = new Button() { name = "RefreshButton" }; mRefreshButton.Add(new Image() { image = EditorGUIUtility.IconContent("refresh").image }); mRefreshButton.clicked += RefreshButton_Clicked; controlsContainer.Add(mRefreshButton); mSettingsButton = new Button() { name = "SettingsButton" }; mSettingsButton.Add(new Image() { image = EditorGUIUtility.IconContent("settings").image }); mSettingsButton.clicked += SettingsButton_Clicked; controlsContainer.Add(mSettingsButton); var tabArea = mTabView.Q <VisualElement>("TabArea"); tabArea.Add(controlsContainer); root.Add(mTabView); }
static void Main(string[] args) { Application.Init(); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_New...", LocMan.Get("New CommonSecrets file..."), () => { var createNew = NewFileDialog.CreateNewFileDialog(() => Application.RequestStop(), () => Application.RequestStop()); Application.Run(createNew); }), new MenuItem("_Open...", LocMan.Get("Open existing CommonSecrets file..."), () => OpenCommonSecretsFile()), new MenuItem("_Save", "Save CommonSecrets file", () => {}), new MenuItem("Save As...", "Save CommonSecrets file as...", () => SaveCommonSecretsFileAs()), new MenuItem("_Close", "Close file", () => {}), new MenuItem("_Quit", "Quit", () => { Application.RequestStop(); }) }), new MenuBarItem("_Edit", new MenuItem[] { }), new MenuBarItem("_Tools", new MenuItem[] { new MenuItem("_Generate Random Password...", LocMan.Get("Generate a new random password...."), () => { var createPasswordSelection = PasswordGeneratorDialog.CreateDialog(() => Application.RequestStop()); Application.Run(createPasswordSelection); }), }), }); var win = new Window("Hello") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill() - 1 }; //LoginInformationsWindow.CreateLoginInformationsDialog(win); TabView tabView = new TabView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(1) }; tabView.AddTab(new TabView.Tab("Login informations", LoginInformationsView.CreateView()), true); tabView.AddTab(new TabView.Tab("Notes", new ListView()), false); tabView.AddTab(new TabView.Tab("Files", new ListView()), false); tabView.AddTab(new TabView.Tab("Contacts", new ListView()), false); tabView.AddTab(new TabView.Tab("Payment cards", new ListView()), false); win.Add(tabView); // Add both menu and win in a single call Application.Top.Add(menu, win); Application.Run(); }
private TabView GetTabView(out Tab tab1, out Tab tab2) { InitFakeDriver(); var tv = new TabView(); tv.AddTab(tab1 = new Tab("Tab1", new TextField("hi")), false); tv.AddTab(tab2 = new Tab("Tab2", new Label("hi2")), false); return(tv); }
private static void InitializeCourtsMenu() { CourtsMenu = new TabView("~b~~h~San Andreas Magistrates' Court"); // use "AddTab" rather than "Tabs.Add" as it will throw an exception in "TabSubmenuItem.ProcessControls" // because the "Parent" won't be set in the submenu items causing a "NullPointerException" CourtsMenu.AddTab(PendingResultsList = new TabSubmenuItem("Pending Results", EmptyItems)); CourtsMenu.AddTab(PublishedResultsList = new TabSubmenuItem("Results", EmptyItems)); CourtsMenu.RefreshIndex(); }
public void AddTwoTabs_SecondIsSelected() { InitFakeDriver(); var tv = new TabView(); Tab tab1; Tab tab2; tv.AddTab(tab1 = new Tab("Tab1", new TextField("hi")), false); tv.AddTab(tab2 = new Tab("Tab1", new Label("hi2")), true); Assert.Equal(2, tv.Tabs.Count); Assert.Equal(tab2, tv.SelectedTab); }
private TabView GetTabView(out TabView.Tab tab1, out TabView.Tab tab2, bool initFakeDriver = true) { if (initFakeDriver) { InitFakeDriver(); } var tv = new TabView(); tv.ColorScheme = new ColorScheme(); tv.AddTab(tab1 = new TabView.Tab("Tab1", new TextField("hi")), false); tv.AddTab(tab2 = new TabView.Tab("Tab2", new Label("hi2")), false); return(tv); }
public MainPageView() { AddToClassList(UssClassName); AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(k_LayoutPath).CloneTree(this); styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(k_StylePath)); m_AlertBox = this.Q <AlertBox>(className: AlertBoxUssClassName); m_TabView = this.Q <TabView>(className: TabViewUssClassName); m_Container = this.Q <VisualElement>(className: ContainerUssClassName); m_ChangesView = new ChangesTabPageView(); m_HistoryView = new HistoryTabPageView(); m_TabView.AddTab(StringAssets.changes, m_ChangesView); m_TabView.AddTab(StringAssets.history, m_HistoryView); m_TabView.Init(); }
public override void InitWindow() { // Window's attr SetParameters(Controller.GetLanguage()["SetsTitle"], Controller.GetLanguage()["SetsTitle"], 900, 600, false); SetMinSize(900, 600); SetBackground(Factory.Palette.CommonDark); IsCentered = true; SetIcon(Factory.Resources.Icon, Factory.Resources.Icon); // Content _titleBar = Factory.Items.GetTitleBar(Controller.GetLanguage()["SetsTitle"]); CloseBtn = _titleBar.GetCloseButton(); VerticalStack layout = Factory.Items.GetLayout(); layout.SetMargin(0, _titleBar.GetHeight(), 0, 0); layout.SetPadding(0, 0, 0, 15); _tabArea = new TabView(); _tabArea.SetTabPolicy(SizePolicy.Expand); _common = new SettingsTab(Controller.GetLanguage()["SetsTabCommon"]); _commonContent = new CommonSettingsContainer(); _binds = new SettingsTab(Controller.GetLanguage()["SetsTabBinds"]); _bindsContent = new BindsSettingsContainer(); _sticks = new SettingsTab(Controller.GetLanguage()["SetsTabSticks"]); _sticksContent = new SticksSettingsContainer(); SaveBtn = Items.GetControlButton(Controller.GetLanguage()["SaveButton"]); // Adding content AddItems(_titleBar, layout); layout.AddItems( _tabArea, SaveBtn ); _tabArea.AddTab(_common); _tabArea.AddTab(_sticks); _tabArea.AddTab(_binds); _tabArea.AddItemToTab(_common, _commonContent as IBaseItem); _tabArea.AddItemToTab(_sticks, _sticksContent as IBaseItem); _tabArea.AddItemToTab(_binds, _bindsContent as IBaseItem); }
public ConsoleGuiViewGraph(IBasicActivateItems activator, AggregateConfiguration aggregate) : base(activator, new ViewAggregateExtractUICollection(aggregate) { TopX = null }) { graphView = new GraphView() { Width = Dim.Fill(), Height = Dim.Fill() }; ColorScheme = ConsoleMainWindow.ColorScheme; TabView.AddTab(graphTab = new Tab("Graph", graphView), false); this.aggregate = aggregate; }
void BuildComponents() { VisualElement root = rootVisualElement; root.Clear(); mTabView = new TabView(); mSignInPanel = new SignInPanel( this, sRestApi, sCmConnection); mSSOSignUpPanel = new SSOSignUpPanel( this, sRestApi, sCmConnection); mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.SignIn), mSignInPanel).clicked += () => { mIsOnSignIn = true; titleContent = new GUIContent(GetWindowTitle()); }; mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.SignUp), mSSOSignUpPanel).clicked += () => { mIsOnSignIn = false; titleContent = new GUIContent(GetWindowTitle()); }; root.Add(mTabView); if (sAutoLogin) { mSignInPanel.SignInWithUnityIdButtonAutoLogin(); } }
internal void BuildComponents() { VisualElement root = rootVisualElement; root.Clear(); mTabView = new TabView(); mSignInPanel = new SignInPanel(this); mSSOSignUpPanel = new SSOSignUpPanel(this, mRestApi); mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.Login), mSignInPanel); mTabView.AddTab( PlasticLocalization.GetString(PlasticLocalization.Name.SignUp), mSSOSignUpPanel).clicked += () => { titleContent = new GUIContent( PlasticLocalization.GetString(PlasticLocalization.Name.SignUp)); }; root.Add(mTabView); }
/// Modify this method for adding other examples. public TabViewExample() : base() { WidthSpecification = LayoutParamPolicies.MatchParent; HeightSpecification = LayoutParamPolicies.MatchParent; // Navigator bar title is added here. AppBar = new AppBar() { Title = "TabView Default Style", }; tabView = new TabView() { WidthSpecification = LayoutParamPolicies.MatchParent, }; Content = tabView; tabView.AddTab(CreateTabButton(), CreateView()); tabCount++; tabView.AddTab(CreateTabButton(), CreateView()); tabCount++; }
/// <summary> /// Creates a new tab with initial text /// </summary> /// <param name="initialText"></param> /// <param name="fileInfo">File that was read or null if a new blank document</param> private void Open(string initialText, FileInfo fileInfo, string tabName) { var textView = new TextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), Text = initialText }; var tab = new OpenedFile(tabName, fileInfo, textView); tabView.AddTab(tab, true); // when user makes changes rename tab to indicate unsaved textView.KeyUp += (k) => { // if current text doesn't match saved text var areDiff = tab.UnsavedChanges; if (areDiff) { if (!tab.Text.ToString().EndsWith('*')) { tab.Text = tab.Text.ToString() + '*'; tabView.SetNeedsDisplay(); } } else { if (tab.Text.ToString().EndsWith('*')) { tab.Text = tab.Text.ToString().TrimEnd('*'); tabView.SetNeedsDisplay(); } } }; }
public ConsoleGuiSqlEditor(IBasicActivateItems activator, IViewSQLAndResultsCollection collection) { this.Activator = activator; this._collection = collection; Modal = true; ColorScheme = ConsoleMainWindow.ColorScheme; // Tabs (query and results) TabView = new TabView() { Width = Dim.Fill(), Height = Dim.Fill(), Y = 1 }; textView = new SqlTextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), Text = _orignalSql = collection.GetSql().Replace("\r\n", "\n").Replace("\t", " ") }; textView.AllowsTab = false; TabView.AddTab(queryTab = new Tab("Query", textView), true); tableView = new TableView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; tableView.Style.AlwaysShowHeaders = true; tableView.CellActivated += TableView_CellActivated; TabView.AddTab(resultTab = new Tab("Results", tableView), false); Add(TabView); // Buttons on top of control _btnRunOrCancel = new Button("Run") { X = 0, Y = 0, }; _btnRunOrCancel.Clicked += () => RunOrCancel(); Add(_btnRunOrCancel); var resetSql = new Button("Reset Sq_l") { X = Pos.Right(_btnRunOrCancel) + 1 }; resetSql.Clicked += () => ResetSql(); Add(resetSql); var clearSql = new Button("Clear S_ql") { X = Pos.Right(resetSql) + 1, }; clearSql.Clicked += () => ClearSql(); Add(clearSql); var lblTimeout = new Label("Timeout:") { X = Pos.Right(clearSql) + 1, }; Add(lblTimeout); var tbTimeout = new TextField(_timeout.ToString()) { X = Pos.Right(lblTimeout), Width = 5 }; tbTimeout.TextChanged += TbTimeout_TextChanged; Add(tbTimeout); var btnSave = new Button("Save") { X = Pos.Right(tbTimeout) + 1, }; btnSave.Clicked += () => Save(); Add(btnSave); var btnClose = new Button("Clos_e") { X = Pos.Right(btnSave) + 1, }; btnClose.Clicked += () => { Application.RequestStop(); }; Add(btnClose); var auto = new AutoCompleteProvider(collection.GetQuerySyntaxHelper()); collection.AdjustAutocomplete(auto); var bits = auto.Items.SelectMany(auto.GetBits).OrderBy(a => a).Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList(); textView.Autocomplete.AllSuggestions = bits; textView.Autocomplete.MaxWidth = 40; }
public async void OpenCustomPauseMenu() { TabView MenuContainer = new TabView("This is the title", "Subtitle"); MenuContainer.SideStringTop = "Player_Name"; MenuContainer.SideStringMiddle = "Middle_String"; MenuContainer.SideStringBottom = "Bottom_string"; MenuContainer.DisplayHeader = true; _menuPool.AddPauseMenu(MenuContainer); TabItem Item1 = new TabItem("simple TabItem"); TabTextItem Item2 = new TabTextItem("TabTextItem", "This is the Title inside", "With a cool text to be added where you can write whatever you want"); TabItemSimpleList Item3 = new TabItemSimpleList("TabItemSimpleList", new Dictionary <string, string>() { ["Item 1"] = "subItem 1", ["Item 2"] = "subItem 2", ["Item 3"] = "subItem 3", ["Item 4"] = "subItem 4", ["Item 5"] = "subItem 5", ["Item 6"] = "subItem 6" }); List <UIMenuItem> items = new List <UIMenuItem>() { new UIMenuItem("Item 1"), new UIMenuCheckboxItem("Item 2", true), new UIMenuListItem("Item 3", new List <dynamic>() { "Item1", 2, 3.0999 }, 0), new UIMenuSliderItem("Item 4", "", true), new UIMenuSliderProgressItem("Item 5", 20, 0), }; TabInteractiveListItem Item4 = new TabInteractiveListItem("TabInteractiveListItem", items); List <MissionInformation> info = new List <MissionInformation>() { new MissionInformation("Mission 1", new List <Tuple <string, string> >() { new Tuple <string, string>("item 1", "description 1"), new Tuple <string, string>("item 2", "description 2"), new Tuple <string, string>("item 3", "description 3"), new Tuple <string, string>("item 4", "description 4"), new Tuple <string, string>("item 5", "description 5"), }), new MissionInformation("Mission 2", new List <Tuple <string, string> >() { new Tuple <string, string>("item 1", "description 1"), new Tuple <string, string>("item 2", "description 2"), new Tuple <string, string>("item 3", "description 3"), new Tuple <string, string>("item 4", "description 4"), new Tuple <string, string>("item 5", "description 5"), }), }; TabSubmenuItem Item5 = new TabSubmenuItem("TabSubmenuItem", new List <TabItem>() { new TabItem("simple TabItem"), new TabTextItem("TabTextItem", "This is the Title inside", "With a cool text to be added where you can write whatever you want"), new TabItemSimpleList("TabItemSimpleList", new Dictionary <string, string>() { ["Item 1"] = "subItem 1", ["Item 2"] = "subItem 2", ["Item 3"] = "subItem 3", ["Item 4"] = "subItem 4", ["Item 5"] = "subItem 5", ["Item 6"] = "subItem 6" }), new TabMissionSelectItem("Mission tab", info), new TabInteractiveListItem("TabInteractiveListItem", items) }); TabMissionSelectItem Item6 = new TabMissionSelectItem("Mission tab", info); MenuContainer.AddTab(Item1); MenuContainer.AddTab(Item2); MenuContainer.AddTab(Item3); MenuContainer.AddTab(Item4); MenuContainer.AddTab(Item5); MenuContainer.AddTab(Item6); // this way we can choose which tab is the defualt one Item1.Active = true; Item1.Focused = true; Item1.Visible = true; MenuContainer.Visible = true; // items have events exactly the same as UIMenuItems and you can handle TabInteractiveListItem items just like that }
public static void InitialiseMenus() { Game.FrameRender += Process; _MenuPool = new MenuPool(); //ChecksMenu = new UIMenu("Checks", ""); //_MenuPool.Add(ChecksMenu); TrafficStopMenu = new UIMenu("Traffic Stop", ""); _MenuPool.Add(TrafficStopMenu); TicketMenu = new UIMenu("Ticket", ""); _MenuPool.Add(TicketMenu); PursuitTacticsMenu = new UIMenu("Pursuit Tactics", ""); PursuitTacticsMenu.AddItem(AutomaticTacticsCheckboxItem = new UIMenuCheckboxItem("Automatic Tactics", EnhancedPursuitAI.DefaultAutomaticAI)); PursuitTacticsMenu.AddItem(PursuitTacticsListItem = new UIMenuListItem("Current Tactic", "", PursuitTacticsOptionsList)); PursuitTacticsListItem.Enabled = false; PursuitTacticsMenu.RefreshIndex(); PursuitTacticsMenu.OnItemSelect += OnItemSelect; PursuitTacticsMenu.OnCheckboxChange += OnCheckboxChange; //TrafficStopMenu.OnListChange += OnListChange; PursuitTacticsMenu.MouseControlsEnabled = false; PursuitTacticsMenu.AllowCameraMovement = true; _MenuPool.Add(PursuitTacticsMenu); Dictionary <UIMenu, string> UIMenus_Categories = new Dictionary <UIMenu, string>(); foreach (string category in Offence.CategorizedTrafficOffences.Keys) { UIMenu newcategorymenu = new UIMenu(category, "LSPDFR+ offences"); OffenceCategoryMenus.Add(newcategorymenu); UIMenus_Categories.Add(newcategorymenu, category); } OffenceCategorySwitchItem = new UIMenuSwitchMenusItem("Categories", "", OffenceCategoryMenus); foreach (UIMenu newcategorymenu in OffenceCategoryMenus) { newcategorymenu.AddItem(OffenceCategorySwitchItem); string category = UIMenus_Categories[newcategorymenu]; foreach (string reason in Offence.CategorizedTrafficOffences[category].Select(x => x.name)) { UIMenuCheckboxItem newcheckboxitem = new UIMenuCheckboxItem(reason, false); newcategorymenu.AddItem(newcheckboxitem); CheckboxItems_Offences.Add(new Tuple <UIMenuCheckboxItem, Offence>(newcheckboxitem, Offence.CategorizedTrafficOffences[category].FirstOrDefault(x => x.name == reason))); } newcategorymenu.OnMenuClose += OnMenuClose; newcategorymenu.RefreshIndex(); newcategorymenu.AllowCameraMovement = true; newcategorymenu.MouseControlsEnabled = false; _MenuPool.Add(newcategorymenu); } var speech = new List <dynamic>() { "Hello", "Insult", "Kifflom", "Thanks", "Swear", "Warn", "Threaten" }; TrafficStopMenu.AddItem(SpeechItem = new UIMenuListItem("Speech", "", speech)); TrafficStopMenu.AddItem(IDItem = new UIMenuListItem("Ask for identification", "", OccupantSelector)); TrafficStopMenu.AddItem(QuestionDriverItem = new UIMenuItem("Question driver")); TrafficStopMenu.AddItem(PenaltyItem = new UIMenuItem("Issue Penalty")); TrafficStopMenu.AddItem(WarningItem = new UIMenuItem("Issue warning", "Let the driver go with words of advice.")); TrafficStopMenu.AddItem(OutOfVehicleItem = new UIMenuListItem("Order out of vehicle", "", OccupantSelector)); TrafficStopMenu.RefreshIndex(); TrafficStopMenu.OnItemSelect += OnItemSelect; TrafficStopMenu.MouseControlsEnabled = false; TrafficStopMenu.AllowCameraMovement = true; for (int i = 5; i <= Offence.maxFine; i += 5) { FineList.Add(Offence.currency + i.ToString()); } for (int i = Offence.minpoints; i <= Offence.maxpoints; i += Offence.pointincstep) { PointsList.Add(i.ToString()); } TicketMenu.AddItem(TicketOffenceSelectorItem); TicketMenu.AddItem(FineItem = new UIMenuListItem("Fine", "", FineList)); PointsItem = new UIMenuListItem("Points", "", PointsList); if (Offence.enablePoints) { TicketMenu.AddItem(PointsItem); } //TicketMenu.AddItem(TicketReasonsListItem = new UIMenuListItem("Offence", TicketReasonsList, 0)); TicketMenu.AddItem(SeizeVehicleTicketCheckboxItem = new UIMenuCheckboxItem("Seize Vehicle", false)); List <dynamic> PenaltyOptions = new List <dynamic>() { "Ticket", "Court Summons" }; if (LSPDFRPlusHandler.BritishPolicingScriptRunning) { PenaltyOptions = new List <dynamic> { "Traffic Offence Report", "Fixed Penalty Notice", "Court Summons" }; } TicketMenu.AddItem(IssueTicketItem = new UIMenuListItem("~h~Issue ", "", PenaltyOptions)); IssueTicketItem.OnListChanged += OnIndexChange; TicketMenu.ParentMenu = TrafficStopMenu; TicketMenu.RefreshIndex(); TicketMenu.OnItemSelect += OnItemSelect; TicketMenu.MouseControlsEnabled = false; TicketMenu.AllowCameraMovement = true; TicketMenu.SetMenuWidthOffset(80); QuestioningMenu = new UIMenu("Questioning", ""); _MenuPool.Add(QuestioningMenu); QuestioningMenu.AddItem(IllegalInVehQuestionItem = new UIMenuItem("")); QuestioningMenu.AddItem(DrinkingQuestionItem = new UIMenuItem("")); QuestioningMenu.AddItem(DrugsQuestionItem = new UIMenuItem("")); QuestioningMenu.AddItem(SearchPermissionItem = new UIMenuItem("")); QuestioningMenu.ParentMenu = TrafficStopMenu; QuestioningMenu.RefreshIndex(); QuestioningMenu.OnItemSelect += OnItemSelect; QuestioningMenu.MouseControlsEnabled = false; QuestioningMenu.AllowCameraMovement = true; QuestioningMenu.SetMenuWidthOffset(110); CourtsMenu = new TabView("~b~~h~San Andreas Court"); CourtsMenu.AddTab(PendingResultsList = new TabSubmenuItem("Pending Results", EmptyItems)); CourtsMenu.AddTab(PublishedResultsList = new TabSubmenuItem("Results", EmptyItems)); CourtsMenu.RefreshIndex(); MainLogic(); }
public static void Main() { Game.FrameRender += Process; tabView = new TabView("A RAGENativeUI Pause Menu"); tabView.MoneySubtitle = "$10.000.000"; tabView.Name = "Here goes the Name! :D"; Dictionary <string, string> listDict = new Dictionary <string, string>() { { "First Item", "Text filler" }, { "Second Item", "Hey, here there's some text" }, { "Third Item", "Duh!" }, }; tabView.AddTab(simpleListTab = new TabItemSimpleList("A List", listDict)); simpleListTab.Activated += SimpleListTab_Activated; List <MissionInformation> missionsInfo = new List <MissionInformation>() { new MissionInformation("Mission One", new Tuple <string, string>[] { new Tuple <string, string>("This the first info", "Random Info"), new Tuple <string, string>("This the second info", "Random Info #2") }) { Logo = new MissionLogo(Game.CreateTextureFromFile("DefaultSkin.png")) }, new MissionInformation("Mission Two", "I have description!", new Tuple <string, string>[] { new Tuple <string, string>("Objective", "Mission Two Objective") }), }; tabView.AddTab(missionSelectTab = new TabMissionSelectItem("I'm a Mission Select Tab", missionsInfo)); missionSelectTab.OnItemSelect += MissionSelectTab_OnItemSelect; tabView.AddTab(textTab = new TabTextItem("TabTextItem", "Text Tab Item", "I'm a text tab item")); textTab.Activated += TextTab_Activated; List <TabItem> items = new List <TabItem>(); for (int i = 0; i < 10; i++) { TabTextItem tItem = new TabTextItem("Item #" + i, "Title #" + i, "Some random text for #" + i); tItem.Activated += SubMenuItem_Activated; items.Add(tItem); } tabView.AddTab(submenuTab = new TabSubmenuItem("A submenu", items)); List <UIMenuItem> menuItems = new List <UIMenuItem>() { new UIMenuItem("First MenuItem!", ""), new UIMenuCheckboxItem("A Checkbox", true), new UIMenuListItem("List", new List <dynamic>() { "something", new Vector3(5, 0, 5), 10, 5, false, }, 0), }; TabInteractiveListItem interactiveListItem = new TabInteractiveListItem("An Interactive List", menuItems); tabView.AddTab(interactiveListItem); tabView.RefreshIndex(); while (true) { GameFiber.Yield(); } }
public override void Setup() { Win.Title = this.GetName(); Win.Y = 1; // menu Win.Height = Dim.Fill(1); // status bar Top.LayoutSubviews(); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Add Blank Tab", "", () => AddBlankTab()), new MenuItem("_Clear SelectedTab", "", () => tabView.SelectedTab = null), new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_View", new MenuItem [] { miShowTopLine = new MenuItem("_Show Top Line", "", () => ShowTopLine()) { Checked = true, CheckType = MenuItemCheckStyle.Checked }, miShowBorder = new MenuItem("_Show Border", "", () => ShowBorder()) { Checked = true, CheckType = MenuItemCheckStyle.Checked }, miTabsOnBottom = new MenuItem("_Tabs On Bottom", "", () => SetTabsOnBottom()) { Checked = false, CheckType = MenuItemCheckStyle.Checked } }) }); Top.Add(menu); tabView = new TabView() { X = 0, Y = 0, Width = 60, Height = 20, }; tabView.AddTab(new Tab("Tab1", new Label("hodor!")), false); tabView.AddTab(new Tab("Tab2", new Label("durdur")), false); tabView.AddTab(new Tab("Interactive Tab", GetInteractiveTab()), false); tabView.AddTab(new Tab("Big Text", GetBigTextFileTab()), false); tabView.AddTab(new Tab( "Long name Tab, I mean seriously long. Like you would not believe how long this tab's name is its just too much really woooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooowwww thats long", new Label("This tab has a very long name which should be truncated. See TabView.MaxTabTextWidth")), false); tabView.AddTab(new Tab("Les Mise" + Char.ConvertFromUtf32(Int32.Parse("0301", NumberStyles.HexNumber)) + "rables", new Label("This tab name is unicode")), false); for (int i = 0; i < 100; i++) { tabView.AddTab(new Tab($"Tab{i}", new Label($"Welcome to tab {i}")), false); } tabView.SelectedTab = tabView.Tabs.First(); Win.Add(tabView); var frameRight = new FrameView("About") { X = Pos.Right(tabView), Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), }; frameRight.Add(new TextView() { Text = "This demos the tabs control\nSwitch between tabs using cursor keys", Width = Dim.Fill(), Height = Dim.Fill() }); Win.Add(frameRight); var frameBelow = new FrameView("Bottom Frame") { X = 0, Y = Pos.Bottom(tabView), Width = tabView.Width, Height = Dim.Fill(), }; frameBelow.Add(new TextView() { Text = "This frame exists to check you can still tab here\nand that the tab control doesn't overspill it's bounds", Width = Dim.Fill(), Height = Dim.Fill() }); Win.Add(frameBelow); var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()), }); Top.Add(statusBar); }
private void AddBlankTab() { tabView.AddTab(new Tab(), false); }
public void Activate() { var window = NUIApplication.GetDefaultWindow(); tabView = new TabView() { WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; tabCount = 0; tabButton = new TabButton() { Text = "Tab#1" }; tabButton.SelectedChanged += (object sender, SelectedChangedEventArgs args) => { global::System.Console.WriteLine($"1st TabButton's IsSelected is changed to {args.IsSelected}."); }; content = new TextLabel() { Text = "Content#1", BackgroundColor = Color.Red, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; tabView.AddTab(tabButton, content); tabCount++; tabButton2 = new TabButton() { Text = "Tab#2" }; tabButton2.SelectedChanged += (object sender, SelectedChangedEventArgs args) => { global::System.Console.WriteLine($"2nd TabButton's IsSelected is changed to {args.IsSelected}."); }; content2 = new TextLabel() { Text = "Content#2", BackgroundColor = Color.Green, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; tabView.AddTab(tabButton2, content2); tabCount++; tabButton3 = new TabButton() { Text = "Tab#3" }; tabButton3.SelectedChanged += (object sender, SelectedChangedEventArgs args) => { global::System.Console.WriteLine($"3rd TabButton's IsSelected is changed to {args.IsSelected}."); }; content3 = new TextLabel() { Text = "Content#3", BackgroundColor = Color.Blue, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; tabView.AddTab(tabButton3, content3); tabCount++; window.Add(tabView); addBtn = new Button() { Text = "+Tab", Size = new Size(100, 72), Position = new Position(80, 290) }; addBtn.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount < 3) { tabCount++; var newTabButton = new TabButton() { Text = "Tab#" + tabCount.ToString() }; int curCount = tabCount; newTabButton.SelectedChanged += (object sender, SelectedChangedEventArgs args) => { global::System.Console.WriteLine($"{curCount}th TabButton's IsSelected is changed to {args.IsSelected}."); }; var newContent = new TextLabel() { Text = "Content#" + tabCount.ToString(), WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; switch (tabCount) { case 1: newContent.BackgroundColor = Color.Red; break; case 2: newContent.BackgroundColor = Color.Green; break; default: newContent.BackgroundColor = Color.Blue; break; } tabView.AddTab(newTabButton, newContent); } }; window.Add(addBtn); removeBtn = new Button() { Text = "-Tab", Size = new Size(100, 72), Position = new Position(180, 290), }; removeBtn.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount > 0) { tabCount--; tabView.RemoveTab(tabCount); } }; window.Add(removeBtn); }
private static void Main() { tabView = new TabView("A RAGENativeUI Pause Menu"); tabView.MoneySubtitle = "$10.000.000"; tabView.Name = "Here goes the Name! :D"; Dictionary <string, string> listDict = new Dictionary <string, string>() { { "First Item", "Text filler" }, { "Second Item", "Hey, here there's some text" }, { "Third Item", "Duh!" }, }; tabView.AddTab(simpleListTab = new TabItemSimpleList("A List", listDict)); simpleListTab.Activated += (s, e) => Game.DisplaySubtitle("I'm in the simple list tab", 5000); List <MissionInformation> missionsInfo = new List <MissionInformation>() { new MissionInformation("Mission One", new Tuple <string, string>[] { new Tuple <string, string>("This the first info", "Random Info"), new Tuple <string, string>("This the second info", "Random Info #2") }) { Logo = new MissionLogo(Game.CreateTextureFromFile("DefaultSkin.png")) }, new MissionInformation("Mission Two", "I have description!", new Tuple <string, string>[] { new Tuple <string, string>("Objective", "Mission Two Objective") }), }; tabView.AddTab(missionSelectTab = new TabMissionSelectItem("I'm a Mission Select Tab", missionsInfo)); missionSelectTab.OnItemSelect += (info) => { if (info.Name == "Mission One") { Game.DisplaySubtitle("~g~Mission One Activated", 5000); } else if (info.Name == "Mission Two") { Game.DisplaySubtitle("~b~Mission Two Activated", 5000); } }; tabView.AddTab(textTab = new TabTextItem("TabTextItem", "Text Tab Item", "I'm a text tab item")); textTab.Activated += (s, e) => Game.DisplaySubtitle("I'm in the text tab", 5000); List <TabItem> items = new List <TabItem>(); for (int i = 0; i < 10; i++) { TabItem tItem = i < 5 ? (TabItem) new TabTextItem("Item #" + i, "Title #" + i, "Some random text for #" + i) : (TabItem) new TabInteractiveListItem("Item #" + i, CreateMenuItems()); tItem.Activated += (s, e) => Game.DisplaySubtitle("Activated Submenu Item #" + submenuTab.Index, 5000); items.Add(tItem); } tabView.AddTab(submenuTab = new TabSubmenuItem("A submenu", items)); UIMenuItem[] menuItems = CreateMenuItems(); menuItems[0].Activated += (m, s) => Game.DisplaySubtitle("Activated first item!"); TabInteractiveListItem interactiveListItem = new TabInteractiveListItem("An Interactive List", menuItems); // set fast scrolling on scroller item with a slider bar (see MenuExtensions.cs) interactiveListItem.BackingMenu.WithFastScrollingOn(menuItems.Where(i => i is UIMenuScrollerItem s && s.SliderBar != null)); interactiveListItem.BackingMenu.OnIndexChange += (m, i) => Game.DisplaySubtitle("Selected #" + i); tabView.AddTab(interactiveListItem); tabView.RefreshIndex(); // start the fiber which will handle drawing and processing the pause menu GameFiber.StartNew(ProcessMenus); // continue with the plugin... Game.Console.Print($" Press {KeyBinding} to open the pause menu."); Game.DisplayHelp($"Press ~{KeyBinding.GetInstructionalId()}~ to open the pause menu."); }
private void BuildMainMenu() { MainMenu = new TabView("Cherry Multiplayer") { CanLeave = false, MoneySubtitle = "Cherry MP " + CurrentVersion }; _mainMapItem = new TabMapItem(); #region Welcome Screen { _welcomePage = new TabWelcomeMessageItem("Welcome to Cherry Multiplayer", "Development branch."); MainMenu.Tabs.Add(_welcomePage); } #endregion #region ServerBrowser { var dConnect = new TabButtonArrayItem("Quick Connect"); { var ipButton = new TabButton { Text = "IP Address", Size = new Size(500, 40) }; ipButton.Activated += (sender, args) => { MainMenu.TemporarilyHidden = true; var newIp = InputboxThread.GetUserInput(_clientIp ?? "", 30, TickSpinner); _clientIp = newIp; ipButton.Text = string.IsNullOrWhiteSpace(newIp) ? "IP Address" : newIp; MainMenu.TemporarilyHidden = false; }; dConnect.Buttons.Add(ipButton); } { var ipButton = new TabButton { Text = "Port", Size = new Size(500, 40) }; ipButton.Activated += (sender, args) => { MainMenu.TemporarilyHidden = true; var port = InputboxThread.GetUserInput(Port.ToString(), 30, TickSpinner); if (string.IsNullOrWhiteSpace(port)) { port = "4499"; } if (!int.TryParse(port, out int newPort)) { Util.Util.SafeNotify("Wrong port format!"); MainMenu.TemporarilyHidden = false; return; } Port = newPort; ipButton.Text = Port.ToString(); MainMenu.TemporarilyHidden = false; }; dConnect.Buttons.Add(ipButton); } { var ipButton = new TabButton { Text = "Password", Size = new Size(500, 40) }; ipButton.Activated += (sender, args) => { MainMenu.TemporarilyHidden = true; var newIp = InputboxThread.GetUserInput("", 30, TickSpinner); MainMenu.TemporarilyHidden = false; _QCpassword = newIp; ipButton.Text = string.IsNullOrWhiteSpace(newIp) ? "Password" : "*******"; }; dConnect.Buttons.Add(ipButton); } { var ipButton = new TabButton { Text = "Connect", Size = new Size(500, 40) }; ipButton.Activated += (sender, args) => { var isPassworded = false; if (!string.IsNullOrWhiteSpace(_QCpassword)) { isPassworded = true; } AddServerToRecent(_clientIp + ":" + Port, _QCpassword); ConnectToServer(_clientIp, Port, isPassworded, _QCpassword); MainMenu.TemporarilyHidden = true; }; dConnect.Buttons.Add(ipButton); } _Verified = new TabInteractiveListItem("Verified", new List <UIMenuItem>()); _serverBrowser = new TabInteractiveListItem("Internet", new List <UIMenuItem>()); _favBrowser = new TabInteractiveListItem("Favorites", new List <UIMenuItem>()); _lanBrowser = new TabInteractiveListItem("Local Network", new List <UIMenuItem>()); _recentBrowser = new TabInteractiveListItem("Recent", new List <UIMenuItem>()); _connectTab = new TabSubmenuItem("connect", new List <TabItem>() { dConnect, _favBrowser, _Verified, _serverBrowser, _lanBrowser, _recentBrowser }); MainMenu.AddTab(_connectTab); _connectTab.DrawInstructionalButtons += (sender, args) => { MainMenu.DrawInstructionalButton(4, Control.Jump, "Refresh"); if (Game.IsControlJustPressed(0, Control.Jump)) { RebuildServerBrowser(); } #region Verified, Iternet, LAN and Recent if (_connectTab.Index == 2 && _connectTab.Items[2].Focused || _connectTab.Index == 3 && _connectTab.Items[3].Focused || _connectTab.Index == 4 && _connectTab.Items[4].Focused || _connectTab.Index == 5 && _connectTab.Items[5].Focused) { MainMenu.DrawInstructionalButton(5, Control.Enter, "Add to Favorites"); if (Game.IsControlJustPressed(0, Control.Enter)) { var selectedServer = _serverBrowser.Items[_serverBrowser.Index]; if (_connectTab.Index == 2 && _connectTab.Items[2].Focused) { selectedServer = _Verified.Items[_Verified.Index]; } else if (_connectTab.Index == 4 && _connectTab.Items[4].Focused) { selectedServer = _lanBrowser.Items[_lanBrowser.Index]; } else if (_connectTab.Index == 5 && _connectTab.Items[5].Focused) { selectedServer = _recentBrowser.Items[_recentBrowser.Index]; } selectedServer.SetRightBadge(UIMenuItem.BadgeStyle.None); if (PlayerSettings.FavoriteServers.Contains(selectedServer.Description)) { var favItem = _favBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description); if (favItem != null) { selectedServer.SetRightBadge(UIMenuItem.BadgeStyle.None); RemoveFromFavorites(selectedServer.Description); _favBrowser.Items.Remove(favItem); _favBrowser.RefreshIndex(); } } else { AddToFavorites(selectedServer.Description); selectedServer.SetRightBadge(UIMenuItem.BadgeStyle.Star); var item = new UIMenuItem(selectedServer.Text) { Description = selectedServer.Description }; item.SetRightLabel(selectedServer.RightLabel); item.SetLeftBadge(selectedServer.LeftBadge); item.Activated += (faf, selectedItem) => { if (IsOnServer()) { Client.Disconnect("Switching servers"); NetEntityHandler.ClearAll(); if (Npcs != null) { Npcs.ToList().ForEach(pair => pair.Value.Clear()); Npcs.Clear(); } while (IsOnServer()) { Script.Yield(); } } bool pass = false; if (selectedServer.LeftBadge == UIMenuItem.BadgeStyle.Lock) { pass = true; } var splt = selectedServer.Description.Split(':'); if (splt.Length < 2) { return; } if (!int.TryParse(splt[1], out int port)) { return; } ConnectToServer(splt[0], port, pass); MainMenu.TemporarilyHidden = true; _connectTab.RefreshIndex(); }; _favBrowser.Items.Add(item); } } } #endregion #region Favorites if (_connectTab.Index == 1 && _connectTab.Items[1].Focused) { MainMenu.DrawInstructionalButton(6, Control.NextCamera, "Add Server"); #region Add server if (Game.IsControlJustPressed(0, Control.NextCamera)) { MainMenu.TemporarilyHidden = true; var serverIp = InputboxThread.GetUserInput("Server IP(:Port)", 40, TickSpinner); if (serverIp.Contains("Server IP(:Port)") || string.IsNullOrWhiteSpace(serverIp)) { Util.Util.SafeNotify("Incorrect input!"); MainMenu.TemporarilyHidden = false; return; } else if (!serverIp.Contains(":")) { serverIp += ":4499"; } MainMenu.TemporarilyHidden = false; if (!PlayerSettings.FavoriteServers.Contains(serverIp)) { AddToFavorites(serverIp); var item = new UIMenuItem(serverIp) { Description = serverIp }; _favBrowser.Items.Add(item); } else { Util.Util.SafeNotify("Server already on the list"); return; } } #endregion MainMenu.DrawInstructionalButton(5, Control.Enter, "Remove"); #region Remove if (Game.IsControlJustPressed(0, Control.Enter)) { var selectedServer = _favBrowser.Items[_favBrowser.Index]; var favItem = _favBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description); if (_Verified.Items.FirstOrDefault(i => i.Description == selectedServer.Description) != null) { _Verified.Items.FirstOrDefault(i => i.Description == selectedServer.Description).SetRightBadge(UIMenuItem.BadgeStyle.None); } if (_serverBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description) != null) { _serverBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description).SetRightBadge(UIMenuItem.BadgeStyle.None); } if (_lanBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description) != null) { _lanBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description).SetRightBadge(UIMenuItem.BadgeStyle.None); } if (_recentBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description) != null) { _recentBrowser.Items.FirstOrDefault(i => i.Description == selectedServer.Description).SetRightBadge(UIMenuItem.BadgeStyle.None); } if (favItem != null) { Util.Util.SafeNotify("Server removed from Favorites!"); RemoveFromFavorites(selectedServer.Description); _favBrowser.Items.Remove(favItem); _favBrowser.RefreshIndex(); } } #endregion } #endregion }; CherryDiscord.CherryDiscord.InMenuDiscordInitialize(CurrentVersion.ToString()); CherryDiscord.CherryDiscord.InMenuDiscordUpdatePresence(); } #endregion #region Settings { #region General Menu var GeneralMenu = new TabInteractiveListItem("General", new List <UIMenuItem>()); { var nameItem = new UIMenuItem("Display Name"); nameItem.SetRightLabel(PlayerSettings.DisplayName); nameItem.Activated += (sender, item) => { if (IsOnServer()) { GTA.UI.Screen.ShowNotification("You cannot change your Display Name while connected to a server."); return; } MainMenu.TemporarilyHidden = true; var newName = InputboxThread.GetUserInput(PlayerSettings.DisplayName ?? "Enter a new Display Name", 32, TickSpinner); if (!string.IsNullOrWhiteSpace(newName)) { if (newName.Length > 32) { newName = newName.Substring(0, 32); } newName = newName.Replace(' ', '_'); PlayerSettings.DisplayName = newName; SaveSettings(); nameItem.SetRightLabel(newName); } MainMenu.TemporarilyHidden = false; }; GeneralMenu.Items.Add(nameItem); } { var debugItem = new UIMenuCheckboxItem("Show Game FPS Counter", PlayerSettings.ShowFPS); debugItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.ShowFPS = @checked; DebugInfo.FPS = @checked; SaveSettings(); }; GeneralMenu.Items.Add(debugItem); } { var debugItem = new UIMenuCheckboxItem("Disable Rockstar Editor", PlayerSettings.DisableRockstarEditor); debugItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.DisableRockstarEditor = @checked; SaveSettings(); }; GeneralMenu.Items.Add(debugItem); } { var debugItem = new UIMenuCheckboxItem("Allow Webcam/Microphone Streaming (Requires restart)", PlayerSettings.MediaStream); debugItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.MediaStream = @checked; SaveSettings(); }; GeneralMenu.Items.Add(debugItem); } { var nameItem = new UIMenuItem("Update Channel"); nameItem.SetRightLabel(PlayerSettings.UpdateChannel); nameItem.Activated += (sender, item) => { MainMenu.TemporarilyHidden = true; var newName = InputboxThread.GetUserInput(PlayerSettings.UpdateChannel ?? "stable", 40, TickSpinner); if (!string.IsNullOrWhiteSpace(newName)) { PlayerSettings.UpdateChannel = newName; SaveSettings(); nameItem.SetRightLabel(newName); } MainMenu.TemporarilyHidden = false; }; GeneralMenu.Items.Add(nameItem); } #endregion #region Chat var ChatboxMenu = new TabInteractiveListItem("Chat", new List <UIMenuItem>()); { var chatItem = new UIMenuCheckboxItem("Enable Timestamp", PlayerSettings.Timestamp); chatItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.Timestamp = @checked; SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } { var chatItem = new UIMenuCheckboxItem("Use Military Time", PlayerSettings.Militarytime); chatItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.Militarytime = @checked; SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } { var chatItem = new UIMenuCheckboxItem("Scale Chatbox With Safezone", PlayerSettings.ScaleChatWithSafezone); chatItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.ScaleChatWithSafezone = @checked; SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } { var chatItem = new UIMenuItem("Horizontal Chatbox Offset"); chatItem.SetRightLabel(PlayerSettings.ChatboxXOffset.ToString()); chatItem.Activated += (sender, item) => { MainMenu.TemporarilyHidden = true; var strInput = InputboxThread.GetUserInput(PlayerSettings.ChatboxXOffset.ToString(), 10, TickSpinner); if (!int.TryParse(strInput, out int newSetting)) { Util.Util.SafeNotify("Input was not in the correct format."); MainMenu.TemporarilyHidden = false; return; } MainMenu.TemporarilyHidden = false; PlayerSettings.ChatboxXOffset = newSetting; chatItem.SetRightLabel(PlayerSettings.ChatboxXOffset.ToString()); SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } { var chatItem = new UIMenuItem("Vertical Chatbox Offset"); chatItem.SetRightLabel(PlayerSettings.ChatboxYOffset.ToString()); chatItem.Activated += (sender, item) => { MainMenu.TemporarilyHidden = true; var strInput = InputboxThread.GetUserInput(PlayerSettings.ChatboxYOffset.ToString(), 10, TickSpinner); if (!int.TryParse(strInput, out int newSetting)) { Util.Util.SafeNotify("Input was not in the correct format."); MainMenu.TemporarilyHidden = false; return; } MainMenu.TemporarilyHidden = false; PlayerSettings.ChatboxYOffset = newSetting; chatItem.SetRightLabel(PlayerSettings.ChatboxYOffset.ToString()); SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } { var chatItem = new UIMenuCheckboxItem("Use Classic Chatbox", PlayerSettings.UseClassicChat); chatItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.UseClassicChat = @checked; SaveSettings(); }; ChatboxMenu.Items.Add(chatItem); } #endregion #region Experimental var ExpMenu = new TabInteractiveListItem("Experimental", new List <UIMenuItem>()); { var expItem = new UIMenuCheckboxItem("Disable Chromium Embedded Framework (Requires restart)", PlayerSettings.DisableCEF); expItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.DisableCEF = @checked; SaveSettings(); }; ExpMenu.Items.Add(expItem); } #endregion #region Debug Menu var DebugMenu = new TabInteractiveListItem("Debug", new List <UIMenuItem>()); { { var expItem = new UIMenuCheckboxItem("Enable CEF Development Tools (http://localhost:9222) [Restart required]", PlayerSettings.CEFDevtool); expItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.CEFDevtool = @checked; SaveSettings(); }; DebugMenu.Items.Add(expItem); } { var expItem = new UIMenuCheckboxItem("Enable Debug mode (Requires an extra tool)", PlayerSettings.DebugMode); expItem.CheckboxEvent += (sender, @checked) => { PlayerSettings.DebugMode = @checked; SaveSettings(); }; DebugMenu.Items.Add(expItem); } { var expItem = new UIMenuCheckboxItem("Save Debug to File (Huge performance impact)", SaveDebugToFile); expItem.CheckboxEvent += (sender, @checked) => { SaveDebugToFile = @checked; SaveSettings(); }; DebugMenu.Items.Add(expItem); } { var debugItem = new UIMenuCheckboxItem("Remove Game Entities", RemoveGameEntities); debugItem.CheckboxEvent += (sender, @checked) => { RemoveGameEntities = @checked; }; DebugMenu.Items.Add(debugItem); } { var debugItem = new UIMenuCheckboxItem("Show Streamer Debug Data", DebugInfo.StreamerDebug); debugItem.CheckboxEvent += (sender, @checked) => { DebugInfo.StreamerDebug = @checked; }; DebugMenu.Items.Add(debugItem); } { var debugItem = new UIMenuCheckboxItem("Disable Nametag Draw", ToggleNametagDraw); debugItem.CheckboxEvent += (sender, @checked) => { ToggleNametagDraw = @checked; }; DebugMenu.Items.Add(debugItem); } { var debugItem = new UIMenuCheckboxItem("Disable Position Update", TogglePosUpdate); debugItem.CheckboxEvent += (sender, @checked) => { TogglePosUpdate = @checked; }; DebugMenu.Items.Add(debugItem); } } #endregion var welcomeItem = new TabSubmenuItem("settings", new List <TabItem>() { GeneralMenu, ChatboxMenu, //DisplayMenu, //GraphicsMenu, ExpMenu, DebugMenu }); MainMenu.AddTab(welcomeItem); } #endregion #region Quit { var welcomeItem = new TabTextItem("Quit", "Quit Cherry Multiplayer", "Are you sure you want to quit Cherry Multiplayer and return to desktop?") { CanBeFocused = false }; welcomeItem.Activated += (sender, args) => { if (Client != null && IsOnServer()) { Client.Disconnect("Quit"); } CEFManager.Dispose(); CEFManager.DisposeCef(); Script.Wait(500); //Environment.Exit(0); Process.GetProcessesByName("GTA5")[0].Kill(); Process.GetCurrentProcess().Kill(); }; MainMenu.Tabs.Add(welcomeItem); } #endregion #region Current Server Tab #region Players _serverPlayers = new TabItemSimpleList("Players", new Dictionary <string, string>()); #endregion var favTab = new TabTextItem("Favorite", "Add to Favorites", "Add the current server to favorites.") { CanBeFocused = false }; favTab.Activated += (sender, args) => { var serb = _currentServerIp + ":" + _currentServerPort; AddToFavorites(_currentServerIp + ":" + _currentServerPort); var item = new UIMenuItem(serb) { Description = serb }; Util.Util.SafeNotify("Server added to favorites!"); item.Activated += (faf, selectedItem) => { if (IsOnServer()) { Client.Disconnect("Switching servers"); NetEntityHandler.ClearAll(); if (Npcs != null) { Npcs.ToList().ForEach(pair => pair.Value.Clear()); Npcs.Clear(); } while (IsOnServer()) { Script.Yield(); } } var splt = serb.Split(':'); if (splt.Length < 2) { return; } if (!int.TryParse(splt[1], out int port)) { return; } ConnectToServer(splt[0], port); MainMenu.TemporarilyHidden = true; _connectTab.RefreshIndex(); AddServerToRecent(serb, ""); }; _favBrowser.Items.Add(item); }; var dcItem = new TabTextItem("Disconnect", "Disconnect", "Disconnect from the current server.") { CanBeFocused = false }; dcItem.Activated += (sender, args) => { if (Client != null) { Client.Disconnect("Quit"); } }; _statsItem = new TabTextItem("Statistics", "Network Statistics", "") { CanBeFocused = false }; _serverItem = new TabSubmenuItem("server", new List <TabItem>() { _serverPlayers, favTab, _statsItem, dcItem }) { Parent = MainMenu }; #endregion MainMenu.RefreshIndex(); }
public void Activate() { var window = NUIApplication.GetDefaultWindow(); tabView = new TabView() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent }; tabCount = 0; tabButton = new TabButton() { Text = "Tab#1" }; content = new TextLabel() { Text = "Content#1", BackgroundColor = Color.Red, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; tabView.AddTab(tabButton, content); tabCount++; tabButton2 = new TabButton() { Text = "Tab#2" }; content2 = new TextLabel() { Text = "Content#2", BackgroundColor = Color.Green, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; tabView.AddTab(tabButton2, content2); tabCount++; tabButton3 = new TabButton() { Text = "Tab#3" }; content3 = new TextLabel() { Text = "Content#3", BackgroundColor = Color.Blue, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; tabView.AddTab(tabButton3, content3); tabCount++; window.Add(tabView); addBtn = new Button() { Text = "+Tab", Size = new Size(100, 72), Position = new Position(80, 290) }; addBtn.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount < 3) { tabCount++; var newTabButton = new TabButton() { Text = "Tab#" + tabCount.ToString() }; var newContent = new TextLabel() { Text = "Content#" + tabCount.ToString(), WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; switch (tabCount) { case 1: newContent.BackgroundColor = Color.Red; break; case 2: newContent.BackgroundColor = Color.Green; break; default: newContent.BackgroundColor = Color.Blue; break; } tabView.AddTab(newTabButton, newContent); } }; window.Add(addBtn); removeBtn = new Button() { Text = "-Tab", Size = new Size(100, 72), Position = new Position(180, 290), }; removeBtn.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount > 0) { tabCount--; tabView.RemoveTab(tabCount); } }; window.Add(removeBtn); }
private View CreateView() { Color backgroundColor; Color buttonBackgroundColor; if ((tabCount + 1) % maxTabCount == colorOne) { backgroundColor = Color.DarkGreen; buttonBackgroundColor = Color.Green; } else if ((tabCount + 1) % maxTabCount == colorTwo) { backgroundColor = Color.DarkRed; buttonBackgroundColor = Color.Red; } else if ((tabCount + 1) % maxTabCount == colorThree) { backgroundColor = Color.DarkBlue; buttonBackgroundColor = Color.Blue; } else { backgroundColor = Color.SaddleBrown; buttonBackgroundColor = Color.Orange; } var container = new View() { Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, CellPadding = new Size2D(0, 20), }, BackgroundColor = backgroundColor, WidthSpecification = LayoutParamPolicies.MatchParent, HeightSpecification = LayoutParamPolicies.MatchParent, }; var buttonAddTab = new Button() { Text = "Add Tab", BackgroundColor = buttonBackgroundColor, }; buttonAddTab.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount < maxTabCount) { tabView.AddTab(CreateTabButton(), CreateView()); tabCount++; } }; container.Add(buttonAddTab); var buttonRemoveTab = new Button() { Text = "Remove Tab", BackgroundColor = buttonBackgroundColor, }; buttonRemoveTab.Clicked += (object sender, ClickedEventArgs args) => { if (tabCount > 1) { tabView.RemoveTab(tabCount - 1); tabCount--; } }; container.Add(buttonRemoveTab); return(container); }