public override bool Load() { PPDFramework.Web.WebModInfo[] webMods = null; Action[] actions = { () => { webMods = PPDFramework.Web.WebManager.Instance.GetMods(); }, PPDScoreManager.Manager.Initialize, }; Parallel.ForEach(actions, (action) => action()); allowedModList = new AllowedModList { WebMods = webMods }; logger = new Logger(String.Format("{0}.txt", DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"))); Sound.AddSound(notifySoundPath); version = FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(this.GetType()).Location).FileVersion; userList = new ChangableList <User>(); userList.ItemChanged += userList_ItemChanged; movieManager = new MovieManager(device, GameHost); movieManager.MovieChanged += MovieManager_MovieChanged; movieManager.MovieChangeFailed += MovieManager_MovieChangeFailed; clientHandledData = new Queue <NetworkData>(); selfUser = new User { Name = PPDFramework.Web.WebManager.Instance.CurrentUserName, AccountId = PPDFramework.Web.WebManager.Instance.CurrentAccountId, CurrentState = UserState.NotReady, Color = RandomColorGenerator.GetColor(), IsSelf = true, IsHost = (bool)this.Param["AsHost"] }; this.AddChild(gameResultComponent = new GameResultComponent(device, GameHost, ResourceManager, Sound)); this.AddChild(leftMenu = new LeftMenu(device, GameHost, ResourceManager, Sound, movieManager, selfUser, userList, allowedModList)); leftMenu.SongSelected += leftMenu_SongSelected; leftMenu.ShowResult += leftMenu_ShowResult; leftMenu.UpdateScoreDB += leftMenu_UpdateScoreDB; leftMenu.RuleChanged += leftMenu_RuleChanged; leftMenu.TryToPlayGame += leftMenu_TryToPlayGame; leftMenu.ChangeLeader += leftMenu_ChangeLeader; leftMenu.KickUser += leftMenu_KickUser; this.AddChild(textBox = new DxTextBox(device, GameHost, ResourceManager)); this.AddChild((chatComponent = new ChatComponent(device, ResourceManager, GameHost) { Position = new SharpDX.Vector2(430, 0) })); this.AddChild(userListComponent = new UserListComponent(device, ResourceManager) { Position = new SharpDX.Vector2(10, 10) }); PictureObject bottom; this.AddChild(bottom = new PictureObject(device, ResourceManager, Utility.Path.Combine("menu_bottom.png")) { Position = new SharpDX.Vector2(0, 421) }); bottom.AddChild(new PictureObject(device, ResourceManager, Utility.Path.Combine("bottom_triangle.png")) { Position = new SharpDX.Vector2(7, 7) }); bottom.AddChild(new TextureString(device, Utility.Language["Menu"], 16, PPDColors.White) { Position = new SharpDX.Vector2(30, 5) }); bottom.AddChild(new PictureObject(device, ResourceManager, Utility.Path.Combine("bottom_circle.png")) { Position = new SharpDX.Vector2(157, 7) }); bottom.AddChild(stateString = new TextureString(device, Utility.Language["ChangeReadyState"], 16, PPDColors.White) { Position = new SharpDX.Vector2(180, 5) }); this.AddChild((bgd = new BackGroundDisplay(device, ResourceManager, "skins\\PPDMulti_BackGround.xml", "Menu"))); focusManager = new FocusManager(); focusManager.Focus(chatComponent); userList.Add(selfUser); chatComponent.Inputed += chatComponent_Inputed; textBox.LostFocused += textBox_LostFocused; leftMenu.Closed += leftMenu_Closed; if (selfUser.IsHost) { WebManager webManager = null; if (this.Param.ContainsKey("WebManager")) { webManager = this.Param["WebManager"] as WebManager; } RoomInfo roomInfo = null; if (this.Param.ContainsKey("RoomInfo")) { roomInfo = this.Param["RoomInfo"] as RoomInfo; } server = new PPDServer((int)Param["Port"], webManager, roomInfo, GameHost); server.FailedToCreateRoom += server_FailedToCreateRoom; client = new Client { Address = "127.0.0.1", Port = (int)Param["Port"] }; timer = new Timer(state => { server.Update(); }, null, 0, 1); } else { client = new Client { Address = (string)Param["IP"], Port = (int)Param["Port"] }; } client.Closed += client_Closed; client.Read += client_Read; byteReader = new TcpByteReader(); byteReader.ByteReaded += TcpByteReader_ByteReaded; if (server != null) { server.Start(); } client.Start(); if (client.HasConnection) { // send login data client.Write(MessagePackSerializer.Serialize(new AddUserNetworkData { UserName = selfUser.Name, AccountId = selfUser.AccountId, State = selfUser.CurrentState, Version = version })); } else { chatComponent.AddSystemMessage(Utility.Language["CannotConnectToHost"]); } // load SongInformation.All.ToArray(); return(true); }
public LeftMenu(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, ISound sound, MovieManager movieManager, User user, ChangableList <User> users, AllowedModList allowedModList) : base(device) { this.gameHost = gameHost; this.resourceManager = resourceManager; this.sound = sound; this.movieManager = movieManager; this.user = user; this.users = users; this.allowedModList = allowedModList; this.AddChild(songSelectSprite = new SpriteObject(device)); this.AddChild(gameRuleSprite = new SpriteObject(device)); this.AddChild(userSelectSprite = new SpriteObject(device)); this.AddChild(itemSettingSprite = new SpriteObject(device)); this.AddChild(modSprite = new SpriteObject(device)); this.AddChild(leftSprite = new SpriteObject(device)); leftSprite.AddChild(back = new PictureObject(device, resourceManager, Utility.Path.Combine("leftmenu.png"))); enables = new bool[] { false, false, false, true, true, true, true, true, true, true, true }; user.PropertyChanged += (name) => { if (name == "IsLeader") { enables[0] = enables[1] = enables[2] = user.IsLeader; if (!user.IsLeader) { if (mode >= Mode.SongSelect && mode <= Mode.UserManage) { mode = Mode.ItemSetting; } } (back[0] as TextureString).Color = GetTextColor(0); (back[1] as TextureString).Color = GetTextColor(1); (back[2] as TextureString).Color = GetTextColor(2); } }; back.AddChild(new TextureString(device, Utility.Language["ChangeScore"], 16, GetTextColor()) { Position = new Vector2(30, 70) }); back.AddChild(new TextureString(device, Utility.Language["ChangeRule"], 16, GetTextColor()) { Position = new Vector2(30, 100) }); back.AddChild(new TextureString(device, Utility.Language["PlayerManager"], 16, GetTextColor()) { Position = new Vector2(30, 130) }); back.AddChild(new TextureString(device, Utility.Language["ItemUseSetting"], 16, GetTextColor()) { Position = new Vector2(30, 160) }); back.AddChild(new TextureString(device, Utility.Language["TryToPlayGame"], 16, GetTextColor()) { Position = new Vector2(30, 190) }); back.AddChild(new TextureString(device, String.Format("{0}:{1}", Utility.Language["MuteSE"], Utility.Language["OFF"]), 16, GetTextColor()) { Position = new Vector2(30, 220) }); back.AddChild(new TextureString(device, String.Format("{0}:{1}", Utility.Language["Connect"], Utility.Language["OFF"]), 16, GetTextColor()) { Position = new Vector2(30, 250) }); back.AddChild(new TextureString(device, Utility.Language["Result"], 16, GetTextColor()) { Position = new Vector2(30, 280) }); back.AddChild(new TextureString(device, Utility.Language["UpdateDB"], 16, GetTextColor()) { Position = new Vector2(30, 310) }); back.AddChild(new TextureString(device, Utility.Language["Mod"], 16, GetTextColor()) { Position = new Vector2(30, 340) }); back.AddChild(new TextureString(device, user.IsHost ? Utility.Language["FinishHost"] : Utility.Language["LeaveRoom"], 16, GetTextColor()) { Position = new Vector2(30, 370) }); Connect = SkinSetting.Setting.Connect; (back[(int)Mode.Connect] as TextureString).Text = String.Format("{0}:{1}", Utility.Language["Connect"], Connect ? Utility.Language["ON"] : Utility.Language["OFF"]); mode = Mode.ItemSetting; select = new EffectObject(device, resourceManager, Utility.Path.Combine("greenflare.etd")) { Position = new Vector2(15, back[(int)mode].Position.Y + selectDiffY) }; select.PlayType = Effect2D.EffectManager.PlayType.ReverseLoop; select.Play(); select.Alignment = EffectObject.EffectAlignment.Center; select.Scale = new Vector2(0.4f, 0.4f); back.AddChild(select); leftSprite.Position = new Vector2(-back.Width, 0); Inputed += LeftMenu_Inputed; }