public void LiveLoadOrder(
            [Frozen] IScheduler scheduler,
            [Frozen] MockFileSystemWatcher watcher,
            [Frozen] MockFileSystem fs,
            [Frozen] ILiveLoadOrderTimings timings,
            [Frozen] IPluginListingsPathProvider pluginPath,
            [Frozen] IDataDirectoryProvider dataDir,
            [Frozen] ICreationClubListingsPathProvider cccPath)
        {
            var implicitKey      = Implicits.Get(GameRelease.SkyrimSE).Listings.First();
            var lightMasterPath  = Path.Combine(dataDir.Path, TestConstants.LightMasterModKey.FileName);
            var lightMaster2Path = Path.Combine(dataDir.Path, TestConstants.LightMasterModKey2.FileName);
            var master2Path      = Path.Combine(dataDir.Path, TestConstants.MasterModKey2.FileName);

            fs.File.WriteAllText(lightMasterPath, string.Empty);
            fs.File.WriteAllText(Path.Combine(dataDir.Path, TestConstants.Skyrim.FileName), string.Empty);
            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey2}",
                $"*{TestConstants.PluginModKey}",
            });
            fs.File.WriteAllLines(cccPath.Path,
                                  new string[]
            {
                TestConstants.LightMasterModKey.ToString(),
                TestConstants.LightMasterModKey2.ToString(),
            });
            var live = LoadOrder.GetLiveLoadOrder(
                GameRelease.SkyrimSE,
                pluginPath.Path,
                dataDir.Path,
                out var state,
                scheduler: scheduler,
                cccLoadOrderFilePath: cccPath.Path,
                timings: timings,
                fileSystem: fs);

            state.Subscribe(x =>
            {
                if (x.Failed)
                {
                    throw x.Exception ?? new Exception();
                }
            });
            var list = live.AsObservableList();

            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
                TestConstants.PluginModKey,
            });

            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.PluginModKey}",
            });
            watcher.MarkChanged(pluginPath.Path);
            fs.File.WriteAllText(lightMaster2Path, string.Empty);
            watcher.MarkCreated(lightMaster2Path);
            fs.File.Delete(lightMasterPath);
            watcher.MarkDeleted(lightMasterPath);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey2,
                TestConstants.MasterModKey,
                TestConstants.PluginModKey,
            });

            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey2}",
            });
            watcher.MarkChanged(pluginPath.Path);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey2,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
            });

            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey2}",
                $"*{TestConstants.PluginModKey}",
            });
            watcher.MarkChanged(pluginPath.Path);
            fs.File.Delete(lightMaster2Path);
            watcher.MarkDeleted(lightMaster2Path);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
                TestConstants.PluginModKey,
            });

            // Does not respect just data folder modification
            // Since ModListing doesn't specify whether data folder is present
            // Data folder is just used for Timestamp alignment for Oblivion
            fs.File.Delete(master2Path);
            watcher.MarkDeleted(master2Path);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
                TestConstants.PluginModKey,
            });
        }
        public void LiveLoadOrder_PluginsCCListingReorders(
            [Frozen] IScheduler scheduler,
            [Frozen] MockFileSystemWatcher watcher,
            [Frozen] MockFileSystem fs,
            [Frozen] IImplicitListingModKeyProvider implicitListingsProvider,
            [Frozen] ILiveLoadOrderTimings timings,
            [Frozen] IPluginListingsPathProvider pluginPath,
            [Frozen] IDataDirectoryProvider dataDir,
            [Frozen] ICreationClubListingsPathProvider cccPath)
        {
            var implicitKeys = implicitListingsProvider.Listings.ToArray();

            foreach (var implicitListing in implicitKeys)
            {
                fs.File.WriteAllText(Path.Combine(dataDir.Path, implicitListing.FileName), string.Empty);
            }
            fs.File.WriteAllText(Path.Combine(dataDir.Path, TestConstants.LightMasterModKey.FileName), string.Empty);
            fs.File.WriteAllText(Path.Combine(dataDir.Path, TestConstants.LightMasterModKey2.FileName), string.Empty);
            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.PluginModKey}",
            });
            fs.File.WriteAllLines(cccPath.Path,
                                  new string[]
            {
                TestConstants.LightMasterModKey.ToString(),
                TestConstants.LightMasterModKey2.ToString(),
            });
            var live = LoadOrder.GetLiveLoadOrder(
                GameRelease.SkyrimSE,
                pluginPath.Path,
                dataDir.Path,
                out var state,
                scheduler: scheduler,
                cccLoadOrderFilePath: cccPath.Path,
                fileSystem: fs,
                timings: timings);
            var list = live.AsObservableList();

            list.Items.Select(x => x.ModKey).Should().Equal(
                implicitKeys.Concat(
                    new ModKey[]
            {
                TestConstants.LightMasterModKey,
                TestConstants.LightMasterModKey2,
                TestConstants.MasterModKey,
                TestConstants.PluginModKey,
            }));

            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.PluginModKey}",
                $"{TestConstants.LightMasterModKey}",
            });
            watcher.MarkChanged(pluginPath.Path);
            list.Items.Select(x => x.ModKey).Should().Equal(
                implicitKeys.Concat(
                    new ModKey[] {
                TestConstants.LightMasterModKey2,
                TestConstants.LightMasterModKey,
                TestConstants.MasterModKey,
                TestConstants.PluginModKey,
            }));

            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.PluginModKey}",
                $"{TestConstants.LightMasterModKey}",
                $"{TestConstants.LightMasterModKey2}",
            });
            watcher.MarkChanged(pluginPath.Path);
            list.Items.Select(x => x.ModKey).Should().Equal(
                implicitKeys.Concat(
                    new ModKey[]
            {
                TestConstants.LightMasterModKey,
                TestConstants.LightMasterModKey2,
                TestConstants.MasterModKey,
                TestConstants.PluginModKey,
            }));
        }
        public void LiveLoadOrder_EnsureReaddRetainsOrder(
            [Frozen] IScheduler scheduler,
            [Frozen] MockFileSystemWatcher watcher,
            [Frozen] MockFileSystem fs,
            [Frozen] ILiveLoadOrderTimings timings,
            [Frozen] IPluginListingsPathProvider pluginPath,
            [Frozen] IDataDirectoryProvider dataDir,
            [Frozen] ICreationClubListingsPathProvider cccPath)
        {
            var implicitKey = Implicits.Get(GameRelease.SkyrimSE).Listings.First();

            fs.File.WriteAllText(Path.Combine(dataDir.Path, TestConstants.LightMasterModKey.FileName), string.Empty);
            fs.File.WriteAllText(Path.Combine(dataDir.Path, implicitKey.FileName), string.Empty);
            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey2}",
                $"*{TestConstants.MasterModKey3}",
                $"*{TestConstants.PluginModKey}",
            });
            fs.File.WriteAllLines(cccPath.Path,
                                  new string[]
            {
                TestConstants.LightMasterModKey.ToString(),
                TestConstants.LightMasterModKey2.ToString(),
            });
            var live = LoadOrder.GetLiveLoadOrder(
                GameRelease.SkyrimSE,
                pluginPath.Path,
                dataDir.Path,
                out var state,
                cccLoadOrderFilePath: cccPath.Path,
                scheduler: scheduler,
                fileSystem: fs,
                timings: timings);
            var list = live.AsObservableList();

            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
                TestConstants.MasterModKey3,
                TestConstants.PluginModKey,
            });

            // Remove
            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey3}",
                $"*{TestConstants.PluginModKey}",
            });
            watcher.MarkChanged(pluginPath.Path);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey3,
                TestConstants.PluginModKey,
            });

            // Then readd
            fs.File.WriteAllLines(pluginPath.Path,
                                  new string[]
            {
                $"*{TestConstants.MasterModKey}",
                $"*{TestConstants.MasterModKey2}",
                $"*{TestConstants.MasterModKey3}",
                $"*{TestConstants.PluginModKey}",
            });
            watcher.MarkChanged(pluginPath.Path);
            list.Items.Select(x => x.ModKey).Should().Equal(new ModKey[]
            {
                implicitKey,
                TestConstants.LightMasterModKey,
                TestConstants.MasterModKey,
                TestConstants.MasterModKey2,
                TestConstants.MasterModKey3,
                TestConstants.PluginModKey,
            });
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            ActivityHelper.ApplyLevelColors(Theme);
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.LessonFrame);
            SetSupportActionBar(FindViewById <Toolbar>(Resource.Id.toolbar));
            //this.SetSystemBarBackground (Color.ParseColor (DataHolder.Current.CurrentModule.Color));
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
            progressList         = new List <Progress>();

            ivGoBack        = FindViewById <ImageView>(Resource.Id.ivGoBack);
            ivGoBack.Click += ((sender, e) => PreviousLesson());
            ivGoFwd         = FindViewById <ImageView>(Resource.Id.ivGoFwd);
            ivGoFwd.Click  += ((sender, e) => NextLesson());
            btnNext         = FindViewById <FloatingActionButton>(Resource.Id.btnNext);
            btnNext.Click  += BtnNext_Click_CheckSolution;
            if (!Env.LollipopSupport)
            {
                var layoutParams = btnNext.LayoutParameters as RelativeLayout.LayoutParams;
                layoutParams.BottomMargin = (int)(-46 * Resources.DisplayMetrics.Density);
            }

            rvProgress = FindViewById <RecyclerView>(Resource.Id.rvProgress);
            rvProgress.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false));
            rvProgress.SetAdapter(new ProgressAdapter(progressList,
                                                      Color.ParseColor(DataHolder.Current.CurrentLevel.Color),
                                                      Color.ParseColor(DataHolder.Current.CurrentModule.Color),
                                                      Resources.DisplayMetrics.Density));
            txtCapitalAlphabet = FindViewById <TextView>(Resource.Id.txtCapitalAlphabet);
            txtLowerAlphabet   = FindViewById <TextView>(Resource.Id.txtLowerAlphabet);
            fragmentContainer  = FindViewById <FrameLayout>(Resource.Id.fragmentContainer);
            ivBadge            = FindViewById <ImageView>(Resource.Id.ivBadge);
            ivIrmgard          = FindViewById <ImageView>(Resource.Id.ivIrmgard);
            ivIrmgard.Click   += (s, e) => PlayOrStopInstruction();

            // Initially hide success image
            ivBadge.Visibility = ViewStates.Gone;

            praiseFilesAvail    = AssetHelper.Instance.List(Path.Combine(Common.AssetSoundDir, Common.AssetPraiseDir)).Select(s => Path.Combine(Common.AssetPraiseDir, s)).ToList();
            criticismFilesAvail = AssetHelper.Instance.List(Path.Combine(Common.AssetSoundDir, Common.AssetCriticismDir)).Select(s => Path.Combine(Common.AssetCriticismDir, s)).ToList();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Entry point to the program. Initializes everything and goes into a message processing
        /// loop. Idle time is used to render the scene.
        /// </summary>
        public static int Run(int adapter, int aa, int af, string mesh)
        {
#if DEBUG
            //mesh="meshes\\editorlandplane.nif";
            //mesh=@"meshes\dungeons\chargen\prisoncell01.nif";
            //mesh=@"meshes\furnituremarker01.nif";
            aa = 4;
            af = 16;
#endif

            AA = aa;
            AF = af;
            using (Framework sampleFramework = new Framework()) {
                BasicHLSL sample = new BasicHLSL(sampleFramework);

                sampleFramework.Disposing     += new EventHandler(sample.OnDestroyDevice);
                sampleFramework.DeviceLost    += new EventHandler(sample.OnLostDevice);
                sampleFramework.DeviceCreated += new DeviceEventHandler(sample.OnCreateDevice);
                sampleFramework.DeviceReset   += new DeviceEventHandler(sample.OnResetDevice);
                sampleFramework.SetWndProcCallback(new WndProcCallback(sample.OnMsgProc));

                sampleFramework.SetCallbackInterface(sample);
                try {
                    // Show the cursor and clip it when in full screen
                    sampleFramework.SetCursorSettings(true, true);

                    // Initialize
                    sample.InitializeApplication();

                    sampleFramework.Initialize(true, true);
                    sampleFramework.CreateWindow("Oblivion NIF viewer");
                    sampleFramework.Window.ClientSize  = new System.Drawing.Size(800, 600);
                    sampleFramework.Window.MinimumSize = sampleFramework.Window.Size;

                    sampleFramework.Window.KeyDown += new System.Windows.Forms.KeyEventHandler(sample.OnKeyEvent);
                    sampleFramework.CreateDevice(adapter, true, 800, 600, sample);

                    if (mesh != null)
                    {
                        sample.LoadNif(mesh);
                        if (Path.GetExtension(mesh).ToLower() != ".nif")
                        {
                            sample.sampleUi.GetCheckbox(ToggleCulling).IsChecked = false;
                            sample.sampleUi.GetComboBox(ChangeShader).SetSelected(1);
                            sample.shaderPicker_Changed(sample.sampleUi.GetComboBox(ChangeShader), null);
                        }
                    }

                    sampleFramework.MainLoop();
                }
#if (DEBUG)
                catch (Exception e) {
                    // In debug mode show this error (maybe - depending on settings)
                    sampleFramework.DisplayErrorMessage(e);
#else
                catch
                {
                    // In release mode fail silently
#endif
                    // Ignore any exceptions here, they would have been handled by other areas
                    return((sampleFramework.ExitCode == 0) ? 1 : sampleFramework.ExitCode); // Return an error code here
                }

                // Perform any application-level cleanup here. Direct3D device resources are released within the
                // appropriate callback functions and therefore don't require any cleanup code here.
                return(sampleFramework.ExitCode);
            }
        }
Ejemplo n.º 6
0
        void Initialize()
        {
            var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Stocks.db");

            _db = new Database(dbPath);
        }
Ejemplo n.º 7
0
        private void GUILeftArea()
        {
            GUILayout.Space(10.0f);

            GUILayout.Label("Graphs:");

            int oldVal = selectedGraph;

            selectedGraph = EditorGUILayout.Popup(selectedGraph, graphSelections);
            if (selectedGraph != oldVal)
            {
                if (ConfirmLoseUnsavedChanges())
                {
                    Grph = new Graph(GraphPaths[selectedGraph]);
                    string err = Grph.Load();
                    CamOffset = Grph.OutputPos.position - new Vector2(Mathf.RoundToInt(position.width * 0.5f),
                                                                      Mathf.RoundToInt(position.height * 0.5f));
                    if (err.Length > 0)
                    {
                        Debug.LogError("Error loading graph: " + err);
                    }
                }
                else
                {
                    selectedGraph = oldVal;
                }
            }

            GUILayout.Space(35.0f);


            if (GUILayout.Button("New Graph") && ConfirmLoseUnsavedChanges())
            {
                string savePath = EditorUtility.SaveFilePanelInProject("Choose Graph location",
                                                                       "MyGraph.gpug", "gpug",
                                                                       "Choose where to save the graph.");
                if (savePath != "")
                {
                    Graph  g   = new Graph(savePath);
                    string err = g.Save();
                    if (err.Length > 0)
                    {
                        EditorUtility.DisplayDialog("Error saving new graph",
                                                    "Error saving graph " + g.FilePath + ": " + err,
                                                    "OK");
                    }
                    else
                    {
                        Grph      = g;
                        CamOffset = Grph.OutputPos.position - new Vector2(Mathf.RoundToInt(position.width * 0.5f),
                                                                          Mathf.RoundToInt(position.height * 0.5f));
                        GraphPaths     = GraphEditorUtils.GetAllGraphsInProject();
                        NewNodeOptions = NodeOptionsGenerator.GenerateList();

                        Func <string, GUIContent> selector = (s => new GUIContent(Path.GetFileNameWithoutExtension(s), s));
                        graphSelections = GraphPaths.Select(selector).ToArray();

                        selectedGraph = -1;
                        string toFind = Path.GetFileNameWithoutExtension(Grph.FilePath);
                        for (int i = 0; i < graphSelections.Length; ++i)
                        {
                            if (graphSelections[i].text == toFind)
                            {
                                selectedGraph = i;
                                break;
                            }
                        }

                        UpdatePreview();
                    }
                }
            }

            GUILayout.Space(30.0f);

            if (Grph != null && unsavedStr.Length > 0)
            {
                if (GUILayout.Button("Save Changes"))
                {
                    string err = Grph.Save();
                    if (err.Length > 0)
                    {
                        Debug.LogError("Error saving graph: " + err);
                    }
                    unsavedStr = "";
                }

                if (GUILayout.Button("Discard Changes"))
                {
                    if (ConfirmLoseUnsavedChanges())
                    {
                        string err = Grph.Load();
                        if (err.Length > 0)
                        {
                            Debug.LogError("Unable to reload graph: " + err);
                        }
                        else
                        {
                            UpdatePreview();
                        }
                    }
                }
            }
            else
            {
                //Leave extra space for the buttons to appear once a change is made.
                GUILayout.Space(42.0f);
            }

            GUILayout.Space(35.0f);


            if (Grph != null)
            {
                GUILayout.Label("1D Hash:");
                string oldHash = Grph.Hash1;
                Grph.Hash1 = GUILayout.TextField(Grph.Hash1);
                if (oldHash != Grph.Hash1)
                {
                    if (!unsavedStr.Contains("1D hash func"))
                    {
                        unsavedStr += "1D hash func, ";
                    }
                    if (autoUpdatePreview)
                    {
                        UpdatePreview();
                    }
                }

                GUILayout.Space(10.0f);

                GUILayout.Label("2D Hash:");
                oldHash    = Grph.Hash2;
                Grph.Hash2 = GUILayout.TextField(Grph.Hash2);
                if (oldHash != Grph.Hash2)
                {
                    if (!unsavedStr.Contains("2D hash func"))
                    {
                        unsavedStr += "2D hash func, ";
                    }
                    if (autoUpdatePreview)
                    {
                        UpdatePreview();
                    }
                }

                GUILayout.Space(10.0f);

                GUILayout.Label("3D Hash:");
                oldHash    = Grph.Hash3;
                Grph.Hash3 = GUILayout.TextField(Grph.Hash3);
                if (oldHash != Grph.Hash3)
                {
                    if (!unsavedStr.Contains("3D hash func"))
                    {
                        unsavedStr += "3D hash func, ";
                    }
                    if (autoUpdatePreview)
                    {
                        UpdatePreview();
                    }
                }
            }

            GUILayout.Space(30.0f);


            //Noise previewing.
            if (Grph != null)
            {
                bool oldAutoUpdate = autoUpdatePreview;
                autoUpdatePreview = GUILayout.Toggle(autoUpdatePreview, "Auto-Update Preview");
                if (autoUpdatePreview && !oldAutoUpdate)
                {
                    UpdatePreview();
                }

                if (!autoUpdatePreview)
                {
                    if (GUILayout.Button("Update Preview"))
                    {
                        UpdatePreview();
                    }
                }

                if (previewNoise != null)
                {
                    //Flip the image vertically for unity GUI.
                    Rect texR = EditorGUILayout.GetControlRect(GUILayout.Width(previewNoise.width),
                                                               GUILayout.Height(previewNoise.height));
                    GUI.DrawTextureWithTexCoords(texR, previewNoise, new Rect(0.0f, 1.0f, 1.0f, -1.0f));
                }
            }


            //Update the title bar as well.
            if (Grph == null)
            {
                titleContent = new GUIContent("GPUG Editor");
            }
            else if (unsavedStr.Length > 0)
            {
                titleContent = new GUIContent("*" + Path.GetFileNameWithoutExtension(Grph.FilePath) + "*");
            }
            else
            {
                titleContent = new GUIContent(Path.GetFileNameWithoutExtension(Grph.FilePath));
            }
        }