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 ModPanel(PPDDevice device, IGameHost gameHost, PPDFramework.Resource.ResourceManager resourceManager, ISound sound, AllowedModList allowedModList) : base(device) { this.gameHost = gameHost; this.sound = sound; this.resourceManager = resourceManager; this.allowedModList = allowedModList; waitSprite = new SpriteObject(device); this.AddChild(waitSprite); waitSprite.AddChild(new TextureString(device, Utility.Language["InitializingMod"], 20, true, PPDColors.White) { Position = new Vector2(400, 220) }); waitSprite.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }); updateSprite = new SpriteObject(device) { Hidden = true }; this.AddChild(updateSprite); updateSprite.AddChild(new TextureString(device, Utility.Language["UpdatingMod"], 20, true, PPDColors.White) { Position = new Vector2(400, 220) }); updateSprite.AddChild(new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }); back = new PictureObject(device, resourceManager, Utility.Path.Combine("dialog_back.png")); black = new RectangleComponent(device, resourceManager, PPDColors.Black) { RectangleHeight = 450, RectangleWidth = 800, Alpha = 0.65f }; back.AddChild(new TextureString(device, Utility.Language["Mod"], 30, PPDColors.White) { Position = new Vector2(35, 30) }); var stackObject = new StackObject(device, updateMenu = new StackObject(device, new StackObject(device, new SpaceObject(device, 0, 2), new PictureObject(device, resourceManager, Utility.Path.Combine("square.png"))) { IsHorizontal = false }, new TextureString(device, String.Format(":{0}", Utility.Language["Update"]), 18, PPDColors.White)) { IsHorizontal = true }, new SpaceObject(device, 20, 0), settingMenu = new StackObject(device, new StackObject(device, new SpaceObject(device, 0, 2), new PictureObject(device, resourceManager, Utility.Path.Combine("delta.png"))) { IsHorizontal = false }, new TextureString(device, String.Format(":{0}", Utility.Language["Setting"]), 18, PPDColors.White)) { IsHorizontal = true }, new SpaceObject(device, 20, 0), new StackObject(device, new SpaceObject(device, 0, 2), new PictureObject(device, resourceManager, Utility.Path.Combine("checkgreen.png"))) { Position = new Vector2(0, 50), IsHorizontal = false }, new TextureString(device, String.Format(":{0}", Utility.Language["Available"]), 18, PPDColors.White) { Position = new Vector2(35, 50) }) { IsHorizontal = true }; back.AddChild(stackObject); stackObject.Update(); stackObject.Position = new Vector2(760 - stackObject.Width, 50); var sprite = new SpriteObject(device) { Position = new Vector2(50, 80) }; modListSprite = new SpriteObject(device); sprite.AddChild(modListSprite); sprite.AddChild(new TextureString(device, String.Format("{0}:", Utility.Language["Author"]), 20, PPDColors.White) { Position = new Vector2(425, 0) }); sprite.AddChild(author = new TextureString(device, "", 20, PPDColors.White) { Position = new Vector2(450, 30) }); sprite.AddChild(new TextureString(device, String.Format("{0}:", Utility.Language["Version"]), 20, PPDColors.White) { Position = new Vector2(425, 60) }); sprite.AddChild(version = new TextureString(device, "", 20, PPDColors.White) { Position = new Vector2(450, 90) }); sprite.AddChild(new TextureString(device, String.Format("{0}:", Utility.Language["Filename"]), 20, PPDColors.White) { Position = new Vector2(425, 120) }); sprite.AddChild(filename = new TextureString(device, "", 20, 240, PPDColors.White) { Position = new Vector2(450, 150) }); sprite.AddChild(notAvailable = new TextureString(device, Utility.Language["ModWarning"], 20, 280, 280, true, PPDColors.Red) { Position = new Vector2(425, 180), Hidden = true }); this.AddChild(scrollBar = new RectangleComponent(device, resourceManager, PPDColors.White) { Position = new Vector2(456, 80), RectangleHeight = 330, RectangleWidth = 5 }); this.AddChild(new RectangleComponent(device, resourceManager, PPDColors.White) { Position = new Vector2(465, 80), RectangleHeight = 330, RectangleWidth = 1 }); this.AddChild(sprite); this.AddChild(back); this.AddChild(black); Inputed += ModPanel_Inputed; GotFocused += ModPanel_GotFocused; }
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; }