public TestState (IDictionary<Type, object> managers) : base(managers) { _sprites = new List<ICluwneDrawable>(); _UI = new List<GuiComponent>(); // setup everything we want to draw here. TextSprite CluwneEngineText = new TextSprite("TEST", "CluwneEngine", ResourceManager.GetFont("CALIBRI")); CluwneEngineText.Position = new Shared.Maths.Vector2(450,600); CluwneEngineText.Color = Color.DarkRed; CluwneEngineText.Text = " SS14: Running on CluwneEngine"; _sprites.Add(CluwneEngineText); // testing TextSprites TextSprite VersionText = new TextSprite("TEST", "version", ResourceManager.GetFont("CALIBRI")); VersionText.Position = new Shared.Maths.Vector2(500, 650); VersionText.Color = Color.Gold; VersionText.Text = "( Running SFML v2.0 ) " ; _sprites.Add(VersionText); TextSprite ProjNotDeadText = new TextSprite("TEST", "ProjNoDed", ResourceManager.GetFont("CALIBRI")); ProjNotDeadText.Position = new Shared.Maths.Vector2(512, 700); ProjNotDeadText.Color = Color.Gold; ProjNotDeadText.Text = " Project != Dead :)"; _sprites.Add(ProjNotDeadText); // testing CluwneSprite from SFML Texture Texture Cluwnelogo = new Texture(ResourceManager.GetImage("Textures/CluwneLibLogo.png")); CluwneSprite CluwneEngineLogo = new CluwneSprite(Cluwnelogo); CluwneEngineLogo.Position = new SFML.System.Vector2f(150,100); _sprites.Add(CluwneEngineLogo); Texture _Tiles = new Texture(ResourceManager.GetImage("Textures/0_Tiles.png")); CluwneSprite _TilesSprite = new CluwneSprite(_Tiles); _TilesSprite.Position = new SFML.System.Vector2f(50, 50); _sprites.Add(_TilesSprite); // Test a sprite extracted from the spritesheet CluwneSprite _OneTile = ResourceManager.GetSprite("locker_closed"); _OneTile.Position = new SFML.System.Vector2f(0, 0); _sprites.Add(_OneTile); ImageButton _button = new ImageButton { ImageNormal = "connect_norm", ImageHover = "connect_hover", }; _button.Update(0); _button.Position = new System.Drawing.Point(0, 0); _UI.Add(_button); Texture _Items = new Texture(ResourceManager.GetImage("Textures/0_Items.png")); CluwneSprite _TilesItems = new CluwneSprite(_Items); _TilesItems.Position = new SFML.System.Vector2f(0, 500); _sprites.Add(_TilesItems); Texture _Objects = new Texture(ResourceManager.GetImage("Textures/0_Objects.png")); CluwneSprite _TilesObjects = new CluwneSprite(_Objects); _TilesObjects.Position = new SFML.System.Vector2f(970, 400); _sprites.Add(_TilesObjects); Texture _Decals = new Texture(ResourceManager.GetImage("Textures/0_Decals.png")); CluwneSprite _TilesDecals = new CluwneSprite(_Decals); _TilesDecals.Position = new SFML.System.Vector2f(1000, 0); _sprites.Add(_TilesDecals); _floorTile = ResourceManager.GetSprite("floor_texture"); _testBatch = new SpriteBatch(); }
public MainScreen(IDictionary<Type, object> managers) : base(managers) { _Width = (int) CluwneLib.Screen.Size.X; _Height = (int) CluwneLib.Screen.Size.Y; _background = ResourceManager.GetSprite("coderart"); _btnConnect = new ImageButton { ImageNormal = "connect_norm", ImageHover = "connect_hover" }; _btnConnect.Clicked += _buttConnect_Clicked; _btnOptions = new ImageButton { ImageNormal = "options_norm", ImageHover = "options_hover" }; _btnOptions.Clicked += _buttOptions_Clicked; _btnExit = new ImageButton { ImageNormal = "exit_norm", ImageHover = "exit_hover" }; _btnExit.Clicked += _buttExit_Clicked; _txtConnect = new Textbox(100, ResourceManager) {Text = ConfigurationManager.GetServerAddress()}; _txtConnect.Position = new Vector2i(_Width / 3, _Height / 2); _txtConnect.OnSubmit += ConnectTextboxOnSubmit; Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); _lblVersion = new Label("v. " + fvi.FileVersion, "CALIBRI", ResourceManager); _lblVersion.Text.Color = new SFML.Graphics.Color(245, 245, 245); _lblVersion.Position = new Vector2i(_Width - _lblVersion.ClientArea.Width - 3, _Height - _lblVersion.ClientArea.Height - 3); _imgTitle = new SimpleImage { Sprite = "SpaceStationLogoColor", Position = new Vector2i(_Width-550, 100), }; _lblVersion.Update(0); _imgTitle.Update(0); _txtConnect.Position = new Vector2i(_imgTitle.ClientArea.Left + 40, _imgTitle.ClientArea.Bottom() + 50); _txtConnect.Update(0); _btnConnect.Position = new Vector2i(_txtConnect.Position.X, _txtConnect.ClientArea.Bottom() + 20); _btnConnect.Update(0); _btnOptions.Position = new Vector2i(_btnConnect.Position.X, _btnConnect.ClientArea.Bottom() + 20); _btnOptions.Update(0); _btnExit.Position = new Vector2i(_btnOptions.Position.X, _btnOptions.ClientArea.Bottom() + 20); _btnExit.Update(0); }
public Lobby(IDictionary<Type, object> managers) : base(managers) { _background = ResourceManager.GetSprite("mainbg"); _background.Smoothing = true; _imgMainBg = new SimpleImage { Sprite = "lobby_mainbg" }; _imgStatus = new SimpleImage { Sprite = "lobby_statusbar" }; _lblServer = new Label("SERVER:", "MICROGME", ResourceManager); _lblServer.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblServer); _lblServerInfo = new Label("LLJK#1", "MICROGME", ResourceManager); _lblServerInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblServerInfo); _lblMode = new Label("GAMEMODE:", "MICROGME", ResourceManager); _lblMode.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblMode); _lblModeInfo = new Label("SECRET", "MICROGME", ResourceManager); _lblModeInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblModeInfo); _lblPlayers = new Label("PLAYERS:", "MICROGME", ResourceManager); _lblPlayers.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblPlayers); _lblPlayersInfo = new Label("17/32", "MICROGME", ResourceManager); _lblPlayersInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblPlayersInfo); _lblPort = new Label("PORT:", "MICROGME", ResourceManager); _lblPort.Text.Color = Color.WhiteSmoke; _serverLabels.Add(_lblPort); _lblPortInfo = new Label("1212", "MICROGME", ResourceManager); _lblPortInfo.Text.Color = Color.DarkRed; _serverLabels.Add(_lblPortInfo); _tabs = new TabbedMenu { TopSprite = "lobby_tab_top", MidSprite = "lobby_tab_mid", BotSprite = "lobby_tab_bot", TabOffset = new Point(-8, 300), ZDepth = 2 }; _tabJob = new JobTab("lobbyTabJob", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_bcase" }; _tabs.AddTab(_tabJob); _tabJob._shwDepa.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwDepa_SelectionChanged); _tabJob._shwJobs.SelectionChanged += new Showcase.ShowcaseSelectionChangedHandler(_shwJobs_SelectionChanged); _tabCharacter = new TabContainer("lobbyTabCharacter", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_person" }; _tabs.AddTab(_tabCharacter); _tabObserve = new TabContainer("lobbyTabObserve", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_eye" }; _tabs.AddTab(_tabObserve); _tabServer = new PlayerListTab("lobbyTabServer", new Size(793, 450), ResourceManager) { tabSpriteName = "lobby_tab_info" }; _tabs.AddTab(_tabServer); _tabs.SelectTab(_tabJob); _lobbyChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager) { Size = new Vector2(780,225), }; _lobbyChat.Update(0); _imgChatBg = new SimpleImage() { Sprite = "lobby_chatbg", }; _lobbyChat.TextSubmitted += new Chatbox.TextSubmitHandler(_lobbyChat_TextSubmitted); _btnReady = new ImageButton() { ImageNormal = "lobby_ready", ImageHover = "lobby_ready_green", //BlendingMode = BlendingModes.None, ZDepth = 1 }; _btnReady.Clicked += _btnReady_Clicked; _btnReady.Update(0); _lblServerInfo.FixedWidth = 100; _lblModeInfo.FixedWidth = 90; _lblPlayersInfo.FixedWidth = 60; _lblPortInfo.FixedWidth = 50; UpdateGUIPosition(); }
public void Startup() { LastUpdate = DateTime.Now; Now = DateTime.Now; _cleanupList = new List<RenderTarget>(); _cleanupSpriteList = new List<CluwneSprite>(); UserInterfaceManager.DisposeAllComponents(); //Init serializer var serializer = IoCManager.Resolve<ISS14Serializer>(); _entityManager = new EntityManager(NetworkManager); IoCManager.Resolve<IEntityManagerContainer>().EntityManager = _entityManager; NetworkManager.MessageArrived += NetworkManagerMessageArrived; NetworkManager.RequestMap(); IoCManager.Resolve<IMapManager>().TileChanged += OnTileChanged; IoCManager.Resolve<IPlayerManager>().OnPlayerMove += OnPlayerMove; // TODO This should go somewhere else, there should be explicit session setup and teardown at some point. NetworkManager.SendClientName(ConfigurationManager.GetPlayerName()); // Create new _baseTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X, (uint)CluwneLib.Camera.ViewSize.Y, true); _cleanupList.Add(_baseTarget); _baseTargetSprite = new CluwneSprite(_baseTarget); _cleanupSpriteList.Add(_baseTargetSprite); _sceneTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X, (uint)CluwneLib.Camera.ViewSize.Y, true); _cleanupList.Add(_sceneTarget); _tilesTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X, (uint)CluwneLib.Camera.ViewSize.Y, true); _cleanupList.Add(_tilesTarget); _overlayTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X, (uint)CluwneLib.Camera.ViewSize.Y, true); _cleanupList.Add(_overlayTarget); // _overlayTarget.SourceBlend = AlphaBlendOperation.SourceAlpha; // _overlayTarget.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha; // _overlayTarget.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha; //_overlayTarget.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha; _composedSceneTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X, (uint)CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(_composedSceneTarget); _lightTarget = new RenderImage("lightTarget", (int)CluwneLib.Camera.ViewSize.X, (int)CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(_lightTarget); _lightTargetSprite = new CluwneSprite("lightTargetSprite", _lightTarget) { DepthWriteEnabled = false }; _cleanupSpriteList.Add(_lightTargetSprite); _lightTargetIntermediate = new RenderImage("lightTargetIntermediate", (int)CluwneLib.Camera.ViewSize.X, (int)CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(_lightTargetIntermediate); _lightTargetIntermediateSprite = new CluwneSprite("lightTargetIntermediateSprite", _lightTargetIntermediate) { DepthWriteEnabled = false }; _cleanupSpriteList.Add(_lightTargetIntermediateSprite); _gasBatch = new SpriteBatch(); //_gasBatch.SourceBlend = AlphaBlendOperation.SourceAlpha; //_gasBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha; //_gasBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha; //_gasBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha; _wallTopsBatch = new SpriteBatch(); //_wallTopsBatch.SourceBlend = AlphaBlendOperation.SourceAlpha; //_wallTopsBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha; //_wallTopsBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha; //_wallTopsBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha; _decalBatch = new SpriteBatch(); //_decalBatch.SourceBlend = AlphaBlendOperation.SourceAlpha; //_decalBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha; //_decalBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha; //_decalBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha; _floorBatch = new SpriteBatch(); _wallBatch = new SpriteBatch(); _gaussianBlur = new GaussianBlur(ResourceManager); _realScreenWidthTiles = (float)CluwneLib.Camera.ViewSize.X / MapManager.TileSize; _realScreenHeightTiles = (float)CluwneLib.Camera.ViewSize.Y / MapManager.TileSize; //Init GUI components _gameChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager); _gameChat.TextSubmitted += ChatTextboxTextSubmitted; UserInterfaceManager.AddComponent(_gameChat); //UserInterfaceManager.AddComponent(new StatPanelComponent(ConfigurationManager.GetPlayerName(), PlayerManager, NetworkManager, ResourceManager)); var statusBar = new StatusEffectBar(ResourceManager, PlayerManager); statusBar.Position = new Point((int)CluwneLib.Camera.ViewSize.X - 800, 10); UserInterfaceManager.AddComponent(statusBar); var hotbar = new Hotbar(ResourceManager); hotbar.Position = new Point(5, (int)CluwneLib.Camera.ViewSize.Y - hotbar.ClientArea.Height - 5); hotbar.Update(0); UserInterfaceManager.AddComponent(hotbar); #region Lighting // TODO: Convert all shaders to GLSL // TODO: Convert QuadRenderer to use SFML // TODO: Convert shadowMapResolver to use SFML // TODO: Convert this shit right here to use SFML /* quadRenderer = new QuadRenderer(); quadRenderer.LoadContent(); shadowMapResolver = new ShadowMapResolver(quadRenderer, ShadowmapSize.Size1024, ShadowmapSize.Size1024, ResourceManager); shadowMapResolver.LoadContent(); lightArea128 = new LightArea(ShadowmapSize.Size128); lightArea256 = new LightArea(ShadowmapSize.Size256); lightArea512 = new LightArea(ShadowmapSize.Size512); lightArea1024 = new LightArea(ShadowmapSize.Size1024); screenShadows = new RenderImage("screenShadows", CluwneLib.Camera.ViewSize.X, CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(screenShadows); screenShadows.UseDepthBuffer = false; shadowIntermediate = new RenderImage("shadowIntermediate", CluwneLib.Camera.ViewSize.X, CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(shadowIntermediate); shadowIntermediate.UseDepthBuffer = false; shadowBlendIntermediate = new RenderImage("shadowBlendIntermediate", CluwneLib.Camera.ViewSize.X, CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(shadowBlendIntermediate); shadowBlendIntermediate.UseDepthBuffer = false; playerOcclusionTarget = new RenderImage("playerOcclusionTarget", CluwneLib.Camera.ViewSize.X, CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8); _cleanupList.Add(playerOcclusionTarget); playerOcclusionTarget.UseDepthBuffer = false; lightBlendShader = IoCManager.Resolve<IResourceManager>().GetShader("lightblend"); finalBlendShader = IoCManager.Resolve<IResourceManager>().GetShader("finallight"); lightMapShader = IoCManager.Resolve<IResourceManager>().GetShader("lightmap"); playerVision = IoCManager.Resolve<ILightManager>().CreateLight(); playerVision.SetColor(Color.Transparent); playerVision.SetRadius(1024); playerVision.Move(Vector2.Zero); */ #endregion _handsGui = new HandsGui(); _handsGui.Position = new Point(hotbar.Position.X + 5, hotbar.Position.Y + 7); UserInterfaceManager.AddComponent(_handsGui); var combo = new HumanComboGui(PlayerManager, NetworkManager, ResourceManager, UserInterfaceManager); combo.Update(0); combo.Position = new Point(hotbar.ClientArea.Right - combo.ClientArea.Width + 5, hotbar.Position.Y - combo.ClientArea.Height - 5); UserInterfaceManager.AddComponent(combo); var healthPanel = new HealthPanel(); healthPanel.Position = new Point(hotbar.ClientArea.Right - 1, hotbar.Position.Y + 11); healthPanel.Update(0); UserInterfaceManager.AddComponent(healthPanel); var targetingUi = new TargetingGui(); targetingUi.Update(0); targetingUi.Position = new Point(healthPanel.ClientArea.Right - 1, healthPanel.ClientArea.Bottom - targetingUi.ClientArea.Height); UserInterfaceManager.AddComponent(targetingUi); var inventoryButton = new ImageButton { ImageNormal = "button_inv", Position = new Point(hotbar.Position.X + 172, hotbar.Position.Y + 2) }; inventoryButton.Update(0); inventoryButton.Clicked += inventoryButton_Clicked; UserInterfaceManager.AddComponent(inventoryButton); var statusButton = new ImageButton { ImageNormal = "button_status", Position = new Point(inventoryButton.ClientArea.Right, inventoryButton.Position.Y) }; statusButton.Update(0); statusButton.Clicked += statusButton_Clicked; UserInterfaceManager.AddComponent(statusButton); var craftButton = new ImageButton { ImageNormal = "button_craft", Position = new Point(statusButton.ClientArea.Right, statusButton.Position.Y) }; craftButton.Update(0); craftButton.Clicked += craftButton_Clicked; UserInterfaceManager.AddComponent(craftButton); var menuButton = new ImageButton { ImageNormal = "button_menu", Position = new Point(craftButton.ClientArea.Right, craftButton.Position.Y) }; menuButton.Update(0); menuButton.Clicked += menuButton_Clicked; UserInterfaceManager.AddComponent(menuButton); CluwneLib.Camera.SetWorldCenter( new Vector2(0.0f, 0.0f)); }
private void InitializeGUI() { //Init GUI components _gameChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager); _gameChat.TextSubmitted += ChatTextboxTextSubmitted; UserInterfaceManager.AddComponent(_gameChat); //UserInterfaceManager.AddComponent(new StatPanelComponent(ConfigurationManager.GetPlayerName(), PlayerManager, NetworkManager, ResourceManager)); var statusBar = new StatusEffectBar(ResourceManager, PlayerManager); statusBar.Position = new Vector2i((int)CluwneLib.Screen.Size.X /2, 400); UserInterfaceManager.AddComponent(statusBar); var hotbar = new Hotbar(ResourceManager); hotbar.Position = new Vector2i(0 , (int)CluwneLib.Screen.Size.Y - hotbar.ClientArea.Height - 5); hotbar.Update(0); UserInterfaceManager.AddComponent(hotbar); _handsGui = new HandsGui(); _handsGui.Position = new Vector2i(hotbar.Position.X + 5, hotbar.Position.Y + 7); UserInterfaceManager.AddComponent(_handsGui); var combo = new HumanComboGui(PlayerManager, NetworkManager, ResourceManager, UserInterfaceManager); combo.Update(0); combo.Position = new Vector2i(hotbar.ClientArea.Right() - combo.ClientArea.Width + 5, hotbar.Position.Y - combo.ClientArea.Height - 5); UserInterfaceManager.AddComponent(combo); var healthPanel = new HealthPanel(); healthPanel.Position = new Vector2i(hotbar.ClientArea.Right() - 1, hotbar.Position.Y + 11); healthPanel.Update(0); UserInterfaceManager.AddComponent(healthPanel); var targetingUi = new TargetingGui(); targetingUi.Update(0); targetingUi.Position = new Vector2i(healthPanel.Position.X + healthPanel.ClientArea.Width, healthPanel.Position.Y - 40); UserInterfaceManager.AddComponent(targetingUi); var inventoryButton = new ImageButton { ImageNormal = "button_inv", Position = new Vector2i(hotbar.Position.X + 172, hotbar.Position.Y + 2) }; inventoryButton.Update(0); inventoryButton.Clicked += inventoryButton_Clicked; UserInterfaceManager.AddComponent(inventoryButton); var statusButton = new ImageButton { ImageNormal = "button_status", Position = new Vector2i(inventoryButton.ClientArea.Right(), inventoryButton.Position.Y) }; statusButton.Update(0); statusButton.Clicked += statusButton_Clicked; UserInterfaceManager.AddComponent(statusButton); var craftButton = new ImageButton { ImageNormal = "button_craft", Position = new Vector2i(statusButton.ClientArea.Right(), statusButton.Position.Y) }; craftButton.Update(0); craftButton.Clicked += craftButton_Clicked; UserInterfaceManager.AddComponent(craftButton); var menuButton = new ImageButton { ImageNormal = "button_menu", Position = new Vector2i(craftButton.ClientArea.Right(), craftButton.Position.Y) }; menuButton.Update(0); menuButton.Clicked += menuButton_Clicked; UserInterfaceManager.AddComponent(menuButton); }