/// <summary> /// Prepares the page with a given profile. /// </summary> /// <param name="profile">The profile to prepare with.</param> /// <param name="handler">The menu handler.</param> public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var pageProfile = (PageProfile)profile; this.Name = pageProfile.name; }
/// <summary>Callback for the menu changed event; switches the currently handler to the one for the new menu type.</summary> private void OnMenuChanged(object sender, EventArgsClickableMenuChanged e) { this.Monitor.DebugLog($"Menu changed from {e?.PriorMenu} to {e?.NewMenu}"); // Resize event; ignore if (e.PriorMenu?.GetType() == e.NewMenu?.GetType() && this.WasResizeEvent) { this.WasResizeEvent = false; return; } this.WasResizeEvent = false; // Reset var newMenuType = e.NewMenu.GetType(); if (this.MenuHandlers.ContainsKey(newMenuType)) { // Close the current one of it's valid and not the same as the current one if (this.CurrentMenuHandler != null && this.CurrentMenuHandler != this.MenuHandlers[newMenuType]) { this.CurrentMenuHandler.Close(); } this.CurrentMenuHandler = this.MenuHandlers[newMenuType]; this.CurrentMenuHandler.Open(e.NewMenu); SubscribeEvents(); } }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { this.CurrentUpdateTick += 1; if (this.CurrentUpdateTick >= 60) { this.CurrentUpdateTick = 0; } // If TickResizedOn isn't -1 then there was a resize event, so do the resize next tick. // We need to do it this way rather than where we ignore resize in menu changed since not all menus are recreated on resize, // and during the actual resize event the new menu will not have been created yet so we need to wait. if (this.TickResizedOn > -1 && this.TickResizedOn != this.CurrentUpdateTick) { this.TickResizedOn = -1; this.CurrentMenuHandler?.Close(); // Checking the menu type since actions like returning to title will cause a resize event (idk why the window is maximized) // and the activeClickableMenu will not be what it was before. if (this.CurrentMenuHandler?.IsCorrectMenuType(Game1.activeClickableMenu) == true) { this.CurrentMenuHandler?.Open(Game1.activeClickableMenu); } else { this.CurrentMenuHandler = null; } } this.CurrentMenuHandler?.Update(); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var objProfile = (IObjectProfile)profile; this.id = objProfile.label; this.alignment = objProfile.align; }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var menuProfile = (MenuProfile)profile; this.window.SetTitle(menuProfile.title); this.window.SetIcon(menuProfile.icon); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var textProfile = (IObjectProfileWithText)profile; this.textLabel.Label.SetText(textProfile.text); this.textLabel.Tooltip = textProfile.tooltip; }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var dummyProfile = (DummyProfile)profile; this.Frame.SetWidth(dummyProfile.width ?? 10); this.Frame.SetHeight(dummyProfile.height ?? 10); this.value = null; }
/// <summary>Callback for the menu closed event; closes the current handler and unsubscribes from the events.</summary> private void OnMenuClosed(object sender, EventArgsClickableMenuClosed e) { if (this.CurrentMenuHandler != null) { //this.Monitor.Log("[OnMenuClosed] Closing current menu handler", LogLevel.Trace); this.CurrentMenuHandler.Close(); this.CurrentMenuHandler = null; UnsubscribeEvents(); } }
/// <summary> /// Prepare to open MenuHandler by attaching to UpateTicked event. This is done to allow other mods to finish manipulating /// the inventory + extended inventory /// </summary> /// <param name="newMenu">The new menu being opened</param> /// <param name="handler">The handler for the new menu</param> private void EnqueueMenuHandlerOpener(IClickableMenu newMenu, IMenuHandler handler) { if (this.WaitOpenTicks > 0) { return; } Log.TraceIfD($"MenuHandlerOpener enregistered & enqueued"); this.MenuToHandle = newMenu; this.CurrentMenuHandler = handler; Mod.Events.GameLoop.UpdateTicked += MenuHandlerOpener; }
/// <summary> /// Prepares the object with a given profile. /// </summary> /// <param name="profile">The profile to prepare with.</param> /// <param name="handler">The menu handler.</param> public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(null, handler); var lineProfile = (LineProfile)profile; this.leftBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.l, handler); this.centerBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.c, handler); this.rightBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.r, handler); this.Content = new List <IAlignedBlock>(); this.Content.AddRange(new[] { this.leftBlock, this.centerBlock, this.rightBlock }.Where(b => b != null)); }
/// <summary> /// Initializes the <see cref="MenuScreen"/>. /// </summary> public void Initialize(IMenuHandler akMenuHandler) { MenuHandler = akMenuHandler; canvasGroup = GetComponent <CanvasGroup>(); State = MenuScreenState.Out; Interactable = false; BlocksRaycasts = false; DefaultSelection = defaultSelection; gameObject.SetActive(false); OnInitialize(); }
// TODO: Add a method for retrieving a created character from a save file public Engine( IMenuHandler menuHandler, IMonsterDatabase monsterDatabase, IAreaDatabase areaDatabase, IAIDatabase aiDatabase) { this.menuHandler = menuHandler; this.monsterDatabase = monsterDatabase; this.areaDatabase = areaDatabase; this.aiDatabase = aiDatabase; }
public virtual void Prepare(IElementProfile profile, IMenuHandler handler) { if (this.prepared) { throw new MenuException("Element is already prepared."); } this.prepared = true; this.handler = handler; this.Frame.Show(); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var panelProfile = (PanelProfile)profile; var innerPageProfile = new PageProfile(); panelProfile.ForEach(innerPageProfile.Add); this.innerPage = (IPage)handler.CreateRegion(innerPageProfile); this.innerPage.Prepare(innerPageProfile, handler); this.name = panelProfile.name; }
public ButtonsTest(IMenuHandler handler) { var menu = handler.CreateMenu( new MenuProfile("Buttons test", 400, () => { Core.print("OK"); }, true, () => Core.print("Show"), null, null) { title = "Buttons tests", icon = "Interface\\Icons\\Ability_Creature_Cursed_04", [0] = new PageProfile() { new LineProfile() { new ButtonProfile() { align = ObjectAlign.l, text = "Default", onClick = (() => { Core.print("Click"); }), tooltip = "Default profile values" }, new ButtonProfile() { width = 80, height = 20, align = ObjectAlign.c, text = "Normal", onClick = (() => { Core.print("Click"); }), tooltip = "Normal with given width and height" }, new ButtonProfile() { width = 80, height = 20, align = ObjectAlign.r, text = "Compact", compact = true, onClick = (() => { Core.print("Click"); }), tooltip = "Compact button" } } } } ); menu.AnimatedShow(); }
public Presenter(IModelProvider model, IMenuHandler menuHandler, QuickButtonModule quickButtonModule) { this.model = model; this.menuHandler = menuHandler; quickButtonModule.RegisterDefaultButton(new QuickButton( "ghdDocument", 6, true, "Documents", "Interface\\Icons\\INV_Misc_Book_08", ShowDocumentMenu, AddOnReference.GHD)); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); var menuProfile = (MenuProfile)profile; this.HandleOnShow(menuProfile); this.HandleOnHide(menuProfile); this.Inserts = new Inserts(); this.menuWidth = menuProfile.width; this.menuHeight = menuProfile.height; this.Frame["Name"] = menuProfile.name; }
public void AddObjectByProfile(IObjectProfile profile, IMenuHandler handler) { var lineProfile = new LineProfile() { profile }; switch (profile.align) { case ObjectAlign.l: if (this.leftBlock == null) { this.leftBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.l, handler); } else { this.leftBlock.AddElement((IMenuObject)handler.CreateRegion(profile)); } break; case ObjectAlign.c: if (this.centerBlock == null) { this.centerBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.c, handler); } else { this.centerBlock.AddElement((IMenuObject)handler.CreateRegion(profile)); } break; default: if (this.rightBlock == null) { this.rightBlock = GenerateAndPrepareBlock(lineProfile, ObjectAlign.r, handler); } else { this.rightBlock.AddElement((IMenuObject)handler.CreateRegion(profile)); } break; } this.Content = new List <IAlignedBlock>(); this.Content.AddRange(new[] { this.leftBlock, this.centerBlock, this.rightBlock }.Where(b => b != null)); }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { // menu closed if (e.NewMenu == null) { // close the current handler and unsubscribe from the events if (this.CurrentMenuHandler != null) { //Log.Trace("[OnMenuClosed] Closing current menu handler"); this.CurrentMenuHandler.Close(); this.CurrentMenuHandler = null; UnsubscribeHandlerEvents(); } return; } // ignore resize event if (e.OldMenu?.GetType() == e.NewMenu?.GetType() && this.WasResizeEvent) { this.WasResizeEvent = false; return; } this.WasResizeEvent = false; // Reset // switch the currently handler to the one for the new menu type var nuMenu = e.NewMenu; Log.TraceIfD($"Menu changed from {e.OldMenu} to {nuMenu}"); if ( HandlerMapping.TryGetHandler(nuMenu.GetType(), out IMenuHandler handler) || HandlerMapping.TryGetHandler(nuMenu.ToString(), out handler) ) { Log.TraceIfD($"{nuMenu} intercepted"); // Close the current one if still open, it's likely invalid if (this.CurrentMenuHandler != null) { DequeueMenuHandlerOpener(); this.CurrentMenuHandler.Close(); } EnqueueMenuHandlerOpener(nuMenu, handler); } else { Log.TraceIfD($"{nuMenu} not intercepted, don't know how"); } }
public bool HandleInput(IEnumerable <char> input, out IMenuHandler nextHandler) { var result = true; nextHandler = this; this.OnHandleInput((StringHelper.AsString(input) ?? string.Empty).ToLower().Trim(), ref nextHandler, ref result); if (!result) { nextHandler = this; } return(result); }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { // menu closed if (e.NewMenu == null) { // close the current handler and unsubscribe from the events if (this.CurrentMenuHandler != null) { //this.Monitor.Log("[OnMenuClosed] Closing current menu handler", LogLevel.Trace); this.CurrentMenuHandler.Close(); this.CurrentMenuHandler = null; UnsubscribeEvents(); } return; } // ignore resize event if (e.OldMenu?.GetType() == e.NewMenu?.GetType() && this.WasResizeEvent) { this.WasResizeEvent = false; return; } this.WasResizeEvent = false; // Reset // switch the currently handler to the one for the new menu type this.Monitor.DebugLog($"Menu changed from {e.OldMenu} to {e.NewMenu}"); var newMenuType = e.NewMenu.GetType(); if (this.MenuHandlers.ContainsKey(newMenuType)) { // Close the current one of it's valid if (this.CurrentMenuHandler != null) { this.CurrentMenuHandler.Close(); } this.CurrentMenuHandler = this.MenuHandlers[newMenuType]; this.CurrentMenuHandler.Open(e.NewMenu); SubscribeEvents(); } }
// Protected Methods (1) protected override void OnHandleInput(string input, ref IMenuHandler nextHandler, ref bool isValid) { switch (input) { case "1": nextHandler = new ModuleMenu(); break; case "x": nextHandler = null; break; default: isValid = false; break; } }
public MainTest(IMenuHandler handler) { var menu = handler.CreateMenu( new MenuProfile("Main test", 400, () => { Core.print("OK"); }, true, () => Core.print("Show"), null, null) { title = "Menu tests", icon = "Interface\\Icons\\Ability_Creature_Cursed_04", [0] = new PageProfile() { new LineProfile() { new ButtonProfile() { width = 80, height = 20, align = ObjectAlign.c, text = "Buttons", onClick = (() => { new ButtonsTest(handler); }) } }, new LineProfile() { new ButtonProfile() { width = 80, height = 20, align = ObjectAlign.c, text = "EditBoxes", onClick = (() => { new EditBoxesTest(handler); }) } }, } } ); menu.AnimatedShow(); }
public DocumentMenu(IMenuHandler menuHandler) { var metaCatagory = new MetaCatagoryProfileGenerator(this.Undo, this.Redo, this.Revert, this.Save); var profileGenerator = new DocumentMenuProfileGenerator(metaCatagory); this.textScoper = new TextScoper(); var elementFrameFactory = new ElementFrameFactory(); var pageProperties = new PageProperties() { Width = 550, Height = 750, }; this.elementFactory = new ElementFactory(textScoper, elementFrameFactory, pageProperties); //this.elementFactory = new ElementFactory() // TODO this.inputProvider = new TextBoxInputInterpreter(); this.cursor = new Cursor(); this.menu = menuHandler.CreateMenu(profileGenerator.GenerateMenuProfile()); this.SetupDocumentArea(this.menu.GetFrameById(DocumentMenuLabels.DocumentArea) as IFrame); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); this.Content = new List <T>(); this.layout = handler.Layout; var containerProfile = profile as IContainerProfile <TProfile>; if (containerProfile == null) { return; } containerProfile.ToList().ForEach(p => { var regionProfile = (IMenuRegionProfile)p; var region = (T)handler.CreateRegion(regionProfile); this.Content.Add(region); region.Prepare(regionProfile, handler); }); }
// Protected Methods (1) protected override void OnHandleInput(string input, ref IMenuHandler nextHandler, ref bool isValid) { switch (input) { case "1": this.ExecuteAnWaitOnError((state) => state.Test_DocDB(), this); break; case "2": this.ExecuteAnWaitOnError((state) => state.Test_RemoteComm(), this); break; case "x": nextHandler = new RootMenu(); break; default: isValid = false; break; } }
public MenuController(IMenuHandler menuService) { _menuService = menuService; }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); this.SetupFrame((ButtonProfile)profile); }
public override void Prepare(IElementProfile profile, IMenuHandler handler) { base.Prepare(profile, handler); this.SetUpFromProfile((EditFieldProfile)profile); // this.SetUpTabbableObject(new TabableEditBox(this.frame.Text)); }
public static bool IsMenuType(this IMenuHandler c, MenuType type) { return(c.GetType().GetCustomAttributesData().Any(attr => IsMenuType(attr, type))); }