Example #1
0
        private void LoadWorldandRender()
        {
            var ofd = new OpenFileDialog();

            ofd.Filter           = "Terrarial World File|*.wld|Terraria World Backup|*.bak|TEdit Backup File|*.TEdit";
            ofd.DefaultExt       = "Terrarial World File|*.wld";
            ofd.Title            = "Import Schematic File";
            ofd.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Terraria\Worlds");
            ofd.Multiselect      = false;
            if ((bool)ofd.ShowDialog())
            {
                if (!_texturesLoaded)
                {
                    WorldSettings.FindSteam();  // needs to be done with the current thread

                    Task.Factory
                    .StartNew(() => LoadWorld(ofd.FileName))
                    .ContinueWith(j => { _texturesLoaded = _renderer.LoadGameData(); })
                    .ContinueWith(k => RenderWorldTask())
                    .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);  // required to be non-async
                }
                else
                {
                    Task.Factory
                    .StartNew(() => LoadWorld(ofd.FileName))
                    .ContinueWith(k => RenderWorldTask())
                    .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);  // required to be non-async
                }
            }
        }
Example #2
0
        private void LoadTexturesAndRenderWorld()
        {
            try                            // FindSteam needs a window
            {
                WorldSettings.FindSteam(); // needs to be done with the current thread

                Task.Factory
                .StartNew(() => { _texturesLoaded = _renderer.LoadGameData(); })
                .ContinueWith(k => RenderWorldTask())
                .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);
            }
            catch {
                Task.Factory
                .StartNew(() => RenderWorldTask())
                .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);
            }
        }