public LevelPickingLevelItem(LevelRep level, MHUrhoApp game) : base(game, "UI/LevelItemStyle.xml", true) { this.Level = level; XmlFile styleFile = game.PackageManager.GetXmlFile("UI/LevelItemStyle.xml", true); UIElement fixedElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/LevelItemFixedLayout.xml", true), styleFile); FixedElement.AddChild(fixedElementContents); UIElement expandingElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/LevelItemExpandingLayout.xml", true), styleFile); ExpandingElement.AddChild(expandingElementContents); var thumbnailElement = (BorderImage)fixedElementContents.GetChild("Thumbnail", true); thumbnailElement.Texture = level.Thumbnail; thumbnailElement.ImageRect = new IntRect(0, 0, level.Thumbnail.Width, level.Thumbnail.Height); var nameElement = (Text)CheckBox.GetChild("NameText", true); nameElement.Value = level.Name; ((Text)ExpandingElement.GetChild("DescriptionText", true)).Value = level.Description; }
public void RunActions(MHUrhoApp game) { var exec = new Execution(game, actions.GetEnumerator()); game.MenuController.ScreenChanged += exec.TriggerNext; exec.TriggerNext(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); var decorView = Window.DecorView; var uiOptions = (int)decorView.SystemUiVisibility; uiOptions |= (int)SystemUiFlags.LowProfile; uiOptions |= (int)SystemUiFlags.Fullscreen; uiOptions |= (int)SystemUiFlags.HideNavigation; uiOptions |= (int)SystemUiFlags.ImmersiveSticky; decorView.SystemUiVisibility = (StatusBarVisibility)uiOptions; var layout = new FrameLayout(this); var surface = UrhoSurface.CreateSurface(this); layout.AddView(surface); SetContentView(layout); MHUrhoApp.FileManager = FileManagerDroid.LoadConfig(Assets); MHUrhoApp.FileManager.CopyStaticToDynamic(Path.Combine("Data", "Test")); try { myGame = await surface.Show <MHUrhoApp>(new ApplicationOptions("Data")); } catch (Exception e) { Urho.IO.Log.Write(LogLevel.Debug, e.ToString()); } //to stop the game use await surface.Stop(). }
public PackageListItem(GamePackRep pack, MHUrhoApp game) : base(game, "UI/AvailablePackItemStyle.xml", true) { this.Pack = pack; UIElement fixedElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/AvailablePackItemFixedLayout.xml", true), game.PackageManager.GetXmlFile("UI/AvailablePackItemStyle.xml", true)); FixedElement.AddChild(fixedElementContents); var thumbnail = (BorderImage)FixedElement.GetChild("Thumbnail", true); thumbnail.Texture = pack.Thumbnail; thumbnail.ImageRect = new IntRect(0, 0, pack.Thumbnail.Width, pack.Thumbnail.Height); var name = (Text)FixedElement.GetChild("NameText", true); name.Value = pack.Name; UIElement expandingElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/AvailablePackItemExpandingLayout.xml", true), game.PackageManager.GetXmlFile("UI/AvailablePackItemStyle.xml", true)); ExpandingElement.AddChild(expandingElementContents); descriptionText = (Text)ExpandingElement.GetChild("DescriptionText", true); descriptionText.Value = pack.Description; }
public LevelPickingNewLevelItem(MHUrhoApp game) : base(game, "UI/LevelItemStyle.xml", false) { UIElement fixedElementContets = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/NewLevelItemLayout.xml", true), game.PackageManager.GetXmlFile("UI/LevelItemStyle.xml", true)); FixedElement.AddChild(fixedElementContets); }
static UIElement InitTeamItem(int teamID, MHUrhoApp game, MenuUIManager menuUIManager) { var newElement = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/TeamListItemLayout.xml", true), menuUIManager.MenuRoot.GetDefaultStyle()); Text textElement = (Text)newElement.GetChild("TeamIDText"); textElement.Value = teamID.ToString(); return(newElement); }
public NameTextPair(MHUrhoApp game, string name, bool isDirectory) { Name = name; Text = new Text { Value = name, Visible = true }; Text.SetStyle(isDirectory ? "DirectoryEntry" : "FileEntry", game.PackageManager.GetXmlFile("UI/FileBrowserStyle.xml", true)); IsDirectory = isDirectory; }
static UIElement InitTypeItem(PlayerType player, MHUrhoApp game, MenuUIManager menuUIManager) { var newElement = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/PlayerTypeItemLayout.xml", true), menuUIManager.MenuRoot.GetDefaultStyle()); BorderImage playerIcon = (BorderImage)newElement.GetChild("PlayerIcon"); Text playerName = (Text)newElement.GetChild("PlayerName"); Text playerDescription = (Text)newElement.GetChild("PlayerDescription", true); playerIcon.Texture = player.Package.PlayerIconTexture; playerIcon.ImageRect = player.IconRectangle; playerName.Value = player.Name; //FUTURE: Description playerDescription.Value = "Nothing for now"; return(newElement); }
void SetValues(AppConfig config) { MHUrhoApp.InvokeOnMainSafe(SetValuesImpl); void SetValuesImpl() { UnitDrawDistance.Value = config.UnitDrawDistance; ProjectileDrawDistance.Value = config.ProjectileDrawDistance; TerrainDrawDistance.Value = config.TerrainDrawDistance; Resolutions.Selection = (uint)Game.Config.SupportedResolutions.IndexOf(Game.Config.Resolution); WindowTypes.Selection = (uint)FullscreenAndBorderlessToWindowType(config.Fullscreen, config.Borderless); HighDPI.Checked = config.HighDPI; TripleBuffer.Checked = config.TripleBuffer; VSync.Checked = config.VSync; DebugHUD.Checked = config.DebugHUD; MultiSample.Text = config.Multisample.ToString(); RefreshRate.Text = config.RefreshRateCap.ToString(); CameraScroll.Value = config.CameraScrollSensitivity; CameraRotation.Value = config.CameraRotationSensitivity; MouseCamRotation.Value = config.MouseRotationSensitivity; ZoomSpeed.Value = config.ZoomSensitivity; BorderMovement.Checked = config.MouseBorderCameraMovement; PathFindingVisualization.Selection = (uint)Game.Config.SupportedPathFindingVisualizations.IndexOf(Game.Config.PathFindingVisualization); } }
async void ThumbnailPathButtonReleased(ReleasedEventArgs args) { try { string oldPath = thumbnailPathText.Value; var result = await MenuUIManager. FileBrowsingPopUp. Request(Game.PackageManager.ActivePackage.RootedDirectoryPath, SelectOption.File, thumbnailPathText.HasDefaultValue?null : thumbnailPathText.Value); string newPath = result == null ? oldPath : result.RelativePath; await MHUrhoApp.InvokeOnMainSafeAsync(() => thumbnailPathText.Value = newPath); } catch (OperationCanceledException) { //Text should not have changed } }
public PackageManager(MHUrhoApp app) { this.App = app; this.resourceCache = app.ResourceCache; schemas = new XmlSchemaSet(); try { schemas.Add(XMLNamespace.NamespaceName, XmlReader.Create(App.Files.OpenStaticFileRO(GamePackageSchemaPath))); } catch (IOException e) { string message = $"Error loading GamePack schema: {e.Message}"; Log.Write(LogLevel.Error, message); if (Debugger.IsAttached) { Debugger.Break(); } //Reading of static file of this app failed, something is horribly wrong, die throw new FatalPackagingException(message, e); } try { DefaultIcon = resourceCache.GetTexture2D(defaultIconPath); } catch (IOException e) { string message = $"Error loading the default icon at {defaultIconPath}"; Log.Write(LogLevel.Error, message); if (Debugger.IsAttached) { Debugger.Break(); } //Reading of static file of this app failed, something is horribly wrong, die throw new FatalPackagingException(message, e); } }
/// <summary> /// Creates level manager that controls a level presented by <paramref name="levelRep"/> to the user, /// represented by <paramref name="levelNode"/> in the game engine. /// </summary> /// <param name="levelNode">The <see cref="Node"/> representing the level in the game engine.</param> /// <param name="levelRep">Presentation of the level for the user.</param> /// <param name="app">Current running application.</param> /// <param name="octree">Engine component used for raycasting.</param> /// <param name="editorMode">If the level is in editor mode or playig mode.</param> protected LevelManager(Node levelNode, LevelRep levelRep, MHUrhoApp app, Octree octree, bool editorMode) { this.LevelNode = levelNode; this.LevelRep = levelRep; this.EditorMode = editorMode; //Plugin is set in the loader after the creation of LevelManager //this.Plugin = plugin; this.units = new Dictionary <int, IUnit>(); this.players = new Dictionary <int, IPlayer>(); this.buildings = new Dictionary <int, IBuilding>(); this.projectiles = new Dictionary <int, IProjectile>(); this.entities = new Dictionary <int, IEntity>(); this.rangeTargets = new Dictionary <int, IRangeTarget>(); this.nodeToEntity = new Dictionary <Node, IEntity>(); this.rng = new Random(); this.App = app; this.octree = octree; this.DefaultComponentFactory = new DefaultComponentFactory(); this.IsEnding = false; ReceiveSceneUpdates = true; }
protected ExpandingListItem(MHUrhoApp game, string stylePath, bool expandOnSelect) { this.LayoutMode = LayoutMode.Horizontal; this.ExpandOnSelect = expandOnSelect; OuterElement = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/ExpandingItemLayout.xml", true), game.PackageManager.GetXmlFile(stylePath, true)); AddChild(OuterElement); CheckBox = (CheckBox)OuterElement.GetChild("CheckBox"); CheckBox.Toggled += CheckBoxToggled; FixedElement = CheckBox.GetChild("FixedElement"); ExpandingElement = CheckBox.GetChild("CollapsingElement"); ExpandingElement.Visible = false; //Set the size to effective min size, so all unused space with invisible elements gets hidden OuterElement.Size = new IntVector2(OuterElement.Size.X, OuterElement.EffectiveMinSize.Y); Size = new IntVector2(Size.X, EffectiveMinSize.Y); }
void OnLoadingFailed(IProgressNotifier failed, string message) { //Update UI text, must be called from main thread MHUrhoApp.InvokeOnMainSafe(() => { text.Value = "Loading failed"; }); }
void OnLoadingFinished(IProgressNotifier finished) { //Update UI text, must be called from main thread MHUrhoApp.InvokeOnMainSafe(() => { text.Value = "Loading finished"; }); }
public override LevelLogicCustomSettings GetCustomSettings(Window customSettingsWindow, MHUrhoApp game) { return(new LevelLogicCustomSettings()); }
public override void Send(SendOrPostCallback d, object state) { MHUrhoApp.InvokeOnMainSafe(() => d(state)); }
/// <summary> /// Provides facade over the UI control /// </summary> /// <param name="app"></param> public MenuController(MHUrhoApp app) { this.app = app; UIController = new MenuUI(this); }
async void TimeOutExpired(Task task) { //Do not wait await MHUrhoApp.InvokeOnMainSafeAsync(() => Reply(false)); }
public Material GetMaterialFromImage(string image, string normals) { return(MHUrhoApp.InvokeOnMainSafe(() => Material.FromImage(image, normals))); }
public Material GetMaterialFromImage(Image image) { return(MHUrhoApp.InvokeOnMainSafe(() => Material.FromImage(image))); }
public ParticleEffect2D GetParticleEffect2D(string name, bool throwOnFailure = false) { var resource = MHUrhoApp.InvokeOnMainSafe(() => resourceCache.GetParticleEffect2D(name)); return(!throwOnFailure ? resource : resource ?? throw new ResourceLoadingException(name)); }
public bool Exists(string name) { return(MHUrhoApp.InvokeOnMainSafe(() => resourceCache.Exists(name))); }
public ResourceCreationWindow(Window settingsWindow, MHUrhoApp game) { game.UI.LoadLayoutToElement(settingsWindow, game.ResourceCache, "Assets/UI/CreationWindowLayout.xml"); resourceSlider = (Slider)settingsWindow.GetChild("ResourceSlider", true); resourceSlider.SliderChanged += OnSliderChanged; }
void OnTextUpdate(string newText) { //Update UI text, must be called from main thread MHUrhoApp.InvokeOnMainSafe(() => { text.Value = newText;; }); }
public Execution(MHUrhoApp game, IEnumerator <MenuScreenAction> actions) { this.game = game; this.actions = actions; }
/// <summary> /// Returns plugin custom settings, encapsulating the GUI given to the plugin to place it's own elements in. /// </summary> /// <param name="customSettingsWindow">The part of the GUI given to the plugin.</param> /// <param name="game">Th instance representing the app.</param> /// <returns>Instance encapsulating the access to the GUI for the plugin.</returns> public LevelLogicCustomSettings GetCustomSettings(Window customSettingsWindow, MHUrhoApp game) { return(Plugin.GetCustomSettings(customSettingsWindow, game)); }
public override LevelLogicCustomSettings GetCustomSettings(Window customSettingsWindow, MHUrhoApp game) { return(new ResourceCreationWindow(customSettingsWindow, game)); }
public XmlFile GetXmlFile(string name, bool throwOnFailure = false) { var resource = MHUrhoApp.InvokeOnMainSafe(() => resourceCache.GetXmlFile(name)); return(!throwOnFailure ? resource : resource ?? throw new ResourceLoadingException(name)); }
/// <summary> /// Creates a controller for menu. /// </summary> /// <param name="app">The application instance.</param> /// <returns>A controller for menu.</returns> public IMenuController CreateMenuController(MHUrhoApp app) { return(new MenuController(app)); }