public override void Init() { Application.Log("Program.Init"); ClientXmlFormatterBinder.Instance.BindClientTypes(); LoadControls(); SignalEvent(ProgramEventType.ProgramStarted); #if DEBUG RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init start"); #endif Content.ContentPath = Program.DataPath; Game.Map.GameEntity.ContentPool = Content; Bitmap b = new Bitmap(Common.FileSystem.Instance.OpenRead(Content.ContentPath + "/Interface/Cursors/MenuCursor1.png")); Graphics.Cursors.Arrow = NeutralCursor = Cursor = new System.Windows.Forms.Cursor(b.GetHicon()); Graphics.Interface.InterfaceScene.DefaultFont = Fonts.Default; if (Settings.DeveloperMainMenu) { MainMenuDefault = MainMenuType.DeveloperMainMenu; ProfileMenuDefault = ProfileMenuType.DeveloperMainMenu; } else if (Settings.ChallengeMapMode) { MainMenuDefault = MainMenuType.ChallengeMap; ProfileMenuDefault = ProfileMenuType.ChallengeMap; } else { MainMenuDefault = MainMenuType.MainMenu; ProfileMenuDefault = ProfileMenuType.ProfileMenu; } if (Settings.DisplaySettingsForm) { OpenDeveloperSettings(); } //Graphics.Content.DefaultModels.Load(Content, Device9); InterfaceScene = new Graphics.Interface.InterfaceScene(); InterfaceScene.View = this; ((Graphics.Interface.Control)InterfaceScene.Root).Size = new Vector2(Program.Settings.GraphicsDeviceSettings.Resolution.Width, Program.Settings.GraphicsDeviceSettings.Resolution.Height); InterfaceScene.Add(Interface); InterfaceScene.Add(AchievementsContainer); InterfaceScene.Add(PopupContainer); InterfaceScene.Add(FeedackOnlineControl); if (!String.IsNullOrEmpty(Program.Settings.BetaSurveyLink)) { var u = new Uri(Program.Settings.BetaSurveyLink); var s = u.ToString(); if (!u.IsFile) { Button survey = new Button { Text = "Beta survey", Anchor = Orientation.BottomRight, Position = new Vector2(10, 50), Size = new Vector2(110, 30) }; survey.Click += new EventHandler((o, e) => { Util.StartBrowser(s); }); InterfaceScene.Add(survey); } } InterfaceScene.Add(Tooltip); InterfaceScene.Add(MouseCursor); InputHandler = InterfaceManager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene }; // Adjust the main char skin mesh; remove the dummy weapons var mainCharSkinMesh = Program.Instance.Content.Acquire<SkinnedMesh>( new SkinnedMeshFromFile("Models/Units/MainCharacter1.x")); mainCharSkinMesh.RemoveMeshContainerByFrameName("sword1"); mainCharSkinMesh.RemoveMeshContainerByFrameName("sword2"); mainCharSkinMesh.RemoveMeshContainerByFrameName("rifle"); try { SoundManager = new Client.Sound.SoundManager(Settings.SoundSettings.AudioDevice, Settings.SoundSettings.Engine, Settings.SoundSettings.MinMaxDistance.X, Settings.SoundSettings.MinMaxDistance.Y, Common.FileSystem.Instance.OpenRead); SoundManager.Settings = Settings.SoundSettings; SoundManager.ContentPath = Program.DataPath + "/Sound/"; SoundManager.Muted = Settings.SoundSettings.Muted; SoundManager.LoadSounds(!Settings.ChallengeMapMode); if (SoundLoaded != null) SoundLoaded(SoundManager, null); SoundManager.Volume = Settings.SoundSettings.MasterVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Ambient).Volume = Settings.SoundSettings.AmbientVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Music).Volume = Settings.SoundSettings.MusicVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.SoundEffects).Volume = Settings.SoundSettings.SoundVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Interface).Volume = Settings.SoundSettings.SoundVolume; } catch (Client.Sound.SoundManagerException ex) { SendSoundFailureLog(ex); SoundManager = new Client.Sound.DummySoundManager(); System.Windows.Forms.MessageBox.Show( Locale.Resource.ErrorFailInitSoundDevice, Locale.Resource.ErrorFailInitSoundDeviceTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } //StateManager = new DummyDevice9StateManager(Device9); StateManager = new Device9StateManager(Device9); InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9) { Scene = InterfaceScene, StateManager = StateManager, #if PROFILE_INTERFACERENDERER PeekStart = () => ClientProfilers.IRPeek.Start(), PeekEnd = () => ClientProfilers.IRPeek.Stop() #endif }; InterfaceRenderer.Initialize(this); BoundingVolumesRenderer = new BoundingVolumesRenderer { StateManager = Program.Instance.StateManager, View = Program.Instance }; #if BETA_RELEASE Client.Settings defaultSettings = new Settings(); ValidateSettings("", defaultSettings, Settings); #endif if (Settings.QuickStartMap != null && Settings.QuickStartMap != "" && Common.FileSystem.Instance.FileExists("Maps/" + Settings.QuickStartMap + ".map")) { LoadNewState(new Game.Game("Maps/" + Settings.QuickStartMap)); return; } UpdateFeedbackOnlineControl(); System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler((o, e) => { FeedbackOnline = e.Reply != null && e.Reply.Status == System.Net.NetworkInformation.IPStatus.Success; UpdateFeedbackOnlineControl(); }); var statsUri = new Uri(Settings.StatisticsURI); p.SendAsync(statsUri.DnsSafeHost, null); if (Settings.DeveloperMainMenu) InitDeveloperMenu(); else if (Settings.ChallengeMapMode) InitChallengeMapMode(); else InitFullGame(); EnterMainMenuState(false); if(WindowMode == WindowMode.Fullscreen) MouseCursor.BringToFront(); AskAboutUpdate(); if (!String.IsNullOrEmpty(Program.Settings.StartupMessage)) { Dialog.Show(Program.Settings.StartupMessageTitle ?? "", Program.Settings.StartupMessage); } fixedFrameStepSW.Start(); Application.Log("Program.Init completed"); #if DEBUG RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init end"); #endif }
public override void Init() { Content.ContentPath = "Data"; InterfaceScene = new Graphics.Interface.InterfaceScene(this); InterfaceScene.Add(new Graphics.Interface.TextBox { Size = new Vector2(100, 20), Text = "TopRight", Anchor = Orientation.TopRight }); InterfaceScene.Add(new Graphics.Interface.TextBox { Size = new Vector2(100, 20), Text = "BottomLeft", Anchor = Orientation.BottomLeft }); InterfaceScene.Add(new Graphics.Interface.TextBox { Size = new Vector2(100, 20), Text = "BottomRight", Anchor = Orientation.BottomRight }); InterfaceScene.Add(new Graphics.Interface.Button { Size = new Vector2(100, 20), Text = "Button", Anchor = Orientation.Center }); InterfaceScene.Add(cb = new Graphics.Interface.Checkbox { Size = new Vector2(100, 20), Text = "Checkbox", Anchor = Orientation.Center, Position = new Vector2(0, 40) }); InterfaceScene.Add(pb = new Graphics.Interface.ProgressBar { Size = new Vector2(100, 100), Text = "Button", Anchor = Orientation.Bottom, MaxValue = 100, Value = 50, ProgressGraphic = new ImageGraphic { Texture = new TextureFromFile("cornellbox3.png"), //new TextureConcretizer { TextureDescription = new Graphics.Software.Textures.SingleColorTexture(Color.Red) }, TextureAnchor = Orientation.BottomLeft }, ProgressOrientation = Graphics.Interface.ProgressOrientation.BottomToTop }); InterfaceScene.Add(dpb = new Graphics.Interface.DeltaProgressBar { Size = new Vector2(140, 10), Anchor = Orientation.Center, MaxValue = 100, Value = 70, Position = new Vector2(0, -30), ProgressOrientation = Graphics.Interface.ProgressOrientation.LeftToRight }); Button bb; InterfaceScene.Add(bb = new Button { Size = new Vector2(50, 20), Text = "-", Anchor = Orientation.Center, Position = new Vector2(-30, -60) }); bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value - 20, 0, 100); }; InterfaceScene.Add(bb = new Button { Size = new Vector2(50, 20), Text = "+", Anchor = Orientation.Center, Position = new Vector2(30, -60) }); bb.Click += (sender, ea) => { dpb.Value = Common.Math.Clamp(dpb.Value + 20, 0, 100); }; InterfaceScene.Add(new Graphics.Interface.Console { Anchor = Orientation.Bottom, Position = new Vector2(0, 100), Size = new Vector2(400, 100) }); var f = new Graphics.Interface.Form { Size = new Vector2(300, 300) }; InterfaceScene.Add(f); b = new Graphics.Interface.Button { Size = new Vector2(100, 20), Text = "TopLeft", Anchor = Orientation.TopLeft }; f.AddChild(b); Control checker; InterfaceScene.Add(checker = new Control { Background = new ImageGraphic { Size = new Vector2(100, 100), Texture = new TextureFromFile("checker.png") }, Size = new Vector2(100, 100), Position = new Vector2(10, 30), Anchor = Orientation.TopRight, Clickable = true, PickingLocalBounding = new Common.Bounding.Chain { Boundings = new object[] { new BoundingBox(Vector3.Zero, new Vector3(1, 1, 0)), new MetaBoundingImageGraphic { Graphic = new ImageGraphic { Size = new Vector2(100, 100), Texture = new TextureFromFile("checker.png") }, } }, Shallow = true } }); InterfaceScene.Add(popupContainer); InterfaceScene.Add(new Form { Anchor = Orientation.Right, Size = new Vector2(100, 100), ControlBox = true }); tt = new Graphics.Interface.ToolTip(); tt.SetToolTip(pb, "This is a progress bar"); tt.SetToolTip(checker, "Checker"); InterfaceScene.Add(tt); if (Direct3DVersion == Direct3DVersion.Direct3D10) { InterfaceRenderer = new Graphics.Interface.InterfaceRenderer10(Device10) { Scene = InterfaceScene } } ; else { InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9) { Scene = InterfaceScene, StateManager = new Device9StateManager(Device9) } }; InterfaceRenderer.Initialize(this); InputHandler = Manager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene }; //bvr = new BoundingVolumesRenderer //{ // View = this, // StateManager = sm //}; } Graphics.Interface.ToolTip tt; Graphics.Interface.Button b;