Example #1
0
        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;
        }
Example #2
0
        public void RunActions(MHUrhoApp game)
        {
            var exec = new Execution(game, actions.GetEnumerator());

            game.MenuController.ScreenChanged += exec.TriggerNext;
            exec.TriggerNext();
        }
Example #3
0
        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().
        }
Example #4
0
        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;
        }
Example #5
0
        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);
        }
Example #6
0
                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);
                }
Example #7
0
                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;
                }
Example #8
0
                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);
                }
Example #9
0
            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);
                }
            }
Example #10
0
            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
                }
            }
Example #11
0
        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);
            }
        }
Example #12
0
        /// <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;
        }
Example #13
0
        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);
        }
Example #14
0
 void OnLoadingFailed(IProgressNotifier failed, string message)
 {
     //Update UI text, must be called from main thread
     MHUrhoApp.InvokeOnMainSafe(() => { text.Value = "Loading failed"; });
 }
Example #15
0
 void OnLoadingFinished(IProgressNotifier finished)
 {
     //Update UI text, must be called from main thread
     MHUrhoApp.InvokeOnMainSafe(() => { text.Value = "Loading finished"; });
 }
Example #16
0
 public override LevelLogicCustomSettings GetCustomSettings(Window customSettingsWindow, MHUrhoApp game)
 {
     return(new LevelLogicCustomSettings());
 }
 public override void Send(SendOrPostCallback d, object state)
 {
     MHUrhoApp.InvokeOnMainSafe(() => d(state));
 }
Example #18
0
 /// <summary>
 /// Provides facade over the UI control
 /// </summary>
 /// <param name="app"></param>
 public MenuController(MHUrhoApp app)
 {
     this.app     = app;
     UIController = new MenuUI(this);
 }
Example #19
0
 async void TimeOutExpired(Task task)
 {
     //Do not wait
     await MHUrhoApp.InvokeOnMainSafeAsync(() => Reply(false));
 }
Example #20
0
 public Material GetMaterialFromImage(string image, string normals)
 {
     return(MHUrhoApp.InvokeOnMainSafe(() => Material.FromImage(image, normals)));
 }
Example #21
0
 public Material GetMaterialFromImage(Image image)
 {
     return(MHUrhoApp.InvokeOnMainSafe(() => Material.FromImage(image)));
 }
Example #22
0
        public ParticleEffect2D GetParticleEffect2D(string name, bool throwOnFailure = false)
        {
            var resource = MHUrhoApp.InvokeOnMainSafe(() => resourceCache.GetParticleEffect2D(name));

            return(!throwOnFailure ? resource : resource ?? throw new ResourceLoadingException(name));
        }
Example #23
0
 public bool Exists(string name)
 {
     return(MHUrhoApp.InvokeOnMainSafe(() => resourceCache.Exists(name)));
 }
Example #24
0
 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;
 }
Example #25
0
 void OnTextUpdate(string newText)
 {
     //Update UI text, must be called from main thread
     MHUrhoApp.InvokeOnMainSafe(() => { text.Value = newText;; });
 }
Example #26
0
 public Execution(MHUrhoApp game, IEnumerator <MenuScreenAction> actions)
 {
     this.game    = game;
     this.actions = actions;
 }
Example #27
0
 /// <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));
 }
Example #28
0
 public override LevelLogicCustomSettings GetCustomSettings(Window customSettingsWindow, MHUrhoApp game)
 {
     return(new ResourceCreationWindow(customSettingsWindow, game));
 }
Example #29
0
        public XmlFile GetXmlFile(string name, bool throwOnFailure = false)
        {
            var resource = MHUrhoApp.InvokeOnMainSafe(() => resourceCache.GetXmlFile(name));

            return(!throwOnFailure ? resource : resource ?? throw new ResourceLoadingException(name));
        }
Example #30
0
 /// <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));
 }