public TravelViewModel() { Travel = new TravelHelper(); Title = Consts.TRAVEL_TITLE_NEW; _type = PanelType.New; IsBackButtonVisible = false; }
public Panel(Panel panel) { type = panel.type; size = panel.size; height = panel.height; heightOffset = panel.heightOffset; }
void onPanelSwitched(PanelType panel) { if (activePanelType == panel) return; activePanelType = panel; refreshPanelStates(); }
public void ShowPanel(PanelType panelType, params object[] panelArgs) { if (panels.ContainsKey(panelType)) { current = panels[panelType]; current.gameObject.SetActive(false); current.OnInit(panelArgs); } else { GameObject scene = new GameObject(panelType.ToString()); current = scene.AddComponent(Type.GetType(panelType.ToString())) as PanelBase; current.gameObject.SetActive(false); current.OnInit(panelArgs); panels.Add(panelType, current); if (parentObj == null) { parentObj = GameObject.Find("UI Root").transform; } scene.transform.parent = parentObj; scene.transform.localEulerAngles = Vector3.zero; scene.transform.localScale = Vector3.one; scene.transform.localPosition = Vector3.zero; LayerMgr.GetInstance().SetLayer(current.gameObject, LayerType.Panel); } StartShowPanel(current, current.PanelShowStyle, true); }
public MainPage(PanelType pt) { InitializeComponent(); LoadControl(); NavigatedTo(null, pt); this.LayoutUpdated += new EventHandler(MainPage_LayoutUpdated); }
public override void Init() { base.Init(); attachPanels(); addListeners(); activePanelType = PanelType.PLAY; refreshPanelStates(); }
public void ChangePanelContents(UIViewController newChildView, PanelType type) { var activePanel = GetPanel(type); if (activePanel != null) activePanel.SwapChildView(newChildView, type); else DisplayNewChildView(newChildView, type); }
public void Open(PanelType type, PanelParamBase panelParam, PanelEffectType effectType, int depth) { this.ThisPanel = type; this.SetPanelDepth(depth); if (!this.IsInit) this.Init(); this.InitPanel(); this.Open(panelParam); this.PlayEffect(effectType); }
internal PanelSpecification(IApi platform) { panelPhysicalSize = platform.sys_GetPrimaryPanelPhysicalSize (); panelPhysicalAspectRatio = panelPhysicalSize.HasValue ? (Single) panelPhysicalSize.Value.X / (Single) panelPhysicalSize.Value.Y : (Single?) null; panelType = platform.sys_GetPrimaryPanelType (); }
public ReportTool() { InitializeComponent(); showHighSeverity = true; showMediumSeverity = true; showLowSeverity = true; errorList = new List<WipeError>(); activePanel = PanelType.Errors; }
/// <summary> /// 调用父类的导航 /// </summary> /// <param name="owen">自己的类型</param> /// <param name="pt">导航到的类型</param> public static void BaseNavigate(Control own, PanelType pt) { own.Dispatcher.BeginInvoke(() => { MainPage mp = ((Grid)own.Parent).Parent as MainPage; if (mp != null) { mp.NavigatedTo(own, pt); } }); }
/// <summary> /// 导航到 /// </summary> /// <param name="to"></param> public void NavigatedTo(Control from, PanelType to) { FromControl = from; ToControl = ResourceMgr.CachePanel[to]; //属性 ResetToPt(ToControl, -1200, 0); ((IMyControl)ToControl).ControlVisible(); ToControl.UpdateLayout(); CreateSb(ToControl, FromControl); }
private UIBarButtonItem CreateSliderButton(string imageName, PanelType panelType) { var button = new UIBarButtonItem(UIImage.FromBundle(imageName).Scale(new SizeF(20,20)), UIBarButtonItemStyle.Plain, (s,e) => { SlidingPanelsNavigationViewController navController = NavigationController as SlidingPanelsNavigationViewController; navController.TogglePanel(panelType); }); return button; }
private UIBarButtonItem CreateSliderButton(string imageName, PanelType panelType) { UIButton button = new UIButton(new RectangleF(0, 0, 40f, 40f)); button.SetBackgroundImage(UIImage.FromBundle(imageName), UIControlState.Normal); button.TouchUpInside += delegate { SlidingPanelsNavigationViewController navController = NavigationController as SlidingPanelsNavigationViewController; navController.TogglePanel(panelType); }; return new UIBarButtonItem(button); }
public static LandingPagePanel Create(PanelType type = PanelType.Tile) { switch (type) { case PanelType.Tile: return new LandingPagePanel(); case PanelType.Intro: return new IntroPanel(); case PanelType.Picture: return new PicturePanel(); case PanelType.Video: return new VideoPanel(); case PanelType.Form: return new FormPanel(); case PanelType.Article: return new ArticlePanel(); case PanelType.PictureTile: return new PictureTile(); default: return new LandingPagePanel(); } }
public void OpenPanel(PanelType p) { Panel panel = GetPanel(p); if (panel == null) { return; } if (panelStack.Count > 0) panelStack.Peek().Hide(); panelStack.Push(panel); panel.Open(); }
public Panel(string title, PanelType? panelType = null, Colors? color = null, IDictionary<string, object> htmlAttributes = null) : base("div") { EnsureClass("panel"); if (panelType != null) EnsureClass(string.Format("panel-{0}", panelType.ToName())); if (color != null) EnsureClass(string.Format("panel-{0}", color.ToName())); if (htmlAttributes != null) this.htmlAttributes = htmlAttributes; }
public override IPanel ShowPanel(PanelType panelType) { IPanel panel = null; switch (panelType) { case PanelType.Default: break; case PanelType.LoginPanel: panel = LoadPanel("UI/Login/LoginPanel", panelType, null, 0); panel.Show(); break; } return panel; }
public void ClosePanel(PanelType p) { string panelName = Enum.GetName(typeof(PanelType), p).ToLower(); Panel panel = panelStack.Peek(); if (panel.name != panelName) { Debug.LogError( "You can only close panels at the top of the stack!" + string.Format("Current panel: {0}, panel to close: {1}", panel.name, panelName)); return; } panelStack.Pop(); panel.Close(); if (panelStack.Count > 0) panelStack.Peek().Show(); }
private Panel GetPanel(PanelType p) { string panelName = Enum.GetName(typeof(PanelType), p).ToLower(); GameObject prefab = Resources.Load<GameObject>("Panels/" + panelName); if (prefab == null) { Debug.LogError("Can't find panel with name: " + panelName); } GameObject panelObj = GameObject.Instantiate<GameObject>(prefab); panelObj.transform.SetParent(this.transform, false); panelObj.name = panelName; Panel panel = panelObj.GetComponent<Panel>(); if (panel == null) { Debug.LogError(panelName + " doesn't have a panel component"); } return panel; }
public virtual void SwapChildView(UIViewController newChildView, PanelType type) { if (newChildView == null) return; newChildView.View.Frame = CreateChildViewPosition(); if (PanelView == null) { AddChildViewController(newChildView); View.AddSubview(newChildView.View); } else { AddChildViewController(newChildView); View.AddSubview(newChildView.View); newChildView.WillMoveToParentViewController(null); TransitionPanel(newChildView); } }
public PanelScope(HtmlHelper html, PanelType panelType) { this.html = html; string panelClass = string.Empty; switch (panelType) { case PanelType.Highlight: panelClass = "ui-state-highlight "; break; case PanelType.Error: panelClass = "ui-state-error "; break; } html.ViewContext.Writer.WriteLine( "<div class=\"ui-widget\">" + "<div class=\"" + panelClass + " ui-corner-all panel\">" ); }
public static AccordionPanel Make(string headerText, string subtext, string id, PanelType type) { AccordionPanel accor = new AccordionPanel(); accor.id = id; accor.PType = type; jQuery c = new jQuery("<div>"); if (!string.IsNullOrEmpty(headerText)) c.Append(new jQuery("<h2>").Html(headerText)); if (!string.IsNullOrEmpty(subtext)) c.Append(new jQuery("<h4>").Html(subtext)); accor.PanelGroup = new jQuery("<div>").AddClass("panel-group").Attr("id", id); c.Append(accor.PanelGroup); accor.MainContainer = c; return accor; }
private string ConvertToDisplayValue(PanelType panelType) { // TODO: do cooler things than a string display string convertedResult; switch (panelType) { case PanelType.Unknown: convertedResult = String.Empty; break; case PanelType.Miss: convertedResult = "-"; break; case PanelType.Hit: convertedResult = "X"; break; case PanelType.AircraftCarrier: convertedResult = "A"; break; case PanelType.Battleship: convertedResult = "B"; break; case PanelType.Submarine: convertedResult = "S"; break; case PanelType.Cruiser: convertedResult = "C"; break; case PanelType.PatrolBoat: convertedResult = "P"; break; default: throw new ArgumentOutOfRangeException("panelType"); } return convertedResult; }
/// <summary> /// Switchs the scene. /// </summary> /// <returns>返回当前创建的Gameobject</returns> /// <param name="name">要创建的资源路径</param> /// <param name="objParams">可变参数</param> public void ShowPanel(PanelType panelType, params object[] objParams)//GameObject { //GameObject obj = ResourceMsg.GetInstance ().CreateGameObject (name, cache); string name = panelType.ToString(); GameObject go = new GameObject(name); PanelBase scene = go.AddComponent(Type.GetType(name)) as PanelBase; scene.Init(); if (parentObj == null) { //此处写法欠妥,还需要改进 parentObj = GameObject.Find("UI Root").transform; } go.transform.SetParent(parentObj); go.transform.localEulerAngles = Vector3.zero; go.transform.localScale = Vector3.one; go.transform.localPosition = Vector3.zero; currentShow = go; ShowPanelStyle(go); LayerMgr.GetInstance().SetLayer(go, LayerType.Panel); }
public Panel(HtmlHelper htmlHelper, PanelType panelType = PanelType.basic, string heading = "", string title = "", string titleTag = "h3", string footer = "", dynamic attributes = null) : base(htmlHelper) { var writer = htmlHelper.ViewContext.Writer; var panelContainer = new TagBuilder("div"); panelContainer.MergeAttributes<string, object>(attributes); if (panelType == PanelType.basic) panelContainer.AddCssClass("panel-default"); else panelContainer.AddCssClass("panel-" + panelType); panelContainer.AddCssClass("panel"); writer.WriteLine(panelContainer.ToString(TagRenderMode.StartTag)); if (!string.IsNullOrEmpty(heading) || !string.IsNullOrEmpty(title)) { var headingDiv = new TagBuilder("div"); headingDiv.AddCssClass("panel-heading"); writer.Write(headingDiv.ToString(TagRenderMode.StartTag)); if (!string.IsNullOrEmpty(title)) { writer.WriteLine(); var titleTagBuilder = new TagBuilder(titleTag); titleTagBuilder.AddCssClass("panel-title"); titleTagBuilder.SetInnerText(title); writer.WriteLine(titleTagBuilder.ToString()); } else if (!string.IsNullOrEmpty(heading)) { writer.Write(heading); } writer.WriteLine(headingDiv.ToString(TagRenderMode.EndTag)); } writer.WriteLine("<div class=\"panel-body\">"); }
/// <summary> /// Constructor /// </summary> /// <param name="plugInId"></param> /// <param name="type"></param> /// <param name="englishCaption"></param> /// <param name="localCaption"></param> /// <param name="icon"></param> /// <param name="panelType"></param> internal PanelDefinition(Guid plugInId, Type type, string englishCaption, string localCaption, Icon icon, PanelType panelType) { PlugInId = plugInId; Id = type.GUID; Type = type; EnglishCaption = englishCaption; LocalCaption = localCaption; Icon = icon; PanelType = panelType; switch (panelType) { case PanelType.PerDoc: m_document_containers = new Dictionary <uint, PanelContainers>(); break; case PanelType.System: m_system_containers = new PanelContainers(); break; } }
/// <summary> /// Call once to register a panel type which will get dynamically created /// and embedded in a Rhino docking/floating location. /// </summary> /// <param name="plugIn"> /// Plug-in restringing the panel /// </param> /// <param name="type"> /// Type of the control object to be displayed in the panel /// </param> /// <param name="caption"> /// Panel caption also used as a tool-tip. On Windows the panel may be /// displayed using the icon, caption or both. On Mac the icon will be /// used and the caption will be the tool-tip. /// </param> /// <param name="icon"> /// The panel icon. On Windows the panel may be displayed using the icon, /// caption or both. On Mac the icon will be used and the caption will be /// the tool-tip. /// </param> /// <param name="panelType"> /// See <see cref="PanelType"/> /// </param> public static void Register(PlugIns.PlugIn plugIn, Type type, string caption, Icon icon, PanelType panelType) { // Plug-in that owns the panel, currently required. Investigate changing to // System.Reflection.Assembly to allow Rhino.UI to register panels directly if (plugIn == null) { throw new ArgumentNullException(nameof(plugIn)); } Register(GetPlugInId(plugIn), type, caption, icon, panelType); }
public void DrawHotReLoadUI() { GUILayout.BeginHorizontal("HelpBox"); EditorGUILayout.LabelField("== 热重载 =="); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("重载配置表", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30))) { SettingsManager.AllSettingsReload(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("快速编译配置表", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30))) { SettingModuleEditor.QuickCompileSettings(); } if (GUILayout.Button("编译配置表并生成代码", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30))) { SettingModuleEditor.CompileSettings(); } GUILayout.EndHorizontal(); #if xLua || SLUA GUILayout.BeginHorizontal(); if (GUILayout.Button("重载所有UI的Lua代码", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30))) { KSFrameworkEditor.ReloadAllUIScript(); } if (GUILayout.Button("重新打开所有UI", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30))) { KSFrameworkEditor.ReloadAllUI(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("UI名字:", GUILayout.Width(40)); reloadUIScript = EditorGUILayout.TextField(reloadUIScript, GUILayout.MinWidth(120), GUILayout.MaxHeight(30)); panelType = (PanelType)EditorGUILayout.EnumPopup("", panelType, GUILayout.MinWidth(80), GUILayout.MinHeight(30)); if (panelType != PanelType.HeadInfoUI && Application.isPlaying) { topUI = UIModule.Instance.GetTopUI(panelType); Log.Info($"now top ui:{topUI?.UIName}"); if (topUI != null) { reloadUIScript = topUI.UIName; } } if (GUILayout.Button("重载Lua脚本", GUILayout.MinWidth(100), GUILayout.MaxHeight(30))) { KSFrameworkEditor.ReloadUIScript(reloadUIScript); } GUILayout.EndHorizontal(); #endif GUILayout.Space(10); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("UI名字:", GUILayout.Width(40)); reloadUIAb = EditorGUILayout.TextField(reloadUIAb, GUILayout.MinWidth(120), GUILayout.MaxHeight(30)); if (GUILayout.Button("重载AB并打开", GUILayout.MinWidth(100), GUILayout.MaxHeight(30))) { KSFrameworkEditor.ReloadUIAB(reloadUIAb); } GUILayout.EndHorizontal(); //GUILayout.Space(10); }
internal LobbyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, OrderManager orderManager, Action onExit, Action onStart, bool skirmishMode) { map = MapCache.UnknownMap; lobby = widget; this.modData = modData; this.orderManager = orderManager; this.onStart = onStart; this.onExit = onExit; this.skirmishMode = skirmishMode; // TODO: This needs to be reworked to support per-map tech levels, bots, etc. this.modRules = modData.DefaultRules; shellmapWorld = worldRenderer.World; services = modData.Manifest.Get <WebServices>(); orderManager.AddChatLine += AddChatLine; Game.LobbyInfoChanged += UpdateCurrentMap; Game.LobbyInfoChanged += UpdatePlayerList; Game.BeforeGameStart += OnGameStart; Game.ConnectionStateChanged += ConnectionStateChanged; var name = lobby.GetOrNull <LabelWidget>("SERVER_NAME"); if (name != null) { name.GetText = () => orderManager.LobbyInfo.GlobalSettings.ServerName; } Ui.LoadWidget("MAP_PREVIEW", lobby.Get("MAP_PREVIEW_ROOT"), new WidgetArgs { { "orderManager", orderManager }, { "getMap", (Func <MapPreview>)(() => map) }, { "onMouseDown", (Action <MapPreviewWidget, MapPreview, MouseInput>)((preview, mapPreview, mi) => LobbyUtils.SelectSpawnPoint(orderManager, preview, mapPreview, mi)) }, { "getSpawnOccupants", (Func <MapPreview, Dictionary <CPos, SpawnOccupant> >)(mapPreview => LobbyUtils.GetSpawnOccupants(orderManager.LobbyInfo, mapPreview)) }, { "showUnoccupiedSpawnpoints", true }, }); UpdateCurrentMap(); var playerBin = Ui.LoadWidget("LOBBY_PLAYER_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); playerBin.IsVisible = () => panel == PanelType.Players; players = playerBin.Get <ScrollPanelWidget>("LOBBY_PLAYERS"); editablePlayerTemplate = players.Get("TEMPLATE_EDITABLE_PLAYER"); nonEditablePlayerTemplate = players.Get("TEMPLATE_NONEDITABLE_PLAYER"); emptySlotTemplate = players.Get("TEMPLATE_EMPTY"); editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR"); nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR"); newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR"); colorPreview = lobby.Get <ColorPreviewManagerWidget>("COLOR_MANAGER"); colorPreview.Color = Game.Settings.Player.Color; foreach (var f in modRules.Actors["world"].TraitInfos <FactionInfo>()) { factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description }); } var gameStarting = false; Func <bool> configurationDisabled = () => !Game.IsHost || gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart || !map.RulesLoaded || map.InvalidCustomRules || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; var mapButton = lobby.GetOrNull <ButtonWidget>("CHANGEMAP_BUTTON"); if (mapButton != null) { mapButton.IsDisabled = () => gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; mapButton.OnClick = () => { var onSelect = new Action <string>(uid => { // Don't select the same map again if (uid == map.Uid) { return; } orderManager.IssueOrder(Order.Command("map " + uid)); Game.Settings.Server.Map = uid; Game.Settings.Save(); }); Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() { { "initialMap", map.Uid }, { "initialTab", MapClassification.System }, { "onExit", DoNothing }, { "onSelect", Game.IsHost ? onSelect : null }, { "filter", MapVisibility.Lobby }, }); }; } var slotsButton = lobby.GetOrNull <DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON"); if (slotsButton != null) { slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players || (orderManager.LobbyInfo.Slots.Values.All(s => !s.AllowBots) && orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) == 0); slotsButton.OnMouseDown = _ => { var botTypes = map.Rules.Actors["player"].TraitInfos <IBotInfo>().Select(t => t.Type); var options = new Dictionary <string, IEnumerable <DropDownOption> >(); var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); if (orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots)) { var botOptions = new List <DropDownOption>() { new DropDownOption() { Title = "Add", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var bot = botTypes.Random(Game.CosmeticRandom); var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (slot.Value.AllowBots == true && (c == null || c.Bot != null)) { orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot.Key, botController.Index, bot))); } } } } }; if (orderManager.LobbyInfo.Clients.Any(c => c.Bot != null)) { botOptions.Add(new DropDownOption() { Title = "Remove", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (c != null && c.Bot != null) { orderManager.IssueOrder(Order.Command("slot_open " + slot.Value.PlayerReference)); } } } }); } options.Add("Configure Bots", botOptions); } var teamCount = (orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) + 1) / 2; if (teamCount >= 1) { var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption { Title = "{0} Teams".F(d), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams {0}".F(d.ToString()))) }).ToList(); if (orderManager.LobbyInfo.Slots.Any(s => s.Value.AllowBots)) { teamOptions.Add(new DropDownOption { Title = "Humans vs Bots", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 1")) }); } teamOptions.Add(new DropDownOption { Title = "Free for all", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 0")) }); options.Add("Configure Teams", teamOptions); } Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; slotsButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 175, options, setupItem); }; } var optionsBin = Ui.LoadWidget("LOBBY_OPTIONS_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); optionsBin.IsVisible = () => panel == PanelType.Options; var musicBin = Ui.LoadWidget("LOBBY_MUSIC_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs { { "onExit", DoNothing }, { "world", worldRenderer.World } }); musicBin.IsVisible = () => panel == PanelType.Music; var optionsTab = lobby.Get <ButtonWidget>("OPTIONS_TAB"); optionsTab.IsHighlighted = () => panel == PanelType.Options; optionsTab.IsDisabled = () => !map.RulesLoaded || map.InvalidCustomRules || panel == PanelType.Kick || panel == PanelType.ForceStart; optionsTab.OnClick = () => panel = PanelType.Options; var playersTab = lobby.Get <ButtonWidget>("PLAYERS_TAB"); playersTab.IsHighlighted = () => panel == PanelType.Players; playersTab.IsDisabled = () => panel == PanelType.Kick || panel == PanelType.ForceStart; playersTab.OnClick = () => panel = PanelType.Players; var musicTab = lobby.Get <ButtonWidget>("MUSIC_TAB"); musicTab.IsHighlighted = () => panel == PanelType.Music; musicTab.IsDisabled = () => panel == PanelType.Kick || panel == PanelType.ForceStart; musicTab.OnClick = () => panel = PanelType.Music; // Force start panel Action startGame = () => { gameStarting = true; orderManager.IssueOrder(Order.Command("startgame")); }; var startGameButton = lobby.GetOrNull <ButtonWidget>("START_GAME_BUTTON"); if (startGameButton != null) { startGameButton.IsDisabled = () => configurationDisabled() || map.Status != MapStatus.Available || orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null) || (!orderManager.LobbyInfo.GlobalSettings.EnableSingleplayer && orderManager.LobbyInfo.NonBotPlayers.Count() < 2); startGameButton.OnClick = () => { // Bots and admins don't count if (orderManager.LobbyInfo.Clients.Any(c => c.Slot != null && !c.IsAdmin && c.Bot == null && !c.IsReady)) { panel = PanelType.ForceStart; } else { startGame(); } }; } var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); forceStartBin.IsVisible = () => panel == PanelType.ForceStart; forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid); forceStartBin.Get <ButtonWidget>("OK_BUTTON").OnClick = startGame; forceStartBin.Get <ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players; // Options panel var optionCheckboxes = new Dictionary <string, string>() { { "EXPLORED_MAP_CHECKBOX", "explored" }, { "CRATES_CHECKBOX", "crates" }, { "SHORTGAME_CHECKBOX", "shortgame" }, { "FOG_CHECKBOX", "fog" }, { "ALLYBUILDRADIUS_CHECKBOX", "allybuild" }, { "ALLOWCHEATS_CHECKBOX", "cheats" }, { "CREEPS_CHECKBOX", "creeps" }, }; foreach (var kv in optionCheckboxes) { var checkbox = optionsBin.GetOrNull <CheckboxWidget>(kv.Key); if (checkbox != null) { var option = new CachedTransform <Session.Global, Session.LobbyOptionState>( gs => gs.LobbyOptions[kv.Value]); var visible = new CachedTransform <Session.Global, bool>( gs => gs.LobbyOptions.ContainsKey(kv.Value)); checkbox.IsVisible = () => visible.Update(orderManager.LobbyInfo.GlobalSettings); checkbox.IsChecked = () => option.Update(orderManager.LobbyInfo.GlobalSettings).Enabled; checkbox.IsDisabled = () => configurationDisabled() || option.Update(orderManager.LobbyInfo.GlobalSettings).Locked; checkbox.OnClick = () => orderManager.IssueOrder(Order.Command( "option {0} {1}".F(kv.Value, !option.Update(orderManager.LobbyInfo.GlobalSettings).Enabled))); } } var optionDropdowns = new Dictionary <string, string>() { { "TECHLEVEL", "techlevel" }, { "STARTINGUNITS", "startingunits" }, { "STARTINGCASH", "startingcash" }, { "DIFFICULTY", "difficulty" }, { "GAMESPEED", "gamespeed" } }; var allOptions = new CachedTransform <MapPreview, LobbyOption[]>( mapPreview => mapPreview.Rules.Actors["player"].TraitInfos <ILobbyOptions>() .Concat(mapPreview.Rules.Actors["world"].TraitInfos <ILobbyOptions>()) .SelectMany(t => t.LobbyOptions(mapPreview.Rules)) .ToArray()); foreach (var kv in optionDropdowns) { var dropdown = optionsBin.GetOrNull <DropDownButtonWidget>(kv.Key + "_DROPDOWNBUTTON"); if (dropdown != null) { var optionValue = new CachedTransform <Session.Global, Session.LobbyOptionState>( gs => gs.LobbyOptions[kv.Value]); var option = new CachedTransform <MapPreview, LobbyOption>( mapPreview => allOptions.Update(mapPreview).FirstOrDefault(o => o.Id == kv.Value)); var getOptionLabel = new CachedTransform <string, string>(id => { string value; if (id == null || !option.Update(map).Values.TryGetValue(id, out value)) { return("Not Available"); } return(value); }); dropdown.GetText = () => getOptionLabel.Update(optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Value); dropdown.IsVisible = () => option.Update(map) != null; dropdown.IsDisabled = () => configurationDisabled() || optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Locked; dropdown.OnMouseDown = _ => { Func <KeyValuePair <string, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (c, template) => { Func <bool> isSelected = () => optionValue.Update(orderManager.LobbyInfo.GlobalSettings).Value == c.Key; Action onClick = () => orderManager.IssueOrder(Order.Command("option {0} {1}".F(kv.Value, c.Key))); var item = ScrollItemWidget.Setup(template, isSelected, onClick); item.Get <LabelWidget>("LABEL").GetText = () => c.Value; return(item); }; var options = option.Update(map).Values; dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; var label = optionsBin.GetOrNull(kv.Key + "_DESC"); if (label != null) { label.IsVisible = () => option.Update(map) != null; } } } var disconnectButton = lobby.Get <ButtonWidget>("DISCONNECT_BUTTON"); disconnectButton.OnClick = () => { Ui.CloseWindow(); onExit(); }; if (skirmishMode) { disconnectButton.Text = "Back"; } var globalChat = Game.LoadWidget(null, "LOBBY_GLOBALCHAT_PANEL", lobby.Get("GLOBALCHAT_ROOT"), new WidgetArgs()); var globalChatInput = globalChat.Get <TextFieldWidget>("CHAT_TEXTFIELD"); globalChat.IsVisible = () => chatPanel == ChatPanelType.Global; var globalChatTab = lobby.Get <ButtonWidget>("GLOBALCHAT_TAB"); globalChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Global; globalChatTab.OnClick = () => { chatPanel = ChatPanelType.Global; globalChatInput.TakeKeyboardFocus(); }; var globalChatLabel = globalChatTab.Text; globalChatTab.GetText = () => { if (globalChatUnreadMessages == 0 || chatPanel == ChatPanelType.Global) { return(globalChatLabel); } return(globalChatLabel + " ({0})".F(globalChatUnreadMessages)); }; globalChatLastReadMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message); var lobbyChat = lobby.Get("LOBBYCHAT"); lobbyChat.IsVisible = () => chatPanel == ChatPanelType.Lobby; chatLabel = lobby.Get <LabelWidget>("LABEL_CHATTYPE"); var chatTextField = lobby.Get <TextFieldWidget>("CHAT_TEXTFIELD"); chatTextField.MaxLength = UnitOrders.ChatMessageMaxLength; chatTextField.TakeKeyboardFocus(); chatTextField.OnEnterKey = () => { if (chatTextField.Text.Length == 0) { return(true); } // Always scroll to bottom when we've typed something lobbyChatPanel.ScrollToBottom(); orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text)); chatTextField.Text = ""; return(true); }; chatTextField.OnTabKey = () => { var previousText = chatTextField.Text; chatTextField.Text = tabCompletion.Complete(chatTextField.Text); chatTextField.CursorPosition = chatTextField.Text.Length; if (chatTextField.Text == previousText) { return(SwitchTeamChat()); } else { return(true); } }; chatTextField.OnEscKey = () => { chatTextField.Text = ""; return(true); }; var lobbyChatTab = lobby.Get <ButtonWidget>("LOBBYCHAT_TAB"); lobbyChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Lobby; lobbyChatTab.OnClick = () => { chatPanel = ChatPanelType.Lobby; chatTextField.TakeKeyboardFocus(); }; var lobbyChatLabel = lobbyChatTab.Text; lobbyChatTab.GetText = () => { if (lobbyChatUnreadMessages == 0 || chatPanel == ChatPanelType.Lobby) { return(lobbyChatLabel); } return(lobbyChatLabel + " ({0})".F(lobbyChatUnreadMessages)); }; lobbyChatPanel = lobby.Get <ScrollPanelWidget>("CHAT_DISPLAY"); chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE"); lobbyChatPanel.RemoveChildren(); var settingsButton = lobby.GetOrNull <ButtonWidget>("SETTINGS_BUTTON"); if (settingsButton != null) { settingsButton.OnClick = () => Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs { { "onExit", DoNothing }, { "worldRenderer", worldRenderer } }); } // Add a bot on the first lobbyinfo update if (skirmishMode) { addBotOnMapLoad = true; } }
/// <summary> /// Fired when the memory manager wants some memory back. Lets see if we can help him out. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MemoryMan_OnMemoryCleanUpRequest(object sender, Managers.OnMemoryCleanupRequestArgs e) { // Memory pressure // Low - Only clean up pages that are very old and user forgot about // Medium - Clean up pages that are older and the user hopefully forgot about // High - Clean up just about everything we can. List <IPanel> cleanupPanelList = new List <IPanel>(); lock (m_panelStack) { if (m_state != State.Idle && e.CurrentPressure != MemoryPressureStates.HighNoAllocations) { // If we are not idle return unless we are high, then // we will take our chances. return; } // Figure out how many panels we need to keep. int minNumHistoryPages = 0; switch (e.CurrentPressure) { default: case MemoryPressureStates.None: case MemoryPressureStates.VeryLow: minNumHistoryPages = c_veryLowMemoryHistoryPagesLimit; break; case MemoryPressureStates.Low: minNumHistoryPages = c_lowMemoryHistoryPagesLimit; break; case MemoryPressureStates.Medium: minNumHistoryPages = c_mediumMemoryHistoryPagesLimit; break; case MemoryPressureStates.HighNoAllocations: minNumHistoryPages = c_highMemoryHistoryPagesLimit; break; } // Do a quick check to ensure we can do work. // Panel count - 4 (worse case we have 4 we have to keep) is the worse case # of history pages. (this can be (-)) // If that count is less then the min just return because we have nothing to do. if (m_panelStack.Count - 4 < minNumHistoryPages) { return; } // First find the most recent subreddit panel and the panel we are looking at. // If we are in split view we will always have two, if in single view we will only have one. Tuple <Type, string> currentPanel = null; PanelType currentPanelPanelType = PanelType.None; Tuple <Type, string> splitViewOtherCurrentPanel = null; for (int count = m_panelStack.Count - 1; count > 0; count--) { StackItem item = m_panelStack[count]; // If this is first this is what we are looking at. if (currentPanel == null) { currentPanel = new Tuple <Type, string>(item.Panel.GetType(), item.Id); currentPanelPanelType = GetPanelType(item.Panel); // If we are in single mode we only care about the first one. if (m_screenMode == ScreenMode.Single) { break; } } else { // If we get here we are in split view and are looking for the latest panel that is not the same type as the current panel. if (GetPanelType(item.Panel) != currentPanelPanelType) { splitViewOtherCurrentPanel = new Tuple <Type, string>(item.Panel.GetType(), item.Id); break; } } } // Check that we are good. if (currentPanel == null) { return; } // We will always keep the welcome screen, the first subreddit. // We also might need to keep the two visible panels, but they might also be the same. int numRequiredPages = 2; // Now loop though all of the panels and kill them. for (int count = 0; count < m_panelStack.Count; count++) { StackItem item = m_panelStack[count]; if ((item.Panel as WelcomePanel) != null) { // This is the welcome panel, skip continue; } else if (count == 1 && (item.Panel as SubredditPanel) != null) { // If this subreddit isn't the first visible panel we have one more required page. if (!item.Id.Equals(currentPanel.Item2) || !item.Panel.GetType().Equals(currentPanel.Item1)) { numRequiredPages++; } // If this subreddit also isn't the second visible panel we have one more required page. if (splitViewOtherCurrentPanel != null && (!item.Id.Equals(splitViewOtherCurrentPanel.Item2) || !item.Panel.GetType().Equals(splitViewOtherCurrentPanel.Item1))) { numRequiredPages++; } // Skip the first subreddit panel also. continue; } // Check if we are done, if our list is smaller than req + min history. if (m_panelStack.Count <= minNumHistoryPages + numRequiredPages) { break; } if (item.Id.Equals(currentPanel.Item2) && item.Panel.GetType().Equals(currentPanel.Item1)) { // If this is visible panel 1 don't kill it. continue; } if (splitViewOtherCurrentPanel != null && item.Id.Equals(splitViewOtherCurrentPanel.Item2) && item.Panel.GetType().Equals(splitViewOtherCurrentPanel.Item1)) { // If this is visible panel 2 don't kill it. continue; } // We found one we can kill from the list and back down the count. m_panelStack.RemoveAt(count); count--; // Now make sure there isn't another instance of it in the list, if so don't add // it to the clean up list. bool addToCleanUp = true; foreach (StackItem searchItem in m_panelStack) { if (item.Id.Equals(searchItem.Id) && item.Panel.GetType().Equals(searchItem.Panel.GetType())) { addToCleanUp = false; break; } } if (addToCleanUp) { cleanupPanelList.Add(item.Panel); } } } // Now that we are out of lock, delete the panels if we have any. if (cleanupPanelList.Count > 0) { // Keep track of how many pages have been cleaned up. App.BaconMan.UiSettingsMan.PagesMemoryCleanedUp += cleanupPanelList.Count; // Jump to the UI thread to do this. await global::Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { foreach (IPanel panel in cleanupPanelList) { // Fire cleanup on the panel FireOnCleanupPanel(panel); } // Also update the back button. UpdateBackButton(); }); } }
/// <summary> /// Navigates to a panel. If a panel already exist with the same panelId instead or creating a new /// panel the old panel will be shown and passed the new arguments. /// </summary> /// <param name="panelType">The type of panel to be created</param> /// <param name="panelId">A unique identifier for the panel, the id should be able to differeincae between two panels of the same type</param> /// <param name="arguments">Arguments to be sent to the panel</param> /// <returns></returns> public bool Navigate(Type panelType, string panelId, Dictionary <string, object> arguments = null) { if (panelType == null) { throw new Exception("Panel type can't be null!"); } // Make sure we send args along. if (arguments == null) { arguments = new Dictionary <string, object>(); } // Clear this value m_finalNavigateHasShownMenu = false; bool isExitingPanel = false; StackItem navigateFromPanel = null; StackItem panelToReduceMemory = null; lock (m_panelStack) { // For now we can only do one animation at a time. So if we are doing something we // must ignore this if (m_state != State.Idle) { return(false); } // The panel we will navigate to StackItem navigateToPanel = null; // First, check to see if we already have the panel foreach (StackItem item in m_panelStack) { if (item.Panel.GetType() == panelType && item.Id == panelId) { // We found it. isExitingPanel = true; navigateToPanel = item; break; } } // If we didn't find it make a new panel. if (navigateToPanel == null) { navigateToPanel = new StackItem(); navigateToPanel.Panel = (IPanel)Activator.CreateInstance(panelType); navigateToPanel.Id = panelId; } // Check the type PanelType newPanelType = GetPanelType(navigateToPanel.Panel); // Second, Figure out what panel will be leaving. if (m_screenMode == ScreenMode.Single) { // If we are in single mode it will be the panel from the top of the stack if (m_panelStack.Count > 0) { navigateFromPanel = m_panelStack.Last(); } } else { // If we are in split mode it will be the panel we will replace. // So go through the list backwards and find it. foreach (StackItem item in m_panelStack.Reverse <StackItem>()) { // If the are both subreddit panels or both not, we found the panel. if (GetPanelType(item.Panel) == newPanelType) { navigateFromPanel = item; break; } } } // We need to type of the leaving panel. If the panel is null this // is the first navigation of a type, so we will just call it the content panel. PanelType navigateFromPanelType = PanelType.ContentPanel; if (navigateFromPanel != null) { navigateFromPanelType = GetPanelType(navigateFromPanel.Panel); } // Third, Setup the panel. If it already exits call activate instead of setup. if (isExitingPanel) { navigateToPanel.Panel.OnPanelPulledToTop(arguments); } else { navigateToPanel.Panel.PanelSetup(this, arguments); } // Special case! If the UI is already shown then we should just return here. if (navigateFromPanel != null && navigateFromPanel.Panel.GetType() == navigateToPanel.Panel.GetType() && navigateFromPanel.Id == navigateToPanel.Id) { return(true); } // Last, add the panel to the bottom of the list. // Note if this existing the panel will be in the list twice! m_panelStack.Add(navigateToPanel); // Check if there is someone we should ask to reduce memory if (m_panelStack.Count > (c_numberOfHistoryPagesBeforeMemoryReduce + 1)) { panelToReduceMemory = m_panelStack[m_panelStack.Count - (c_numberOfHistoryPagesBeforeMemoryReduce + 1)]; // This can only happen in split mode. if (m_screenMode == ScreenMode.Split) { // We need to make sure this panel isn't visible PanelType reducePanelType = GetPanelType(panelToReduceMemory.Panel); for (int count = m_panelStack.Count - 1; count >= 0; count--) { // Find the first panel of this type and make sure it isn't this panel StackItem item = m_panelStack[count]; if (GetPanelType(item.Panel) == reducePanelType) { if (item.Id.Equals(panelToReduceMemory.Id) && item.Panel.GetType() == panelToReduceMemory.Panel.GetType()) { // This is the panel thus it is visible. Just null out the var // and leave it alone. // #todo! There is a bug here, any panel that is cleared here will never be // asked to reduce its memory. This isn't a huge deal, but something we might // want to fix later. This isn't a huge problem because on mobile this will never happen // and the memory manager will start killing pages if memory gets too high. panelToReduceMemory = null; } // If the first panel we found wasn't it then this panel // isn't visible. break; } } } } // Animate the current panel out PlayFadeAnimation(newPanelType, navigateFromPanelType, State.FadingOut); } // If we have a panel tell it we are leaving no under lock. if (navigateFromPanel != null) { FireOnNavigateFrom(navigateFromPanel.Panel); } // If we have a panel to reduce memory, ask it to. if (panelToReduceMemory != null) { FireOnReduceMemory(panelToReduceMemory.Panel); } return(true); }
public static List <Panel> FilterPanelsNotByType(this List <Panel> panels, PanelType type) { return(panels.Where(x => x.Type != type).ToList()); }
bool IsPanelShowed(PanelType panelType) { return(_showedPanelList.IndexOf(panelType) != -1); }
internal LobbyLogic(Widget widget, WorldRenderer worldRenderer, OrderManager orderManager, Action onExit, Action onStart, bool skirmishMode, Ruleset modRules) { lobby = widget; this.orderManager = orderManager; this.onStart = onStart; this.onExit = onExit; this.skirmishMode = skirmishMode; this.modRules = modRules; orderManager.AddChatLine += AddChatLine; Game.LobbyInfoChanged += UpdateCurrentMap; Game.LobbyInfoChanged += UpdatePlayerList; Game.BeforeGameStart += OnGameStart; Game.ConnectionStateChanged += ConnectionStateChanged; var name = lobby.GetOrNull <LabelWidget>("SERVER_NAME"); if (name != null) { name.GetText = () => orderManager.LobbyInfo.GlobalSettings.ServerName; } Ui.LoadWidget("LOBBY_MAP_PREVIEW", lobby.Get("MAP_PREVIEW_ROOT"), new WidgetArgs { { "orderManager", orderManager }, { "lobby", this } }); UpdateCurrentMap(); players = Ui.LoadWidget <ScrollPanelWidget>("LOBBY_PLAYER_BIN", lobby.Get("PLAYER_BIN_ROOT"), new WidgetArgs()); players.IsVisible = () => panel == PanelType.Players; var playerBinHeaders = lobby.GetOrNull <ContainerWidget>("LABEL_CONTAINER"); if (playerBinHeaders != null) { playerBinHeaders.IsVisible = () => panel == PanelType.Players; } editablePlayerTemplate = players.Get("TEMPLATE_EDITABLE_PLAYER"); nonEditablePlayerTemplate = players.Get("TEMPLATE_NONEDITABLE_PLAYER"); emptySlotTemplate = players.Get("TEMPLATE_EMPTY"); editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR"); nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR"); newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR"); colorPreview = lobby.Get <ColorPreviewManagerWidget>("COLOR_MANAGER"); colorPreview.Color = Game.Settings.Player.Color; countryNames = modRules.Actors["world"].Traits.WithInterface <CountryInfo>() .Where(c => c.Selectable) .ToDictionary(a => a.Race, a => a.Name); countryNames.Add("random", "Any"); var gameStarting = false; Func <bool> configurationDisabled = () => !Game.IsHost || gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; var mapButton = lobby.GetOrNull <ButtonWidget>("CHANGEMAP_BUTTON"); if (mapButton != null) { mapButton.IsDisabled = configurationDisabled; mapButton.OnClick = () => { var onSelect = new Action <string>(uid => { // Don't select the same map again if (uid == Map.Uid) { return; } orderManager.IssueOrder(Order.Command("map " + uid)); Game.Settings.Server.Map = uid; Game.Settings.Save(); }); Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() { { "initialMap", Map.Uid }, { "onExit", DoNothing }, { "onSelect", onSelect } }); }; } var slotsButton = lobby.GetOrNull <DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON"); if (slotsButton != null) { slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players || Map.RuleStatus != MapRuleStatus.Cached || !orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots || !s.LockTeam); var botNames = modRules.Actors["player"].Traits.WithInterface <IBotInfo>().Select(t => t.Name); slotsButton.OnMouseDown = _ => { var options = new Dictionary <string, IEnumerable <DropDownOption> >(); var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); if (orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots)) { var botOptions = new List <DropDownOption>() { new DropDownOption() { Title = "Add", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var bot = botNames.Random(Game.CosmeticRandom); var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (slot.Value.AllowBots == true && (c == null || c.Bot != null)) { orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot.Key, botController.Index, bot))); } } } } }; if (orderManager.LobbyInfo.Clients.Any(c => c.Bot != null)) { botOptions.Add(new DropDownOption() { Title = "Remove", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (c != null && c.Bot != null) { orderManager.IssueOrder(Order.Command("slot_open " + slot.Value.PlayerReference)); } } } }); } options.Add("Configure Bots", botOptions); } var teamCount = (orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) + 1) / 2; if (teamCount >= 1) { var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption { Title = "{0} Teams".F(d), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams {0}".F(d.ToString()))) }).ToList(); if (orderManager.LobbyInfo.Slots.Any(s => s.Value.AllowBots)) { teamOptions.Add(new DropDownOption { Title = "Humans vs Bots", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 1")) }); } teamOptions.Add(new DropDownOption { Title = "Free for all", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 0")) }); options.Add("Configure Teams", teamOptions); } Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; slotsButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 175, options, setupItem); }; } var optionsBin = Ui.LoadWidget("LOBBY_OPTIONS_BIN", lobby, new WidgetArgs()); optionsBin.IsVisible = () => panel == PanelType.Options; var optionsButton = lobby.Get <ButtonWidget>("OPTIONS_BUTTON"); optionsButton.IsDisabled = () => Map.RuleStatus != MapRuleStatus.Cached || panel == PanelType.Kick || panel == PanelType.ForceStart; optionsButton.GetText = () => panel == PanelType.Options ? "Players" : "Options"; optionsButton.OnClick = () => panel = (panel == PanelType.Options) ? PanelType.Players : PanelType.Options; // Force start panel Action startGame = () => { gameStarting = true; orderManager.IssueOrder(Order.Command("startgame")); }; var startGameButton = lobby.GetOrNull <ButtonWidget>("START_GAME_BUTTON"); if (startGameButton != null) { startGameButton.IsDisabled = () => configurationDisabled() || Map.RuleStatus != MapRuleStatus.Cached || orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null); startGameButton.OnClick = () => { Func <KeyValuePair <string, Session.Slot>, bool> notReady = sl => { var cl = orderManager.LobbyInfo.ClientInSlot(sl.Key); // Bots and admins don't count return(cl != null && !cl.IsAdmin && cl.Bot == null && !cl.IsReady); }; if (orderManager.LobbyInfo.Slots.Any(notReady)) { panel = PanelType.ForceStart; } else { startGame(); } }; } var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby, new WidgetArgs()); forceStartBin.IsVisible = () => panel == PanelType.ForceStart; forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid); forceStartBin.Get <ButtonWidget>("OK_BUTTON").OnClick = startGame; forceStartBin.Get <ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players; // Options panel var allowCheats = optionsBin.GetOrNull <CheckboxWidget>("ALLOWCHEATS_CHECKBOX"); if (allowCheats != null) { allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats; allowCheats.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Cheats.HasValue || configurationDisabled(); allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); } var crates = optionsBin.GetOrNull <CheckboxWidget>("CRATES_CHECKBOX"); if (crates != null) { crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates; crates.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Crates.HasValue || configurationDisabled(); crates.OnClick = () => orderManager.IssueOrder(Order.Command( "crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates))); } var allybuildradius = optionsBin.GetOrNull <CheckboxWidget>("ALLYBUILDRADIUS_CHECKBOX"); if (allybuildradius != null) { allybuildradius.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius; allybuildradius.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.AllyBuildRadius.HasValue || configurationDisabled(); allybuildradius.OnClick = () => orderManager.IssueOrder(Order.Command( "allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius))); } var fragileAlliance = optionsBin.GetOrNull <CheckboxWidget>("FRAGILEALLIANCES_CHECKBOX"); if (fragileAlliance != null) { fragileAlliance.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.FragileAlliances; fragileAlliance.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.FragileAlliances.HasValue || configurationDisabled(); fragileAlliance.OnClick = () => orderManager.IssueOrder(Order.Command( "fragilealliance {0}".F(!orderManager.LobbyInfo.GlobalSettings.FragileAlliances))); } var difficulty = optionsBin.GetOrNull <DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); if (difficulty != null) { difficulty.IsVisible = () => Map.Status == MapStatus.Available && Map.Map.Options.Difficulties.Any(); difficulty.IsDisabled = () => Map.Status != MapStatus.Available || configurationDisabled(); difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty; difficulty.OnMouseDown = _ => { var options = Map.Map.Options.Difficulties.Select(d => new DropDownOption { Title = d, IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d, OnClick = () => orderManager.IssueOrder(Order.Command("difficulty {0}".F(d))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; difficulty.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; optionsBin.Get <LabelWidget>("DIFFICULTY_DESC").IsVisible = difficulty.IsVisible; } var startingUnits = optionsBin.GetOrNull <DropDownButtonWidget>("STARTINGUNITS_DROPDOWNBUTTON"); if (startingUnits != null) { var startUnitsInfo = modRules.Actors["world"].Traits.WithInterface <MPStartUnitsInfo>(); var classes = startUnitsInfo.Select(a => a.Class).Distinct(); Func <string, string> className = c => { var selectedClass = startUnitsInfo.Where(s => s.Class == c).Select(u => u.ClassName).FirstOrDefault(); return(selectedClass != null ? selectedClass : c); }; startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled(); startingUnits.GetText = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass); startingUnits.OnMouseDown = _ => { var options = classes.Select(c => new DropDownOption { Title = className(c), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass == c, OnClick = () => orderManager.IssueOrder(Order.Command("startingunits {0}".F(c))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; startingUnits.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; optionsBin.Get <LabelWidget>("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible; } var startingCash = optionsBin.GetOrNull <DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON"); if (startingCash != null) { startingCash.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue || configurationDisabled(); startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash); startingCash.OnMouseDown = _ => { var options = modRules.Actors["player"].Traits.Get <PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption { Title = "${0}".F(c), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingCash == c, OnClick = () => orderManager.IssueOrder(Order.Command("startingcash {0}".F(c))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; startingCash.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; } var techLevel = optionsBin.GetOrNull <DropDownButtonWidget>("TECHLEVEL_DROPDOWNBUTTON"); if (techLevel != null) { var techTraits = modRules.Actors["player"].Traits.WithInterface <ProvidesTechPrerequisiteInfo>().ToArray(); techLevel.IsVisible = () => techTraits.Length > 0; optionsBin.GetOrNull <LabelWidget>("TECHLEVEL_DESC").IsVisible = () => techTraits.Length > 0; techLevel.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Length <= 1; techLevel.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel); techLevel.OnMouseDown = _ => { var options = techTraits.Select(c => new DropDownOption { Title = "{0}".F(c.Name), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.TechLevel == c.Name, OnClick = () => orderManager.IssueOrder(Order.Command("techlevel {0}".F(c.Name))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; techLevel.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; } var enableShroud = optionsBin.GetOrNull <CheckboxWidget>("SHROUD_CHECKBOX"); if (enableShroud != null) { enableShroud.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Shroud; enableShroud.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Shroud.HasValue || configurationDisabled(); enableShroud.OnClick = () => orderManager.IssueOrder(Order.Command( "shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud))); } var enableFog = optionsBin.GetOrNull <CheckboxWidget>("FOG_CHECKBOX"); if (enableFog != null) { enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog; enableFog.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Fog.HasValue || configurationDisabled(); enableFog.OnClick = () => orderManager.IssueOrder(Order.Command( "fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog))); } var disconnectButton = lobby.Get <ButtonWidget>("DISCONNECT_BUTTON"); disconnectButton.OnClick = () => { CloseWindow(); onExit(); }; if (skirmishMode) { disconnectButton.Text = "Cancel"; } var teamChat = false; var chatLabel = lobby.Get <LabelWidget>("LABEL_CHATTYPE"); var chatTextField = lobby.Get <TextFieldWidget>("CHAT_TEXTFIELD"); chatTextField.TakeKeyboardFocus(); chatTextField.OnEnterKey = () => { if (chatTextField.Text.Length == 0) { return(true); } // Always scroll to bottom when we've typed something chatPanel.ScrollToBottom(); orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text)); chatTextField.Text = ""; return(true); }; chatTextField.OnAltKey = () => { teamChat ^= true; chatLabel.Text = teamChat ? "Team:" : "Chat:"; return(true); }; chatTextField.OnTabKey = () => { chatTextField.Text = tabCompletion.Complete(chatTextField.Text); chatTextField.CursorPosition = chatTextField.Text.Length; return(true); }; chatPanel = lobby.Get <ScrollPanelWidget>("CHAT_DISPLAY"); chatTemplate = chatPanel.Get("CHAT_TEMPLATE"); chatPanel.RemoveChildren(); var musicButton = lobby.GetOrNull <ButtonWidget>("MUSIC_BUTTON"); if (musicButton != null) { musicButton.OnClick = () => Ui.OpenWindow("MUSIC_PANEL", new WidgetArgs { { "onExit", DoNothing }, { "world", orderManager.world } }); } var settingsButton = lobby.GetOrNull <ButtonWidget>("SETTINGS_BUTTON"); if (settingsButton != null) { settingsButton.OnClick = () => Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs { { "onExit", DoNothing }, { "worldRenderer", worldRenderer } }); } // Add a bot on the first lobbyinfo update if (skirmishMode) { Game.LobbyInfoChanged += WidgetUtils.Once(() => { var slot = orderManager.LobbyInfo.FirstEmptyBotSlot(); var bot = modRules.Actors["player"].Traits.WithInterface <IBotInfo>().Select(t => t.Name).FirstOrDefault(); var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); if (slot != null && bot != null) { orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot))); } }); } }
private void CloseOthersPanels(PanelType type) { foreach (var p in Panels) { if (p.Key == type || !p.Value.Visible) continue; p.Value.Fade(p.Value.Alpha, 0, 500); } }
public PanelSwitchedEvent(PanelType type) { this.type = type; }
/// <summary> /// Call once to register a panel type which will get dynamically created /// and embedded in a Rhino docking/floating location. /// </summary> /// <param name="plugIn"> /// Plug-in restringing the panel /// </param> /// <param name="type"> /// Type of the control object to be displayed in the panel /// </param> /// <param name="caption"> /// Panel caption also used as a tool-tip. On Windows the panel may be /// displayed using the icon, caption or both. On Mac the icon will be /// used and the caption will be the tool-tip. /// </param> /// <param name="icon"> /// The panel icon. On Windows the panel may be displayed using the icon, /// caption or both. On Mac the icon will be used and the caption will be /// the tool-tip. /// </param> /// <param name="panelType"> /// See <see cref="PanelType"/> /// </param> /// <since>6.1</since> public static void RegisterPanel(PlugIns.PlugIn plugIn, Type type, string caption, System.Drawing.Icon icon, PanelType panelType) { PanelSystem.Register(plugIn, type, caption, icon, panelType); }
/// <summary> /// Call once to register a panel type which will get dynamically created /// and embedded in a Rhino docking/floating location. /// </summary> /// <param name="plugInId"> /// Plug-in restringing the panel /// </param> /// <param name="type"> /// Type of the control object to be displayed in the panel /// </param> /// <param name="caption"> /// Panel caption also used as a tool-tip. On Windows the panel may be /// displayed using the icon, caption or both. On Mac the icon will be /// used and the caption will be the tool-tip. /// </param> /// <param name="icon"> /// The panel icon. On Windows the panel may be displayed using the icon, /// caption or both. On Mac the icon will be used and the caption will be /// the tool-tip. /// </param> /// <param name="panelType"> /// See <see cref="PanelType"/> /// </param> public static void Register(Guid plugInId, Type type, string caption, Icon icon, PanelType panelType) { // Plug-in that owns the panel, currently required. Investigate changing to // System.Reflection.Assembly to allow Rhino.UI to register panels directly if (plugInId == Guid.Empty) { throw new ArgumentException($"{nameof(plugInId)} Can't be Guid.Empty", nameof(plugInId)); } // Type of the control object to be displayed in the panel if (type == null) { throw new ArgumentNullException(nameof(type)); } if (!Panels.Service.SupportedType(type, out string exception_message)) { throw new ArgumentException(exception_message, nameof(type)); } // The panel class must have a constructor that either takes a single, // unsigned integer parameter representing a document serial number or no // parameters. var constructor = type.GetConstructor(Type.EmptyTypes); // Allow constructor that takes a single unsigned int which will get // passed the runtime serial number of the active document generating the // new panel request. var constructor_with_doc_and_runtime_id = type.GetConstructor(new [] { typeof(Guid), typeof(RhinoDoc) }); var constructor_with_sn = type.GetConstructor(new [] { typeof(uint) }); var constructor_with_doc = type.GetConstructor(new [] { typeof(RhinoDoc) }); if (!type.IsPublic || (constructor == null && constructor_with_sn == null && constructor_with_doc == null && constructor_with_doc_and_runtime_id == null)) { throw new ArgumentException(@"The panel type must have a constructor with a uint, RhinoDoc or no parameters", nameof(type)); } // Check for a GUID attribute var attr = type.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false); if (attr.Length != 1) { throw new ArgumentException(@"type must have a GuidAttribute", "type"); } // Add the panel type, wont do anything if the type was previously registered Add(plugInId, type, caption, icon, panelType); }
bool IsPanelLoaded(PanelType panelType) { return(_panelDataDict.ContainsKey(panelType)); }
public static PanelContent BeginPanel(this IAnyContentMarker contentHelper, PanelType type) { return(Panel(contentHelper, type).BeginContent()); }
//public void Add(UI ui) //{ // //ui.GameObject.GetComponent<Canvas>().worldCamera = this.Camera.GetComponent<Camera>(); // this.uis.Add(ui.Name, ui); // //ui.Parent = this; // ui.GameObject.transform.SetParent(this.Root.transform, false); //} public void Close(UIEnum panel) { PanelType panelType = uiTypes[panel]; this.Remove(panelType.uiPrefab); }
public static Output <List <Panel>, List <Panel> > FilterPanelsByType(this List <Panel> panels, PanelType type) { return(new Output <List <Panel>, List <Panel> > { Item1 = panels.Where(x => x.Type == type).ToList(), Item2 = panels.Where(x => x.Type != type).ToList(), }); }
public static IItemWriter <T, PanelContent> Type <T>(this IItemWriter <T, PanelContent> target, PanelType value) where T : Panel { target.Item.Type = value; return(target); }
/// <summary> /// Fired when the storyboard animation has finished. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PanelAnimation_Completed(object sender, object e) { PanelType newPanelType = PanelType.None; IPanel newPanel = null; bool fireNavCompleteAndReturn = false; // Grab a lock lock (m_panelStack) { // Check the state if (m_state == State.Idle) { return; } else if (m_state == State.FadingIn) { // We are done with the fade in, go back to idle m_state = State.Idle; // Update the back button UpdateBackButton(); fireNavCompleteAndReturn = true; // If we are pending a screen change do it now. if (m_deferedScreenUpdate.HasValue) { ExecuteOnScreenSizeChagnedLogic(m_deferedScreenUpdate.Value); m_deferedScreenUpdate = null; } } else { // State.FadingOut if (m_screenMode == ScreenMode.Single) { // If we are in single mode we want to animate in whatever is on the top of the stack newPanel = m_panelStack.Last().Panel; } else { // If we are in split mode we want to animate in whatever is the most recent panel for this space. // First figure out what content space this came from PanelType animationPanelType = (sender as DoubleAnimation).Equals(ui_animSubList) ? PanelType.SubredditList : PanelType.ContentPanel; // Now find the most recent panel for content space. foreach (StackItem item in m_panelStack.Reverse <StackItem>()) { IPanel panel = item.Panel; // If the are both subreddit panels or both not, we found the panel. if (GetPanelType(panel) == animationPanelType) { newPanel = panel; break; } } // If newPanel type is null we don't have anything and we should clean up and leave. if (newPanel == null) { // Set the state m_state = State.Idle; // Get the root Grid paneRoot = animationPanelType == PanelType.ContentPanel ? ui_contentRoot : ui_subListRoot; paneRoot.Children.Clear(); // Update the back button UpdateBackButton(); fireNavCompleteAndReturn = true; } } if (!fireNavCompleteAndReturn) { // Get the panel state of the top panel, this is the one we want to animate back in newPanelType = GetPanelType(newPanel); // Get the correct root Grid root = newPanelType == PanelType.ContentPanel ? ui_contentRoot : ui_subListRoot; // Take clear the current panel root.Children.Clear(); root.Children.Add((UserControl)newPanel); // Update the panel sizes UpdatePanelSizes(); } } } // Do this if needed and get out of here. if (fireNavCompleteAndReturn) { FireOnNavigateComplete(); return; } // Inform the panel we are navigating to it. FireOnNavigateTo(newPanel); lock (m_panelStack) { // Play the animation, note the second type doesn't matter for fade in. PlayFadeAnimation(newPanelType, PanelType.None, State.FadingIn); } }
void RegisterSettingsPanel(PanelType type, Func <Widget, Action> init, Func <Widget, Action> reset, string panelID, string buttonID) { var panel = panelContainer.Get(panelID); var tab = tabContainer.Get <ButtonWidget>(buttonID); panel.IsVisible = () => settingsPanel == type; tab.IsHighlighted = () => settingsPanel == type; tab.OnClick = () => { leavePanelActions[settingsPanel](); Game.Settings.Save(); settingsPanel = type; }; leavePanelActions.Add(type, init(panel)); resetPanelActions.Add(type, reset(panel)); }
Stream(ArrayList data, PanelType panelType) { data.Add(new Snoop.Data.ClassSeparator(typeof(PanelType))); // No data at this level yet! }
public static IItemWriter <Panel, PanelContent> Panel(this IAnyContentMarker contentHelper, PanelType type) { return(Panel(contentHelper).Type(type)); }
void UpdatePlayerList() { if (orderManager.LocalClient == null) { return; } var isHost = Game.IsHost; var idx = 0; foreach (var kv in orderManager.LobbyInfo.Slots) { var key = kv.Key; var slot = kv.Value; var client = orderManager.LobbyInfo.ClientInSlot(key); Widget template = null; // get template for possible reuse if (idx < players.Children.Count) { template = players.Children[idx]; } if (client == null) { // Empty slot if (template == null || template.Id != emptySlotTemplate.Id) { template = emptySlotTemplate.Clone(); } if (isHost) { LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, map); } else { LobbyUtils.SetupSlotWidget(template, slot, client); } var join = template.Get <ButtonWidget>("JOIN"); join.IsVisible = () => !slot.Closed; join.IsDisabled = () => orderManager.LocalClient.IsReady; join.OnClick = () => orderManager.IssueOrder(Order.Command("slot " + key)); } else if ((client.Index == orderManager.LocalClient.Index) || (client.Bot != null && isHost)) { // Editable player in slot if (template == null || template.Id != editablePlayerTemplate.Id) { template = editablePlayerTemplate.Clone(); } LobbyUtils.SetupClientWidget(template, client, orderManager, client.Bot == null); if (client.Bot != null) { LobbyUtils.SetupEditableSlotWidget(template, slot, client, orderManager, map); } else { LobbyUtils.SetupEditableNameWidget(template, slot, client, orderManager); } LobbyUtils.SetupEditableColorWidget(template, slot, client, orderManager, shellmapWorld, colorPreview); LobbyUtils.SetupEditableFactionWidget(template, slot, client, orderManager, factions); LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, map); LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, map); LobbyUtils.SetupEditableReadyWidget(template, slot, client, orderManager, map); } else { // Non-editable player in slot if (template == null || template.Id != nonEditablePlayerTemplate.Id) { template = nonEditablePlayerTemplate.Clone(); } LobbyUtils.SetupClientWidget(template, client, orderManager, client.Bot == null); LobbyUtils.SetupNameWidget(template, slot, client); LobbyUtils.SetupKickWidget(template, slot, client, orderManager, lobby, () => panel = PanelType.Kick, () => panel = PanelType.Players); LobbyUtils.SetupColorWidget(template, slot, client); LobbyUtils.SetupFactionWidget(template, slot, client, factions); if (isHost) { LobbyUtils.SetupEditableTeamWidget(template, slot, client, orderManager, map); LobbyUtils.SetupEditableSpawnWidget(template, slot, client, orderManager, map); } else { LobbyUtils.SetupTeamWidget(template, slot, client); LobbyUtils.SetupSpawnWidget(template, slot, client); } LobbyUtils.SetupReadyWidget(template, slot, client); } template.IsVisible = () => true; if (idx >= players.Children.Count) { players.AddChild(template); } else if (players.Children[idx].Id != template.Id) { players.ReplaceChild(players.Children[idx], template); } idx++; } // Add spectators foreach (var client in orderManager.LobbyInfo.Clients.Where(client => client.Slot == null)) { Widget template = null; var c = client; // get template for possible reuse if (idx < players.Children.Count) { template = players.Children[idx]; } // Editable spectator if (c.Index == orderManager.LocalClient.Index) { if (template == null || template.Id != editableSpectatorTemplate.Id) { template = editableSpectatorTemplate.Clone(); } LobbyUtils.SetupEditableNameWidget(template, null, c, orderManager); if (client.IsAdmin) { LobbyUtils.SetupEditableReadyWidget(template, null, client, orderManager, map); } } else { // Non-editable spectator if (template == null || template.Id != nonEditableSpectatorTemplate.Id) { template = nonEditableSpectatorTemplate.Clone(); } LobbyUtils.SetupNameWidget(template, null, client); LobbyUtils.SetupKickWidget(template, null, client, orderManager, lobby, () => panel = PanelType.Kick, () => panel = PanelType.Players); if (client.IsAdmin) { LobbyUtils.SetupReadyWidget(template, null, client); } } LobbyUtils.SetupClientWidget(template, c, orderManager, true); template.IsVisible = () => true; if (idx >= players.Children.Count) { players.AddChild(template); } else if (players.Children[idx].Id != template.Id) { players.ReplaceChild(players.Children[idx], template); } idx++; } // Spectate button if (orderManager.LocalClient.Slot != null) { Widget spec = null; if (idx < players.Children.Count) { spec = players.Children[idx]; } if (spec == null || spec.Id != newSpectatorTemplate.Id) { spec = newSpectatorTemplate.Clone(); } LobbyUtils.SetupKickSpectatorsWidget(spec, orderManager, lobby, () => panel = PanelType.Kick, () => panel = PanelType.Players, skirmishMode); var btn = spec.Get <ButtonWidget>("SPECTATE"); btn.OnClick = () => orderManager.IssueOrder(Order.Command("spectate")); btn.IsDisabled = () => orderManager.LocalClient.IsReady; btn.IsVisible = () => orderManager.LobbyInfo.GlobalSettings.AllowSpectators || orderManager.LocalClient.IsAdmin; spec.IsVisible = () => true; if (idx >= players.Children.Count) { players.AddChild(spec); } else if (players.Children[idx].Id != spec.Id) { players.ReplaceChild(players.Children[idx], spec); } idx++; } while (players.Children.Count > idx) { players.RemoveChild(players.Children[idx]); } tabCompletion.Names = orderManager.LobbyInfo.Clients.Select(c => c.Name).Distinct().ToList(); }
public override void Init(PanelType type) { base.Init(type); type = PanelType.Player_LEFT; }
public bool IsPanelVisible(PanelType type) { return(CurrentActivePanelContainer != null && CurrentActivePanelContainer == ExistingContainerForType(type)); }
public override void Build(PanelType panelType, Layout layout) { base.Build(panelType, layout); distancePanel = AddUIComponent <DistancePanel>(); distancePanel.Build(panelType, new Layout(new Vector2(390.0f, 0.0f), true, ColossalFramework.UI.LayoutDirection.Vertical, ColossalFramework.UI.LayoutStart.TopLeft, 5)); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static Waffle Waffle(string name, double slabDepth, double depthX, double depthY, double stemWidthX, double stemWidthY, double spacingX, double spacingY, PanelType type = PanelType.Undefined) { return(new Waffle { Name = name, Thickness = slabDepth, TotalDepthX = depthX, TotalDepthY = depthY, StemWidthX = stemWidthX, StemWidthY = stemWidthY, SpacingX = spacingX, SpacingY = spacingY, PanelType = type }); }
public UI Get(UIEnum panel) { PanelType panelType = uiTypes[panel]; return(Get(panelType.uiPrefab)); }
public static Construction ToSAM(this HostObjAttributes hostObjAttributes, ConvertSettings convertSettings) { if (hostObjAttributes == null) { return(null); } Construction result = convertSettings?.GetObject <Construction>(hostObjAttributes.Id); if (result != null) { return(result); } string name = hostObjAttributes.Name; PanelType panelType = hostObjAttributes.PanelType(); if (panelType == PanelType.Undefined) { panelType = Query.PanelType((BuiltInCategory)hostObjAttributes.Category.Id.IntegerValue); } Construction construction = Analytical.Query.DefaultConstruction(panelType); if (construction != null && (name.Equals(construction.Name) || name.Equals(construction.UniqueName()))) { result = new Construction(construction); } else { result = new Construction(hostObjAttributes.Name); } result.UpdateParameterSets(hostObjAttributes, ActiveSetting.Setting.GetValue <Core.TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap)); //result.Add(Core.Revit.Query.ParameterSet(hostObjAttributes)); convertSettings?.Add(hostObjAttributes.Id, result); if (panelType != PanelType.Undefined) { result.SetValue(ConstructionParameter.DefaultPanelType, panelType.Text()); } else { result.SetValue(ConstructionParameter.DefaultPanelType, null); } List <ConstructionLayer> constructionLayers = result.ConstructionLayers; if (constructionLayers != null && constructionLayers.Count != 0) { result.SetValue(ConstructionParameter.DefaultThickness, constructionLayers.ConvertAll(x => x.Thickness).Sum()); } else { CompoundStructure compoundStructure = hostObjAttributes.GetCompoundStructure(); if (compoundStructure != null) { #if Revit2017 || Revit2018 || Revit2019 || Revit2020 double thickness = UnitUtils.ConvertFromInternalUnits(compoundStructure.GetWidth(), DisplayUnitType.DUT_METERS); #else double thickness = UnitUtils.ConvertFromInternalUnits(compoundStructure.GetWidth(), UnitTypeId.Meters); #endif result.SetValue(ConstructionParameter.DefaultThickness, thickness); } } return(result); }
internal LobbyLogic(Widget widget, WorldRenderer worldRenderer, OrderManager orderManager, Action onExit, Action onStart, bool skirmishMode, Ruleset modRules) { lobby = widget; this.orderManager = orderManager; this.onStart = onStart; this.onExit = onExit; this.skirmishMode = skirmishMode; this.modRules = modRules; shellmapWorld = worldRenderer.World; orderManager.AddChatLine += AddChatLine; Game.LobbyInfoChanged += UpdateCurrentMap; Game.LobbyInfoChanged += UpdatePlayerList; Game.BeforeGameStart += OnGameStart; Game.ConnectionStateChanged += ConnectionStateChanged; var name = lobby.GetOrNull <LabelWidget>("SERVER_NAME"); if (name != null) { name.GetText = () => orderManager.LobbyInfo.GlobalSettings.ServerName; } Ui.LoadWidget("LOBBY_MAP_PREVIEW", lobby.Get("MAP_PREVIEW_ROOT"), new WidgetArgs { { "orderManager", orderManager }, { "lobby", this } }); UpdateCurrentMap(); var playerBin = Ui.LoadWidget("LOBBY_PLAYER_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); playerBin.IsVisible = () => panel == PanelType.Players; players = playerBin.Get <ScrollPanelWidget>("LOBBY_PLAYERS"); editablePlayerTemplate = players.Get("TEMPLATE_EDITABLE_PLAYER"); nonEditablePlayerTemplate = players.Get("TEMPLATE_NONEDITABLE_PLAYER"); emptySlotTemplate = players.Get("TEMPLATE_EMPTY"); editableSpectatorTemplate = players.Get("TEMPLATE_EDITABLE_SPECTATOR"); nonEditableSpectatorTemplate = players.Get("TEMPLATE_NONEDITABLE_SPECTATOR"); newSpectatorTemplate = players.Get("TEMPLATE_NEW_SPECTATOR"); colorPreview = lobby.Get <ColorPreviewManagerWidget>("COLOR_MANAGER"); colorPreview.Color = Game.Settings.Player.Color; foreach (var f in modRules.Actors["world"].TraitInfos <FactionInfo>()) { factions.Add(f.InternalName, new LobbyFaction { Selectable = f.Selectable, Name = f.Name, Side = f.Side, Description = f.Description }); } var gameStarting = false; Func <bool> configurationDisabled = () => !Game.IsHost || gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; var mapButton = lobby.GetOrNull <ButtonWidget>("CHANGEMAP_BUTTON"); if (mapButton != null) { mapButton.IsDisabled = () => gameStarting || panel == PanelType.Kick || panel == PanelType.ForceStart || orderManager.LocalClient == null || orderManager.LocalClient.IsReady; mapButton.OnClick = () => { var onSelect = new Action <string>(uid => { // Don't select the same map again if (uid == Map.Uid) { return; } orderManager.IssueOrder(Order.Command("map " + uid)); Game.Settings.Server.Map = uid; Game.Settings.Save(); }); Ui.OpenWindow("MAPCHOOSER_PANEL", new WidgetArgs() { { "initialMap", Map.Uid }, { "initialTab", MapClassification.System }, { "onExit", DoNothing }, { "onSelect", Game.IsHost ? onSelect : null }, { "filter", MapVisibility.Lobby }, }); }; } var slotsButton = lobby.GetOrNull <DropDownButtonWidget>("SLOTS_DROPDOWNBUTTON"); if (slotsButton != null) { slotsButton.IsDisabled = () => configurationDisabled() || panel != PanelType.Players || Map.RuleStatus != MapRuleStatus.Cached || !orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots || !s.LockTeam); var botNames = modRules.Actors["player"].TraitInfos <IBotInfo>().Select(t => t.Name); slotsButton.OnMouseDown = _ => { var options = new Dictionary <string, IEnumerable <DropDownOption> >(); var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); if (orderManager.LobbyInfo.Slots.Values.Any(s => s.AllowBots)) { var botOptions = new List <DropDownOption>() { new DropDownOption() { Title = "Add", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var bot = botNames.Random(Game.CosmeticRandom); var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (slot.Value.AllowBots == true && (c == null || c.Bot != null)) { orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot.Key, botController.Index, bot))); } } } } }; if (orderManager.LobbyInfo.Clients.Any(c => c.Bot != null)) { botOptions.Add(new DropDownOption() { Title = "Remove", IsSelected = () => false, OnClick = () => { foreach (var slot in orderManager.LobbyInfo.Slots) { var c = orderManager.LobbyInfo.ClientInSlot(slot.Key); if (c != null && c.Bot != null) { orderManager.IssueOrder(Order.Command("slot_open " + slot.Value.PlayerReference)); } } } }); } options.Add("Configure Bots", botOptions); } var teamCount = (orderManager.LobbyInfo.Slots.Count(s => !s.Value.LockTeam && orderManager.LobbyInfo.ClientInSlot(s.Key) != null) + 1) / 2; if (teamCount >= 1) { var teamOptions = Enumerable.Range(2, teamCount - 1).Reverse().Select(d => new DropDownOption { Title = "{0} Teams".F(d), IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams {0}".F(d.ToString()))) }).ToList(); if (orderManager.LobbyInfo.Slots.Any(s => s.Value.AllowBots)) { teamOptions.Add(new DropDownOption { Title = "Humans vs Bots", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 1")) }); } teamOptions.Add(new DropDownOption { Title = "Free for all", IsSelected = () => false, OnClick = () => orderManager.IssueOrder(Order.Command("assignteams 0")) }); options.Add("Configure Teams", teamOptions); } Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; slotsButton.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 175, options, setupItem); }; } var optionsBin = Ui.LoadWidget("LOBBY_OPTIONS_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); optionsBin.IsVisible = () => panel == PanelType.Options; var musicBin = Ui.LoadWidget("LOBBY_MUSIC_BIN", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs { { "onExit", DoNothing }, { "world", worldRenderer.World } }); musicBin.IsVisible = () => panel == PanelType.Music; var optionsTab = lobby.Get <ButtonWidget>("OPTIONS_TAB"); optionsTab.IsHighlighted = () => panel == PanelType.Options; optionsTab.IsDisabled = () => Map.RuleStatus != MapRuleStatus.Cached || panel == PanelType.Kick || panel == PanelType.ForceStart; optionsTab.OnClick = () => panel = PanelType.Options; var playersTab = lobby.Get <ButtonWidget>("PLAYERS_TAB"); playersTab.IsHighlighted = () => panel == PanelType.Players; playersTab.IsDisabled = () => panel == PanelType.Kick || panel == PanelType.ForceStart; playersTab.OnClick = () => panel = PanelType.Players; var musicTab = lobby.Get <ButtonWidget>("MUSIC_TAB"); musicTab.IsHighlighted = () => panel == PanelType.Music; musicTab.IsDisabled = () => panel == PanelType.Kick || panel == PanelType.ForceStart; musicTab.OnClick = () => panel = PanelType.Music; // Force start panel Action startGame = () => { gameStarting = true; orderManager.IssueOrder(Order.Command("startgame")); }; var startGameButton = lobby.GetOrNull <ButtonWidget>("START_GAME_BUTTON"); if (startGameButton != null) { startGameButton.IsDisabled = () => configurationDisabled() || Map.RuleStatus != MapRuleStatus.Cached || orderManager.LobbyInfo.Slots.Any(sl => sl.Value.Required && orderManager.LobbyInfo.ClientInSlot(sl.Key) == null); startGameButton.OnClick = () => { // Bots and admins don't count if (orderManager.LobbyInfo.Clients.Any(c => c.Slot != null && !c.IsAdmin && c.Bot == null && !c.IsReady)) { panel = PanelType.ForceStart; } else { startGame(); } }; } var forceStartBin = Ui.LoadWidget("FORCE_START_DIALOG", lobby.Get("TOP_PANELS_ROOT"), new WidgetArgs()); forceStartBin.IsVisible = () => panel == PanelType.ForceStart; forceStartBin.Get("KICK_WARNING").IsVisible = () => orderManager.LobbyInfo.Clients.Any(c => c.IsInvalid); forceStartBin.Get <ButtonWidget>("OK_BUTTON").OnClick = startGame; forceStartBin.Get <ButtonWidget>("CANCEL_BUTTON").OnClick = () => panel = PanelType.Players; // Options panel var allowCheats = optionsBin.GetOrNull <CheckboxWidget>("ALLOWCHEATS_CHECKBOX"); if (allowCheats != null) { allowCheats.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllowCheats; allowCheats.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Cheats.HasValue || configurationDisabled(); allowCheats.OnClick = () => orderManager.IssueOrder(Order.Command( "allowcheats {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllowCheats))); } var crates = optionsBin.GetOrNull <CheckboxWidget>("CRATES_CHECKBOX"); if (crates != null) { crates.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Crates; crates.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Crates.HasValue || configurationDisabled(); crates.OnClick = () => orderManager.IssueOrder(Order.Command( "crates {0}".F(!orderManager.LobbyInfo.GlobalSettings.Crates))); } var creeps = optionsBin.GetOrNull <CheckboxWidget>("CREEPS_CHECKBOX"); if (creeps != null) { creeps.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Creeps; creeps.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Creeps.HasValue || configurationDisabled(); creeps.OnClick = () => orderManager.IssueOrder(Order.Command( "creeps {0}".F(!orderManager.LobbyInfo.GlobalSettings.Creeps))); } var allybuildradius = optionsBin.GetOrNull <CheckboxWidget>("ALLYBUILDRADIUS_CHECKBOX"); if (allybuildradius != null) { allybuildradius.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius; allybuildradius.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.AllyBuildRadius.HasValue || configurationDisabled(); allybuildradius.OnClick = () => orderManager.IssueOrder(Order.Command( "allybuildradius {0}".F(!orderManager.LobbyInfo.GlobalSettings.AllyBuildRadius))); } var fragileAlliance = optionsBin.GetOrNull <CheckboxWidget>("FRAGILEALLIANCES_CHECKBOX"); if (fragileAlliance != null) { fragileAlliance.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.FragileAlliances; fragileAlliance.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.FragileAlliances.HasValue || configurationDisabled(); fragileAlliance.OnClick = () => orderManager.IssueOrder(Order.Command( "fragilealliance {0}".F(!orderManager.LobbyInfo.GlobalSettings.FragileAlliances))); } var shortGame = optionsBin.GetOrNull <CheckboxWidget>("SHORTGAME_CHECKBOX"); if (shortGame != null) { shortGame.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.ShortGame; shortGame.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.ShortGame.HasValue || configurationDisabled(); shortGame.OnClick = () => orderManager.IssueOrder(Order.Command( "shortgame {0}".F(!orderManager.LobbyInfo.GlobalSettings.ShortGame))); } var difficulty = optionsBin.GetOrNull <DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); if (difficulty != null) { difficulty.IsVisible = () => Map.Status == MapStatus.Available && Map.Map.Options.Difficulties.Any(); difficulty.IsDisabled = () => Map.Status != MapStatus.Available || configurationDisabled(); difficulty.GetText = () => orderManager.LobbyInfo.GlobalSettings.Difficulty; difficulty.OnMouseDown = _ => { var options = Map.Map.Options.Difficulties.Select(d => new DropDownOption { Title = d, IsSelected = () => orderManager.LobbyInfo.GlobalSettings.Difficulty == d, OnClick = () => orderManager.IssueOrder(Order.Command("difficulty {0}".F(d))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; difficulty.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; optionsBin.Get <LabelWidget>("DIFFICULTY_DESC").IsVisible = difficulty.IsVisible; } var startingUnits = optionsBin.GetOrNull <DropDownButtonWidget>("STARTINGUNITS_DROPDOWNBUTTON"); if (startingUnits != null) { var startUnitsInfo = modRules.Actors["world"].TraitInfos <MPStartUnitsInfo>(); var classes = startUnitsInfo.Select(a => a.Class).Distinct(); Func <string, string> className = c => { var selectedClass = startUnitsInfo.Where(s => s.Class == c).Select(u => u.ClassName).FirstOrDefault(); return(selectedClass != null ? selectedClass : c); }; startingUnits.IsDisabled = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits || configurationDisabled(); startingUnits.GetText = () => Map.Status != MapStatus.Available || !Map.Map.Options.ConfigurableStartingUnits ? "Not Available" : className(orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass); startingUnits.OnMouseDown = _ => { var options = classes.Select(c => new DropDownOption { Title = className(c), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingUnitsClass == c, OnClick = () => orderManager.IssueOrder(Order.Command("startingunits {0}".F(c))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; startingUnits.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; optionsBin.Get <LabelWidget>("STARTINGUNITS_DESC").IsVisible = startingUnits.IsVisible; } var startingCash = optionsBin.GetOrNull <DropDownButtonWidget>("STARTINGCASH_DROPDOWNBUTTON"); if (startingCash != null) { startingCash.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue || configurationDisabled(); startingCash.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.StartingCash.HasValue ? "Not Available" : "${0}".F(orderManager.LobbyInfo.GlobalSettings.StartingCash); startingCash.OnMouseDown = _ => { var options = modRules.Actors["player"].TraitInfo <PlayerResourcesInfo>().SelectableCash.Select(c => new DropDownOption { Title = "${0}".F(c), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.StartingCash == c, OnClick = () => orderManager.IssueOrder(Order.Command("startingcash {0}".F(c))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; startingCash.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; } var techLevel = optionsBin.GetOrNull <DropDownButtonWidget>("TECHLEVEL_DROPDOWNBUTTON"); if (techLevel != null) { var techTraits = modRules.Actors["player"].TraitInfos <ProvidesTechPrerequisiteInfo>().ToList(); techLevel.IsVisible = () => techTraits.Count > 0; var techLevelDescription = optionsBin.GetOrNull <LabelWidget>("TECHLEVEL_DESC"); if (techLevelDescription != null) { techLevelDescription.IsVisible = () => techTraits.Count > 0; } techLevel.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null || configurationDisabled() || techTraits.Count <= 1; techLevel.GetText = () => Map.Status != MapStatus.Available || Map.Map.Options.TechLevel != null ? "Not Available" : "{0}".F(orderManager.LobbyInfo.GlobalSettings.TechLevel); techLevel.OnMouseDown = _ => { var options = techTraits.Select(c => new DropDownOption { Title = "{0}".F(c.Name), IsSelected = () => orderManager.LobbyInfo.GlobalSettings.TechLevel == c.Name, OnClick = () => orderManager.IssueOrder(Order.Command("techlevel {0}".F(c.Name))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; techLevel.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; } var gameSpeed = optionsBin.GetOrNull <DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON"); if (gameSpeed != null) { var speeds = Game.ModData.Manifest.Get <GameSpeeds>().Speeds; gameSpeed.IsDisabled = () => Map.Status != MapStatus.Available || configurationDisabled(); gameSpeed.GetText = () => { if (Map.Status != MapStatus.Available) { return("Not Available"); } GameSpeed speed; if (!speeds.TryGetValue(orderManager.LobbyInfo.GlobalSettings.GameSpeedType, out speed)) { return("Unknown"); } return(speed.Name); }; gameSpeed.OnMouseDown = _ => { var options = speeds.Select(s => new DropDownOption { Title = s.Value.Name, IsSelected = () => orderManager.LobbyInfo.GlobalSettings.GameSpeedType == s.Key, OnClick = () => orderManager.IssueOrder(Order.Command("gamespeed {0}".F(s.Key))) }); Func <DropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick); item.Get <LabelWidget>("LABEL").GetText = () => option.Title; return(item); }; gameSpeed.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", options.Count() * 30, options, setupItem); }; } var exploredMap = optionsBin.GetOrNull <CheckboxWidget>("EXPLORED_MAP_CHECKBOX"); if (exploredMap != null) { exploredMap.IsChecked = () => !orderManager.LobbyInfo.GlobalSettings.Shroud; exploredMap.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Shroud.HasValue || configurationDisabled(); exploredMap.OnClick = () => orderManager.IssueOrder(Order.Command( "shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud))); } var enableFog = optionsBin.GetOrNull <CheckboxWidget>("FOG_CHECKBOX"); if (enableFog != null) { enableFog.IsChecked = () => orderManager.LobbyInfo.GlobalSettings.Fog; enableFog.IsDisabled = () => Map.Status != MapStatus.Available || Map.Map.Options.Fog.HasValue || configurationDisabled(); enableFog.OnClick = () => orderManager.IssueOrder(Order.Command( "fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog))); } var disconnectButton = lobby.Get <ButtonWidget>("DISCONNECT_BUTTON"); disconnectButton.OnClick = () => { CloseWindow(); onExit(); }; if (skirmishMode) { disconnectButton.Text = "Back"; } var globalChat = Game.LoadWidget(null, "LOBBY_GLOBALCHAT_PANEL", lobby.Get("GLOBALCHAT_ROOT"), new WidgetArgs()); var globalChatInput = globalChat.Get <TextFieldWidget>("CHAT_TEXTFIELD"); globalChat.IsVisible = () => chatPanel == ChatPanelType.Global; var globalChatTab = lobby.Get <ButtonWidget>("GLOBALCHAT_TAB"); globalChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Global; globalChatTab.OnClick = () => { chatPanel = ChatPanelType.Global; globalChatInput.TakeKeyboardFocus(); }; var globalChatLabel = globalChatTab.Text; globalChatTab.GetText = () => { if (globalChatUnreadMessages == 0 || chatPanel == ChatPanelType.Global) { return(globalChatLabel); } return(globalChatLabel + " ({0})".F(globalChatUnreadMessages)); }; globalChatLastReadMessages = Game.GlobalChat.History.Count(m => m.Type == ChatMessageType.Message); var lobbyChat = lobby.Get("LOBBYCHAT"); lobbyChat.IsVisible = () => chatPanel == ChatPanelType.Lobby; chatLabel = lobby.Get <LabelWidget>("LABEL_CHATTYPE"); var chatTextField = lobby.Get <TextFieldWidget>("CHAT_TEXTFIELD"); chatTextField.TakeKeyboardFocus(); chatTextField.OnEnterKey = () => { if (chatTextField.Text.Length == 0) { return(true); } // Always scroll to bottom when we've typed something lobbyChatPanel.ScrollToBottom(); orderManager.IssueOrder(Order.Chat(teamChat, chatTextField.Text)); chatTextField.Text = ""; return(true); }; chatTextField.OnTabKey = () => { var previousText = chatTextField.Text; chatTextField.Text = tabCompletion.Complete(chatTextField.Text); chatTextField.CursorPosition = chatTextField.Text.Length; if (chatTextField.Text == previousText) { return(SwitchTeamChat()); } else { return(true); } }; chatTextField.OnEscKey = () => { chatTextField.Text = ""; return(true); }; var lobbyChatTab = lobby.Get <ButtonWidget>("LOBBYCHAT_TAB"); lobbyChatTab.IsHighlighted = () => chatPanel == ChatPanelType.Lobby; lobbyChatTab.OnClick = () => { chatPanel = ChatPanelType.Lobby; chatTextField.TakeKeyboardFocus(); }; var lobbyChatLabel = lobbyChatTab.Text; lobbyChatTab.GetText = () => { if (lobbyChatUnreadMessages == 0 || chatPanel == ChatPanelType.Lobby) { return(lobbyChatLabel); } return(lobbyChatLabel + " ({0})".F(lobbyChatUnreadMessages)); }; lobbyChatPanel = lobby.Get <ScrollPanelWidget>("CHAT_DISPLAY"); chatTemplate = lobbyChatPanel.Get("CHAT_TEMPLATE"); lobbyChatPanel.RemoveChildren(); var settingsButton = lobby.GetOrNull <ButtonWidget>("SETTINGS_BUTTON"); if (settingsButton != null) { settingsButton.OnClick = () => Ui.OpenWindow("SETTINGS_PANEL", new WidgetArgs { { "onExit", DoNothing }, { "worldRenderer", worldRenderer } }); } // Add a bot on the first lobbyinfo update if (skirmishMode) { Game.LobbyInfoChanged += WidgetUtils.Once(() => { var slot = orderManager.LobbyInfo.FirstEmptyBotSlot(); var bot = modRules.Actors["player"].TraitInfos <IBotInfo>().Select(t => t.Name).FirstOrDefault(); var botController = orderManager.LobbyInfo.Clients.FirstOrDefault(c => c.IsAdmin); if (slot != null && bot != null) { orderManager.IssueOrder(Order.Command("slot_bot {0} {1} {2}".F(slot, botController.Index, bot))); } }); } }
/// <summary> /// Fades in our out the current panel /// </summary> /// <param name="newState"></param> private void PlayFadeAnimation(PanelType newPanelType, PanelType lastPanelType, State newState) { PanelType panelToFade = PanelType.None; if (newState == State.FadingIn) { // If we are fading in we know which panel we want to fade in. panelToFade = newPanelType; } else { // Figure out what panel to fade out, if we are in single mode we want to fade out // whatever was on the screen last. if (m_screenMode == ScreenMode.Single) { panelToFade = lastPanelType; } // If we are in split mode we want to fade out which ever panel we are replacing. else { panelToFade = newPanelType; } } // Get the correct vars Storyboard story = panelToFade == PanelType.SubredditList ? ui_storySubList : ui_storyContent; DoubleAnimation anim = panelToFade == PanelType.SubredditList ? ui_animSubList : ui_animContent; Grid root = panelToFade == PanelType.SubredditList ? ui_subListRoot : ui_contentRoot; // Setup anim.To = newState == State.FadingIn ? 1 : 0; /// #todo, use the current opacity in the animation. anim.From = newState == State.FadingIn ? 0 : 1; /// #todo make this better, why do i have set set opacity? root.Opacity = newState == State.FadingIn ? 0 : 1; // Stop any existing animation story.Stop(); // Set the new state m_state = newState; // Start a new one story.Begin(); }
private void ShowPanel(PanelType type) { UIManager.ShowPanel(type); DisableControls(); isPause = true; }
public void ShowPanel(PanelType type) { ShowPausePlayers(); CloseOthersPanels(type); var p = Panels[type]; p.Fade(p.Alpha, 255, 500); Simulator.CanSelectCelestialBodies = false; NotifyPanelOpened(); }
public static List <Panel> PanelsByType(this List <Panel> panels, PanelType type) { return(panels.Where(x => x.Type == type).ToList()); }