public MyDialogueSentence(MyActorEnum speaker, MySoundCuesEnum?cue, MyDialoguesWrapperEnum text, float noise = 0.0f, float pauseBefore_ms = 0.0f, MyActorEnum?listener = null) { Actor = speaker; Listener = listener; Cue = cue; Text = text; PauseBefore_ms = pauseBefore_ms; SentenceTime_ms = MathHelper.Clamp(MyDialoguesWrapper.Get(Text).Length * 66, MIN_SENTENCE_TIME, MAX_SENTENCE_TIME) + PauseBefore_ms; MyCommonDebugUtils.AssertDebug(noise >= 0 && noise <= 1, "Bad dialogue sentence noise value!"); Noise = noise; if (MyActorConstants.IsNoiseActor(speaker)) { Noise = 1f; } }
public MyMinerGame(ServiceContainer services) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame()::constructor"); MyMwcLog.WriteLine("MyMinerGame.Constructor() - START"); MyMwcLog.IncreaseIndent(); Services = services; // we want check objectbuilders, prefab's configurations, gameplay constants and building specifications MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Checks"); MyMwcObjectBuilder_Base.Check(); MyPrefabConstants.Check(); MyGameplayConstants.Check(); MyBuildingSpecifications.Check(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("Preallocate"); Preallocate(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("IsAdmin"); WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity); bool IsAdmin = windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator); MyMwcLog.WriteLine("IsAdmin " + IsAdmin.ToString()); MyMwcLog.WriteLine("Game dir: " + GameDir); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyCustomGraphicsDeviceManagerDX"); #if !DEBUG try { #endif this.Exiting += MyMinerGame_Exiting; this.Activated += MyMinerGame_OnActivated; this.Deactivated += MyMinerGame_OnDeactivated; this.m_InvokeQueue = new ConcurrentQueue <Tuple <ManualResetEvent, Action> >(); this.m_MainThread = Thread.CurrentThread; GraphicsDeviceManager = new MyCustomGraphicsDeviceManagerDX(this); m_isGraphicsSupported = GraphicsDeviceManager.ChangeProfileSupport(); m_isGraphicsSupported = true; if (m_isGraphicsSupported) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.HookEventHandlers"); MyVideoModeManager.HookEventHandlers(); //Content = new MyCustomContentManager(Services, ContentDir); // Content = new SharpDX.Toolkit.Content.ContentManager(Services); RootDirectory = Path.Combine(GameDir, "Content"); RootDirectoryDebug = Path.GetFullPath(System.IO.Path.Combine(GameDir, "..\\..\\..\\Content")); RootDirectoryEffects = RootDirectory; Static = this; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitNumberOfCores"); InitNumberOfCores(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogApplicationInformation"); MyVideoModeManager.LogApplicationInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogInformation"); MyVideoModeManager.LogInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyVideoModeManager.LogEnvironmentInformation"); MyVideoModeManager.LogEnvironmentInformation(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyPlugins.LoadContent"); MyPlugins.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyConfig.Load"); MyConfig.Load(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyMath.Init"); MyMath.Init(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyTextsWrapper.Init"); MyTextsWrapper.Init(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyDialoguesWrapper.Init"); MyDialoguesWrapper.Init(); // If I don't set TargetElapsedTime, default value will be used, which is 60 times per second, and it will be more precise than if I calculate // it like below - SO I MUST BE DOING THE WRONG CALCULATION !!! // We use fixed timestep. Update() is called at this precise timesteps. If Update or Draw takes more time, Update will be called more time. Draw is called only after Update. #if RENDER_PROFILING || GPU_PROFILING IsFixedTimeStep = false; MyMinerGame.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = false; #else IsFixedTimeStep = MyFakes.FIXED_TIMESTEP; #endif } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("InitMultithreading"); InitMultithreading(); #if !DEBUG } catch (Exception ex) { // We are catching exceptions in constructor, because if error occures here, it app will start unloading // so we skip to UnloadContent and there we will get another exception (because app wasn't really loaded when unload started) // So we want original exception in log. MyMwcLog.WriteLine(ex); throw; } #endif MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyMinerGame.Constructor() - END"); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
private void OnGenerateListOfUnusedDialogues(MyGuiControlButton sender) { //get List<MyDialogueSentence> sentences = new List<MyDialogueSentence>(); foreach (MyDialogueEnum dialogueEnum in Enum.GetValues(typeof(MyDialogueEnum))) { MyDialogue dialogue = MyDialogueConstants.GetDialogue(dialogueEnum); foreach (MyDialogueSentence sentence in dialogue.Sentences) { if (sentence.Text != MyDialoguesWrapperEnum.Dlg_DialoguePlaceholder) sentences.Add(sentence); } } //sort sentences.Sort(DialogueSentencesComparer); HashSet<MySoundCuesEnum> soundCues = new HashSet<MySoundCuesEnum>(); foreach (MySoundCuesEnum soundEnum in Enum.GetValues(typeof(MySoundCuesEnum))) { if (Enum.GetName(typeof(MySoundCuesEnum), soundEnum).StartsWith("Dlg_")) soundCues.Add(soundEnum); } HashSet<MyDialoguesWrapperEnum> dialogueTexts = new HashSet<MyDialoguesWrapperEnum>(); foreach (MyDialoguesWrapperEnum textEnum in Enum.GetValues(typeof(MyDialoguesWrapperEnum))) { dialogueTexts.Add(textEnum); } //Remove used foreach (MyDialogueSentence sentence in sentences) { if (sentence.Cue.HasValue) soundCues.Remove(sentence.Cue.Value); dialogueTexts.Remove(sentence.Text); } //print var dialoguesPath = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "UnusedDialogues.txt"); using (var output = new StreamWriter(File.Open(dialoguesPath, FileMode.Create))) { StringBuilder line = new StringBuilder(); line.Append("Unused cues: "); output.WriteLine(line); foreach (MySoundCuesEnum soundCue in soundCues) { line.Clear(); line.Append("MySoundCuesEnum." + Enum.GetName(typeof(MySoundCuesEnum), soundCue)); output.WriteLine(line); } line.Clear(); line.AppendLine(); output.WriteLine(line); line.Clear(); line.Append("Unused texts: "); output.WriteLine(line); foreach (MyDialoguesWrapperEnum textEnum in dialogueTexts) { line.Clear(); line.Append("MyDialoguesWrapperEnum." + Enum.GetName(typeof(MyDialoguesWrapperEnum), textEnum)); line.Append(":"); line.Append(MyDialoguesWrapper.Get(textEnum).ToString()); output.WriteLine(line); } output.Flush(); output.Close(); } }
private void OnGenerateListOfDialogues(MyGuiControlButton sender) { /* List<string> dialoguesString = new List<string>(); foreach (MyDialoguesWrapperEnum textEnum in Enum.GetValues(typeof(MyDialoguesWrapperEnum))) { dialoguesString.Add(textEnum.ToString()); } dialoguesString.Sort(); var dialoguesPath = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "Dialogues.txt"); using (var output = new StreamWriter(File.Open(dialoguesPath, FileMode.Create))) { StringBuilder line = new StringBuilder(); foreach (string str in dialoguesString) { foreach (MyDialoguesWrapperEnum textEnum in Enum.GetValues(typeof(MyDialoguesWrapperEnum))) { if (textEnum.ToString() == str) { line.Clear(); foreach (MyDialogueEnum dialogueEnum in Enum.GetValues(typeof(MyDialogueEnum))) { MyDialogue dialogue = MyDialogueConstants.GetDialogue(dialogueEnum); foreach (MyDialogueSentence sentence in dialogue.Sentences) { if (sentence.Text == textEnum) { line.Append(sentence.Actor.ToString() + " (" + MyDialoguesWrapper.Get(textEnum).ToString() + ")"); break; } } } output.WriteLine(line); break; } } } output.Flush(); output.Close(); } */ //get List<MyDialogueSentence> sentences = new List<MyDialogueSentence>(); foreach (MyDialogueEnum dialogueEnum in Enum.GetValues(typeof(MyDialogueEnum))) { MyDialogue dialogue = MyDialogueConstants.GetDialogue(dialogueEnum); foreach(MyDialogueSentence sentence in dialogue.Sentences){ if(sentence.Text!=MyDialoguesWrapperEnum.Dlg_DialoguePlaceholder) sentences.Add(sentence); } } //sort sentences.Sort(DialogueSentencesComparer); //print var dialoguesPath = Path.Combine(MyFileSystemUtils.GetApplicationUserDataFolder(), "Dialogues.txt"); using (var output = new StreamWriter(File.Open(dialoguesPath, FileMode.Create))) { StringBuilder line = new StringBuilder(); foreach(MyDialogueSentence sentence in sentences) { line.Clear(); if (sentence.Cue.HasValue) { line.Append("MySoundCuesEnum." + Enum.GetName(typeof(MySoundCuesEnum), sentence.Cue.Value)); } else { line.Append("[NULL]"); } line.Append(" ("); line.Append(MyTextsWrapper.Get(MyActorConstants.GetActorProperties(sentence.Actor).DisplayName).ToString()); line.Append("): "); line.Append(MyDialoguesWrapper.Get(sentence.Text).ToString()); output.WriteLine(line); } output.Flush(); output.Close(); } }