private void InitRenderer() { //create a default camera, because it's required during the viewport's creation. camera = new Camera(); Scene.RootNode.CreateChildNode("camera", camera); //create the renderer and render window from window's native handle renderer = Renderer.CreateRenderer(); renderer.RegisterEntityRenderer(new LinesRenderer()); renderer.RegisterEntityRenderer(new BackgroundRenderer()); renderer.RegisterEntityRenderer(normalRenderer = new NormalRenderer()); //Right now we only support native window handle from Microsoft Windows //we'll support more platform on user's demand. window = renderer.RenderFactory.CreateRenderWindow(new RenderParameters(), WindowHandle.FromWin32(Handle)); //renderer.ShaderSet = CreateDepthShader(); //create 4 viewports, the viewport's area is meanless here because we'll change it to the right area in the SetViewports later viewports = new[] { window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)) }; SetViewports(1); SelectedViewport = viewports[0]; }
public CharacterSelection(IRenderWindow renderWindow, ISceneManager sceneManager, ITextDictionary textDictionary, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectionBackground, Palettes.Sky); createNewCharacterButton = createButton(eButtonType.Tall); // TODO: use strCreateNewCharacter -- need to get the text to split after 10 chars though. createNewCharacterButton.Text = textDictionary.Translate("strCreateNewCharacter");// "Create New".ToUpper(); createNewCharacterButton.Location = new Point(33, 467); createNewCharacterButton.OnActivate = () => sceneManager.ChangeScene(eSceneType.SelectHeroClass); deleteCharacterButton = createButton(eButtonType.Tall); deleteCharacterButton.Text = textDictionary.Translate("strDelete"); deleteCharacterButton.Location = new Point(433, 467); exitButton = createButton(eButtonType.Medium); exitButton.Text = textDictionary.Translate("strExit"); exitButton.Location = new Point(33, 540); exitButton.OnActivate = () => sceneManager.ChangeScene(eSceneType.MainMenu); okButton = createButton(eButtonType.Medium); okButton.Text = textDictionary.Translate("strOk"); okButton.Location = new Point(630, 540); okButton.Enabled = false; }
public MiniPanel(IRenderWindow renderWindow, Func <IGameHUD> getGameHud, IMouseInfoProvider mouseInfoProvider, IEnumerable <IPanel> panels, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; this.mouseInfoProvider = mouseInfoProvider; this._getGameHud = getGameHud; this.panels = panels; sprite = renderWindow.LoadSprite(ResourcePaths.MinipanelSmall, Palettes.Units, true); buttons = panelButtons.Select((x, i) => { var newBtn = createButton(x); var panel = panels.SingleOrDefault(o => o.PanelType == x.GetPanelType()); if (panel != null) { newBtn.OnActivate = () => OnPanelToggled?.Invoke(panel); panel.OnPanelClosed += Panel_OnPanelClosed; } return(newBtn); }).ToList().AsReadOnly(); }
public Game( IRenderWindow renderWindow, IResourceManager resourceManager, IMapEngine mapEngine, IGameState gameState, IKeyboardInfoProvider keyboardInfoProvider, Func <eButtonType, IButton> createButton, Func <IMiniPanel> createMiniPanel ) { this.renderWindow = renderWindow; this.resourceManager = resourceManager; this.mapEngine = mapEngine; this.gameState = gameState; this.keyboardInfoProvider = keyboardInfoProvider; panelSprite = renderWindow.LoadSprite(ResourcePaths.GamePanels, Palettes.Act1); healthManaSprite = renderWindow.LoadSprite(ResourcePaths.HealthMana, Palettes.Act1); gameGlobeOverlapSprite = renderWindow.LoadSprite(ResourcePaths.GameGlobeOverlap, Palettes.Act1); minipanel = createMiniPanel(); // Maybe? Not sure. // miniPanel.OnMenuActivate(); runButton = createButton(eButtonType.Run); runButton.Location = new Point(256, 570); runButton.OnToggle = OnRunToggle; menuButton = createButton(eButtonType.Menu); menuButton.Location = new Point(393, 561); menuButton.OnToggle = OnMenuToggle; }
public GameState( ISceneManager sceneManager, IResourceManager resourceManager, IPaletteProvider paletteProvider, IEngineDataManager engineDataManager, IRenderWindow renderWindow, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <IMapRenderer> getMapEngine, Func <eSessionType, ISessionManager> getSessionManager, Func <string, IRandomizedMapGenerator> getRandomizedMapGenerator ) { this.sceneManager = sceneManager; this.resourceManager = resourceManager; this.paletteProvider = paletteProvider; this.getMapEngine = getMapEngine; this.getSessionManager = getSessionManager; this.engineDataManager = engineDataManager; this.renderWindow = renderWindow; this.soundProvider = soundProvider; this.mpqProvider = mpqProvider; this.getRandomizedMapGenerator = getRandomizedMapGenerator; originalMouseCursor = renderWindow.MouseCursor; PlayerInfos = new List <PlayerInfo>(); mapDataLookup = new List <MapCellInfo>(); }
public OpenGLSceneProcessor(IServiceProvider serviceProvider, IRenderWindow renderWindow, SceneGraph sceneGraph) { _serviceProvider = serviceProvider; _cancellationTokenManager = _serviceProvider.GetRequiredService <CancellationTokenSource>(); _logger = _serviceProvider.GetRequiredService <ILogger <RenderWindow> >(); _shaderCompiler = _serviceProvider.GetRequiredService <IShaderCompiler>(); _textureLoader = _serviceProvider.GetRequiredService <ITextureLoader>(); _renderWindow = renderWindow; // This cannot be passed via the service provider otherwise there will be a cycle in the DI graph _sceneGraph = sceneGraph; _renderList = new LinkedList <IRenderCommand>(); _renderInfo = new RenderInfo(); _requestPicking = null; GL.LoadBindings(new GLFWBindingsContext()); // Get human readable log messages during debugging if (Debugger.IsAttached) { GL.Enable(EnableCap.DebugOutput); _debugProc = DebugMessageCallback; _gcHandle = GCHandle.Alloc(_debugProc); GL.DebugMessageCallback(_debugProc, IntPtr.Zero); } GL.Enable(EnableCap.DepthTest); // Save default frame buffer id for later blitting GL.GetInteger(GetPName.FramebufferBinding, out _defaultFrameBufferId); GL.BindFramebuffer(FramebufferTarget.Framebuffer, _defaultFrameBufferId); InitFrameBuffer(640, 360); }
public PanelFrame(IRenderWindow renderWindow, ePanelFrameType panelFrameType) { this.renderWindow = renderWindow; this.panelFrameType = panelFrameType; sprite = renderWindow.LoadSprite(ResourcePaths.Frame, Palettes.Units, new Point(0, 0), true); Location = new Point(0, 0); }
private void InitRenderer() { //create a default camera, because it's required during the viewport's creation. camera = new Camera(); Scene.RootNode.CreateChildNode("camera", camera); //create the renderer and render window from window's native handle renderer = Renderer.CreateRenderer(); //Right now we only support native window handle from Microsoft Windows //we'll support more platform on user's demand. window = renderer.RenderFactory.CreateRenderWindow(new RenderParameters(), Handle); //create 4 viewports, the viewport's area is meanless here because we'll change it to the right area in the SetViewports later viewports = new[] { window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)) }; SetViewports(1); //initialize shader for grid GLSLSource src = new GLSLSource(); src.VertexShader = @"#version 330 core layout (location = 0) in vec3 position; uniform mat4 matWorldViewProj; void main() { gl_Position = matWorldViewProj * vec4(position, 1.0f); }"; src.FragmentShader = @"#version 330 core out vec4 color; void main() { color = vec4(1, 1, 1, 1); }"; //define the input format used by GLSL vertex shader //the format is // struct ControlPoint { // FVector3 Position; //} VertexDeclaration fd = new VertexDeclaration(); fd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position); //compile shader from GLSL source code and specify the vertex input format gridShader = renderer.RenderFactory.CreateShaderProgram(src, fd); //connect GLSL uniform to renderer's internal variable gridShader.Variables = new ShaderVariable[] { new ShaderVariable("matWorldViewProj", VariableSemantic.MatrixWorldViewProj) }; SceneUpdated(""); }
public EventProcessor(IRenderWindow renderWindow, ILogger <EventProcessor> logger, CancellationTokenSource cancellationTokenManager, IAssertionProcessor scene) { _renderWindow = renderWindow; _logger = logger; _cancellationTokenManager = cancellationTokenManager; _scene = scene; _currentCameraOrientation = Constants.DefaultCameraOrientation; _logger.LogInformation("EventProcessor created"); }
public CharacterPanel( IRenderWindow renderWindow, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; panelSprite = renderWindow.LoadSprite(ResourcePaths.InventoryCharacterPanel, Palettes.Act1, FrameType.GetOffset(), true); closeButton = createButton(eButtonType.Close); closeButton.Location = panelSprite.Location + new Size(128, 388); closeButton.OnActivate = () => OnPanelClosed?.Invoke(this); }
public SdlTexture(IRenderWindow window, IBuffer source, bool isPrimary = false, uint? pixelFormat = null) { Initialize(window, isPrimary); Initialize(source.Width, source.Height); Renderer = SdlFactory.GetRenderer(window.Handle); textureAccess = TextureAccess.Static; this.pixelFormat = pixelFormat; if (Renderer == IntPtr.Zero) Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags); Handle = SdlFactory.CreateTexture(Renderer, source); SdlFactory.SetTextureBlendMod(Handle, BlendMode.None); }
public SdlTexture(IRenderWindow window, int? w = null, int? h = null, bool isPrimary = false, uint? pixelFormat = null) { Initialize(window, isPrimary); Initialize(w ?? window.Width, window.Height); Renderer = SdlFactory.GetRenderer(window.Handle); this.pixelFormat = pixelFormat; textureAccess = TextureAccess.Streaming; if (Renderer == IntPtr.Zero) Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags); Handle = SdlFactory.CreateTexture(Renderer, pixelFormat ?? Factory.PixelFormat, textureAccess, Width, Height); SdlFactory.SetTextureBlendMod(Handle, BlendMode.None); }
//ExStart:RenderView private void InitRenderer() { // Create a default camera, because it's required during the viewport's creation. camera = new Camera(); Scene.RootNode.CreateChildNode("camera", camera); // Create the renderer and render window from window's native handle renderer = Renderer.CreateRenderer(); // Right now we only support native window handle from Microsoft Windows // We'll support more platform on user's demand. window = renderer.RenderFactory.CreateRenderWindow(new RenderParameters(), Handle); // Create 4 viewports, the viewport's area is meanless here because we'll change it to the right area in the SetViewports later viewports = new[] { window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)), window.CreateViewport(camera, Color.Gray, RelativeRectangle.FromScale(0, 0, 1, 1)) }; SetViewports(1); //initialize shader for grid GLSLSource src = new GLSLSource(); src.VertexShader = @"#version 330 core layout (location = 0) in vec3 position; uniform mat4 matWorldViewProj; void main() { gl_Position = matWorldViewProj * vec4(position, 1.0f); }"; src.FragmentShader = @"#version 330 core out vec4 color; void main() { color = vec4(1, 1, 1, 1); }"; // Define the input format used by GLSL vertex shader the format is struct ControlPoint { FVector3 Position;} VertexDeclaration fd = new VertexDeclaration(); fd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position); // Compile shader from GLSL source code and specify the vertex input format gridShader = renderer.RenderFactory.CreateShaderProgram(src, fd); // Connect GLSL uniform to renderer's internal variable gridShader.Variables = new ShaderVariable[] { new ShaderVariable("matWorldViewProj", VariableSemantic.MatrixWorldViewProj) }; SceneUpdated(""); }
public MainMenu( IRenderWindow renderWindow, ISceneManager sceneManager, ITextDictionary textDictionary, IResourceManager resourceManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <eButtonType, IButton> createButton ) { this.renderWindow = renderWindow; this.sceneManager = sceneManager; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true; diabloLogoRight = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120)); diabloLogoRight.Blend = true; diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120)); diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120)); btnSinglePlayer = createButton(eButtonType.Wide); btnSinglePlayer.Text = textDictionary.Translate("strStartMenu1"); btnSinglePlayer.Location = new Point(264, 290); btnSinglePlayer.OnActivate = OnSinglePlayerClicked; btnWebsite = createButton(eButtonType.Wide); btnWebsite.Text = "Visit Github".ToUpper(); btnWebsite.Location = new Point(264, 330); btnWebsite.OnActivate = OnVisitWebsiteClicked; btnExit = createButton(eButtonType.Wide); btnExit.Text = textDictionary.Translate("strexitentiregame"); btnExit.Location = new Point(264, 500); btnExit.OnActivate = OnExitClicked; btnCredits = createButton(eButtonType.Short); btnCredits.Text = textDictionary.Translate("strGameCredits"); /* TODO: We apparently need a 'half font' option... */ btnCredits.Location = new Point(264, 470); btnCredits.OnActivate = OnCreditsClicked; labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static); versionLabel = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.02 Pre-Alpha"); urlLabel = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/"); urlLabel.TextColor = Color.Magenta; soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle)); soundProvider.PlaySong(); }
public Renderer(IRenderWindow renderWindow) { _renderWindow = renderWindow; VisibleTriangleDirection = ScreenSpaceTriangleDirection.Clockwise; //Texture = new WriteableBitmap(new BitmapImage(new Uri("Data/Textures/darkstone.png", UriKind.Relative))); TexturingEnabled = true; AmbientLightingEnabled = true; DiffuseLightingEnabled = true; SpecularLightingEnabled = true; Lights = new List <PointLight>(); _zBuffer = new double[_renderWindow.Framebuffer.PixelWidth, _renderWindow.Framebuffer.PixelHeight]; }
public SkillsPanel( IRenderWindow renderWindow, Func <eHero, int, IButton> createTreeButton, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; panelSprite = renderWindow.LoadSprite(ResourcePaths.GetHeroSkillPanel(hero), Palettes.Act1, FrameType.GetOffset(), true); treeButtons = Enumerable.Range(0, 3).Select(o => { var btn = createTreeButton(hero, o); btn.Location = FrameType.GetOffset(); btn.OnActivate = () => { ActivePanelIndex = o; }; return(btn); }).ToArray(); }
public MainMenu( IRenderWindow renderWindow, ISceneManager sceneManager, IResourceManager resourceManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <eButtonType, IButton> createButton, Func <eSceneType, IScene> getScene // Temporary until SDL load functions are sped up ) { this.renderWindow = renderWindow; this.sceneManager = sceneManager; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true; diabloLogoRight = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120)); diabloLogoRight.Blend = true; diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120)); diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120)); btnSinglePlayer = createButton(eButtonType.Wide); btnSinglePlayer.Text = "Single Player".ToUpper(); btnSinglePlayer.Location = new Point(264, 290); btnSinglePlayer.OnActivate = OnSinglePlayerClicked; btnWebsite = createButton(eButtonType.Wide); btnWebsite.Text = "Visit Github".ToUpper(); btnWebsite.Location = new Point(264, 460); btnWebsite.OnActivate = OnVisitWebsiteClicked; btnExit = createButton(eButtonType.Wide); btnExit.Text = "Exit Diablo II".ToUpper(); btnExit.Location = new Point(264, 500); btnExit.OnActivate = OnExitClicked; labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static); versionLabel = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.01 Pre-Alpha"); urlLabel = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/"); urlLabel.TextColor = Color.Magenta; soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle)); soundProvider.PlaySong(); }
public AssertionProcessor(IImageLoader imageLoader, ILogger <AssertionProcessor> logger, IRenderWindow renderWindow, CancellationTokenSource cancellationTokenManager, SceneGraph sceneGraph, BufferManager bufferManager) { _logger = logger; _renderWindow = renderWindow; _cancellationTokenManager = cancellationTokenManager; _logger.LogInformation("Scene created."); _imageLoader = imageLoader; _sceneGraph = sceneGraph; AssertionUpdatesChannel = Channel.CreateUnbounded <AssertionBatch>(); _partialObjectsWatchList = new LinkedList <Core.Scene.Triangle>(); _bufferManager = bufferManager; }
public Game( IRenderWindow renderWindow, IMapRenderer mapRenderer, IGameState gameState, IMouseInfoProvider mouseInfoProvider, IItemManager itemManager, ISessionManager sessionManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, IGameHUD gameHUD ) { this.renderWindow = renderWindow; this._mapRenderer = mapRenderer; this.gameState = gameState; this.mouseInfoProvider = mouseInfoProvider; this.sessionManager = sessionManager; this.gameHUD = gameHUD; //var item = itemManager.getItem("hdm"); }
public GameHUD( IRenderWindow renderWindow, IGameState gameState, IMouseInfoProvider mouseInfoProvider, Func <IMiniPanel> createMiniPanel, Func <eButtonType, IButton> createButton, Func <ePanelFrameType, IPanelFrame> createPanelFrame) { this.renderWindow = renderWindow; this.gameState = gameState; this.mouseInfoProvider = mouseInfoProvider; minipanel = createMiniPanel(); minipanel.OnPanelToggled += TogglePanel; leftPanelFrame = createPanelFrame(ePanelFrameType.Left); rightPanelFrame = createPanelFrame(ePanelFrameType.Right); runButton = createButton(eButtonType.Run); runButton.Location = new Point(256, 570); runButton.OnToggle = OnRunToggle; menuButton = createButton(eButtonType.Menu); menuButton.Location = new Point(393, 561); menuButton.OnToggle = minipanel.OnMenuToggle; menuButton.Toggle(); addStatButton = createButton(eButtonType.Skill); addStatButton.Location = new Point(207, 562); addStatButton.Enabled = addNewAttribute; addStatButton.OnActivate = () => TogglePanel(ePanelType.Character); addSkillButton = createButton(eButtonType.Skill); addSkillButton.Location = new Point(564, 562); addSkillButton.Enabled = addNewSkill; panelSprite = renderWindow.LoadSprite(ResourcePaths.GamePanels, Palettes.Act1, true); healthManaSprite = renderWindow.LoadSprite(ResourcePaths.HealthMana, Palettes.Act1, true); gameGlobeOverlapSprite = renderWindow.LoadSprite(ResourcePaths.GameGlobeOverlap, Palettes.Act1, true); }
public InventoryPanel(IRenderWindow renderWindow, IItemManager itemManager, IMapRenderer mapRenderer, ISessionManager sessionManager, Func <eItemContainerType, IItemContainer> createItemContainer, IGameState gameState, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; this.mapRenderer = mapRenderer; this.gameState = gameState; sessionManager.OnFocusOnPlayer += OnFocusOnPlayer; sessionManager.OnPlayerInfo += OnPlayerInfo; sessionManager.OnChangeEquipment += OnChangeEquipment; panelSprite = renderWindow.LoadSprite(ResourcePaths.InventoryCharacterPanel, Palettes.Units, FrameType.GetOffset(), true); closeButton = createButton(eButtonType.Close); closeButton.Location = panelSprite.Location + new Size(18, 384); closeButton.OnActivate = () => OnPanelClosed?.Invoke(this); secondaryLeftButton = createButton(eButtonType.SecondaryInvHand); secondaryLeftButton.Location = panelSprite.Location + new Size(15, 22); secondaryLeftButton.OnActivate = ToggleWeaponsSlot; secondaryRightButton = createButton(eButtonType.SecondaryInvHand); secondaryRightButton.Location = panelSprite.Location + new Size(246, 22); secondaryRightButton.OnActivate = ToggleWeaponsSlot; goldButton = createButton(eButtonType.GoldCoin); goldButton.Location = panelSprite.Location + new Size(84, 391); goldButton.OnActivate = OpenGoldDrop; headContainer = createItemContainer(eItemContainerType.Helm); headContainer.Location = panelSprite.Location + new Size(135, 5); headContainer.Slot = "head"; neckContainer = createItemContainer(eItemContainerType.Amulet); neckContainer.Location = panelSprite.Location + new Size(209, 34); neckContainer.Slot = "neck"; torsoContainer = createItemContainer(eItemContainerType.Armor); torsoContainer.Location = panelSprite.Location + new Size(135, 75); torsoContainer.Slot = "tors"; rightHandContainer = createItemContainer(eItemContainerType.Weapon); rightHandContainer.Location = panelSprite.Location + new Size(20, 47); rightHandContainer.Slot = "rarm"; leftHandContainer = createItemContainer(eItemContainerType.Weapon); leftHandContainer.Location = panelSprite.Location + new Size(253, 47); leftHandContainer.Slot = "larm"; secondaryLeftHandContainer = createItemContainer(eItemContainerType.Weapon); secondaryLeftHandContainer.Location = panelSprite.Location + new Size(24, 45); secondaryRightHandContainer = createItemContainer(eItemContainerType.Weapon); secondaryRightHandContainer.Location = panelSprite.Location + new Size(257, 45); beltContainer = createItemContainer(eItemContainerType.Belt); beltContainer.Location = panelSprite.Location + new Size(136, 178); beltContainer.Slot = "belt"; ringLeftContainer = createItemContainer(eItemContainerType.Ring); ringLeftContainer.Location = panelSprite.Location + new Size(95, 179); ringLeftContainer.Slot = "rrin"; ringRightContainer = createItemContainer(eItemContainerType.Ring); ringRightContainer.Location = panelSprite.Location + new Size(209, 179); ringRightContainer.Slot = "lrin"; gloveContainer = createItemContainer(eItemContainerType.Glove); gloveContainer.Location = panelSprite.Location + new Size(20, 179); gloveContainer.Slot = "glov"; bootsContainer = createItemContainer(eItemContainerType.Boots); bootsContainer.Location = panelSprite.Location + new Size(251, 178); bootsContainer.Slot = "feet"; }
public SdlWindowSurface(IRenderWindow window) { this.Window = window; PrimaryBuffer = new SdlBuffer(Handle.ToStruct <SurfaceInfo>()); }
public IWindowSurface newSurface(IRenderWindow window) => new SdlWindowSurface(window);
public ITexture newTexture(IRenderWindow window, IBuffer info, bool isPrimary = false) => new SdlTexture(window, info, isPrimary);
public ITexture newTexture(IRenderWindow window, int?w = null, int?h = null, bool isPrimary = false) => new SdlTexture(window, w, h, isPrimary);
public MainMenu( IRenderWindow renderWindow, IPaletteProvider paletteProvider, IMPQProvider mpqProvider, IMouseInfoProvider mouseInfoProvider, IMusicProvider musicProvider, ISceneManager sceneManager, IResourceManager resourceManager, Func <eButtonType, IButton> createButton, Func <string, IScene> getScene // Temporary until SDL load functions are sped up ) { this.renderWindow = renderWindow; this.paletteProvider = paletteProvider; this.mpqProvider = mpqProvider; this.mouseInfoProvider = mouseInfoProvider; this.sceneManager = sceneManager; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true; diabloLogoRight = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120)); diabloLogoRight.Blend = true; diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120)); diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120)); btnSinglePlayer = createButton(eButtonType.Wide); btnSinglePlayer.Text = "Single Player".ToUpper(); btnSinglePlayer.Location = new Point(264, 290); btnSinglePlayer.OnActivate = OnSinglePlayerClicked; btnWebsite = createButton(eButtonType.Wide); btnWebsite.Text = "Visit Github".ToUpper(); btnWebsite.Location = new Point(264, 460); btnWebsite.OnActivate = OnVisitWebsiteClicked; btnExit = createButton(eButtonType.Wide); btnExit.Text = "Exit Diablo II".ToUpper(); btnExit.Location = new Point(264, 500); btnExit.OnActivate = OnExitClicked; labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static); versionLabel = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.01 Pre-Alpha"); urlLabel = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/"); urlLabel.TextColor = Color.Magenta; var loadingSprite = renderWindow.LoadSprite(ResourcePaths.LoadingScreen, Palettes.Loading, new Point(300, 400)); // Pre-load all the scenes for now until we fix the sdl load problem var scenesToLoad = new string[] { "Select Hero Class" }; for (int i = 0; i < scenesToLoad.Count(); i++) { renderWindow.Clear(); renderWindow.Draw(loadingSprite, (int)((float)loadingSprite.TotalFrames * ((float)i / (float)scenesToLoad.Count()))); renderWindow.Sync(); getScene(scenesToLoad[i]); } /* * musicProvider.LoadSong(mpqProvider.GetStream("data\\global\\music\\introedit.wav")); * * musicProvider.PlaySong(); */ }
public InventoryPanel(IRenderWindow renderWindow, IItemManager itemManager, Func <eItemContainerType, IItemContainer> createItemContainer, Func <eButtonType, IButton> createButton) { this.renderWindow = renderWindow; panelSprite = renderWindow.LoadSprite(ResourcePaths.InventoryCharacterPanel, Palettes.Units, FrameType.GetOffset(), true); closeButton = createButton(eButtonType.Close); closeButton.Location = panelSprite.Location + new Size(18, 384); closeButton.OnActivate = () => OnPanelClosed?.Invoke(this); secondaryLeftButton = createButton(eButtonType.SecondaryInvHand); secondaryLeftButton.Location = panelSprite.Location + new Size(15, 22); secondaryLeftButton.OnActivate = ToggleWeaponsSlot; secondaryLeftButton.ClickableRect = new Size(0, 20); secondaryLeftButton.AllowFrameChange = false; secondaryRightButton = createButton(eButtonType.SecondaryInvHand); secondaryRightButton.Location = panelSprite.Location + new Size(246, 22); secondaryRightButton.OnActivate = ToggleWeaponsSlot; secondaryRightButton.ClickableRect = new Size(0, 20); secondaryRightButton.AllowFrameChange = false; goldButton = createButton(eButtonType.GoldCoin); goldButton.Location = panelSprite.Location + new Size(84, 391); goldButton.OnActivate = OpenGoldDrop; helmContainer = createItemContainer(eItemContainerType.Helm); helmContainer.Location = panelSprite.Location + new Size(135, 5); amuletContainer = createItemContainer(eItemContainerType.Amulet); amuletContainer.Location = panelSprite.Location + new Size(209, 34); armorContainer = createItemContainer(eItemContainerType.Armor); armorContainer.Location = panelSprite.Location + new Size(135, 75); leftHandContainer = createItemContainer(eItemContainerType.Weapon); leftHandContainer.Location = panelSprite.Location + new Size(20, 47); rightHandContainer = createItemContainer(eItemContainerType.Weapon); rightHandContainer.Location = panelSprite.Location + new Size(253, 47); secondaryLeftHandContainer = createItemContainer(eItemContainerType.Weapon); secondaryLeftHandContainer.Location = panelSprite.Location + new Size(24, 45); secondaryRightHandContainer = createItemContainer(eItemContainerType.Weapon); secondaryRightHandContainer.Location = panelSprite.Location + new Size(257, 45); beltContainer = createItemContainer(eItemContainerType.Belt); beltContainer.Location = panelSprite.Location + new Size(136, 178); ringtLeftContainer = createItemContainer(eItemContainerType.Ring); ringtLeftContainer.Location = panelSprite.Location + new Size(95, 179); ringtRightContainer = createItemContainer(eItemContainerType.Ring); ringtRightContainer.Location = panelSprite.Location + new Size(209, 179); gloveContainer = createItemContainer(eItemContainerType.Glove); gloveContainer.Location = panelSprite.Location + new Size(20, 179); bootsContainer = createItemContainer(eItemContainerType.Boots); bootsContainer.Location = panelSprite.Location + new Size(251, 178); }
protected void Initialize(IRenderWindow window, bool isPrimary) { Window = window; IsPrimary = isPrimary; }
public GrabScreenshot(IRenderWindow renderWindow, CancellationTokenSource cancellationTokenManager) { _renderWindow = renderWindow; _cancellationTokenManager = cancellationTokenManager; }
public SelectHeroClass( IRenderWindow renderWindow, IMouseInfoProvider mouseInfoProvider, ISceneManager sceneManager, ISoundProvider soundProvider, Func <eButtonType, IButton> createButton, Func <ITextBox> createTextBox, ITextDictionary textDictionary, IKeyboardInfoProvider keyboardInfoProvider, IMPQProvider mpqProvider, IGameState gameState ) { this.renderWindow = renderWindow; this.mouseInfoProvider = mouseInfoProvider; this.sceneManager = sceneManager; this.textDictionary = textDictionary; this.keyboardInfoProvider = keyboardInfoProvider; this.soundProvider = soundProvider; this.gameState = gameState; sfxDictionary = new Dictionary <string, byte[]>(); backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBackground, Palettes.Fechar); campfireSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectCampfire, Palettes.Fechar, new Point(380, 335)); campfireSprite.Blend = true; heroRenderInfo[eHero.Barbarian] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianUnselected, Palettes.Fechar, new Point(400, 330)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianUnselectedH, Palettes.Fechar, new Point(400, 330)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianForwardWalk, Palettes.Fechar, new Point(400, 330)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianForwardWalkOverlay, Palettes.Fechar, new Point(400, 330)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianSelected, Palettes.Fechar, new Point(400, 330)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianBackWalk, Palettes.Fechar, new Point(400, 330)), SelectionBounds = new Rectangle(364, 201, 90, 170), ForwardWalkTimeMs = 2500, BackWalkTimeMs = 1000 }; heroRenderInfo[eHero.Sorceress] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressUnselected, Palettes.Fechar, new Point(626, 352)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressUnselectedH, Palettes.Fechar, new Point(626, 352)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressForwardWalk, Palettes.Fechar, new Point(626, 352)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressForwardWalkOverlay, Palettes.Fechar, new Point(626, 352)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressSelected, Palettes.Fechar, new Point(626, 352)), SelectedSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressSelectedOverlay, Palettes.Fechar, new Point(626, 352)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressBackWalk, Palettes.Fechar, new Point(626, 352)), BackWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressBackWalkOverlay, Palettes.Fechar, new Point(626, 352)), SelectionBounds = new Rectangle(580, 240, 65, 160), ForwardWalkTimeMs = 2300, BackWalkTimeMs = 1200 }; heroRenderInfo[eHero.Sorceress].SelectedSpriteOverlay.Blend = true; heroRenderInfo[eHero.Sorceress].ForwardWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Sorceress].BackWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectNecromancerUnselected, Palettes.Fechar, new Point(300, 335)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectNecromancerUnselectedH, Palettes.Fechar, new Point(300, 335)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerForwardWalk, Palettes.Fechar, new Point(300, 335)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerForwardWalkOverlay, Palettes.Fechar, new Point(300, 335)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerSelected, Palettes.Fechar, new Point(300, 335)), SelectedSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerSelectedOverlay, Palettes.Fechar, new Point(300, 335)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerBackWalk, Palettes.Fechar, new Point(300, 335)), BackWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerBackWalkOverlay, Palettes.Fechar, new Point(300, 335)), SelectionBounds = new Rectangle(265, 220, 55, 175), ForwardWalkTimeMs = 2000, BackWalkTimeMs = 1500, }; heroRenderInfo[eHero.Necromancer].ForwardWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer].BackWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer].SelectedSpriteOverlay.Blend = true; heroRenderInfo[eHero.Paladin] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectPaladinUnselected, Palettes.Fechar, new Point(521, 338)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectPaladinUnselectedH, Palettes.Fechar, new Point(521, 338)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinForwardWalk, Palettes.Fechar, new Point(521, 338)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinForwardWalkOverlay, Palettes.Fechar, new Point(521, 338)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinSelected, Palettes.Fechar, new Point(521, 338)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinBackWalk, Palettes.Fechar, new Point(521, 338)), SelectionBounds = new Rectangle(490, 210, 65, 180), ForwardWalkTimeMs = 3400, BackWalkTimeMs = 1300 }; heroRenderInfo[eHero.Amazon] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAmazonUnselected, Palettes.Fechar, new Point(100, 339)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAmazonUnselectedH, Palettes.Fechar, new Point(100, 339)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonForwardWalk, Palettes.Fechar, new Point(100, 339)), //ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonForwardWalkOverlay, Palettes.Fechar, new Point(100, 339)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonSelected, Palettes.Fechar, new Point(100, 339)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonBackWalk, Palettes.Fechar, new Point(100, 339)), SelectionBounds = new Rectangle(70, 220, 55, 200), ForwardWalkTimeMs = 2200, BackWalkTimeMs = 1500 }; heroRenderInfo[eHero.Assassin] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinUnselected, Palettes.Fechar, new Point(231, 365)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinUnselectedH, Palettes.Fechar, new Point(231, 365)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinForwardWalk, Palettes.Fechar, new Point(231, 365)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinSelected, Palettes.Fechar, new Point(231, 365)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinBackWalk, Palettes.Fechar, new Point(231, 365)), SelectionBounds = new Rectangle(175, 235, 50, 180), ForwardWalkTimeMs = 3800, BackWalkTimeMs = 1500 }; heroRenderInfo[eHero.Druid] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidUnselected, Palettes.Fechar, new Point(720, 370)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidUnselectedH, Palettes.Fechar, new Point(720, 370)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidForwardWalk, Palettes.Fechar, new Point(720, 370)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidSelected, Palettes.Fechar, new Point(720, 370)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidBackWalk, Palettes.Fechar, new Point(720, 370)), SelectionBounds = new Rectangle(680, 220, 70, 195), ForwardWalkTimeMs = 4800, BackWalkTimeMs = 1500 }; headingFont = renderWindow.LoadFont(ResourcePaths.Font30, Palettes.Units); heroDescFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Units); uiFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Units); headingLabel = renderWindow.CreateLabel(headingFont); headingLabel.Text = textDictionary.Translate("strSelectHeroClass"); headingLabel.Location = new Point(400 - (headingLabel.TextArea.Width / 2), 17); heroClassLabel = renderWindow.CreateLabel(headingFont); heroClassLabel.Text = ""; heroClassLabel.Location = new Point(400 - (heroClassLabel.TextArea.Width / 2), 65); heroDesc1Label = renderWindow.CreateLabel(heroDescFont); heroDesc2Label = renderWindow.CreateLabel(heroDescFont); heroDesc3Label = renderWindow.CreateLabel(heroDescFont); characterNameLabel = renderWindow.CreateLabel(uiFont); characterNameLabel.Text = textDictionary.Translate("strCharacterName"); characterNameLabel.Location = new Point(320, 475); characterNameLabel.TextColor = Color.FromArgb(216, 196, 128); exitButton = createButton(eButtonType.Medium); exitButton.Text = textDictionary.Translate("strExit"); exitButton.Location = new Point(33, 540); exitButton.OnActivate = OnExitClicked; okButton = createButton(eButtonType.Medium); okButton.Text = textDictionary.Translate("strOk"); okButton.Location = new Point(630, 540); okButton.OnActivate = OnOkclicked; okButton.Enabled = false; characterNameTextBox = createTextBox(); characterNameTextBox.Text = ""; characterNameTextBox.Location = new Point(320, 493); Parallel.ForEach(new[] { ResourcePaths.SFXAmazonSelect, ResourcePaths.SFXAssassinSelect, ResourcePaths.SFXBarbarianSelect, ResourcePaths.SFXDruidSelect, ResourcePaths.SFXNecromancerSelect, ResourcePaths.SFXPaladinSelect, ResourcePaths.SFXSorceressSelect, ResourcePaths.SFXAmazonDeselect, ResourcePaths.SFXAssassinDeselect, ResourcePaths.SFXBarbarianDeselect, ResourcePaths.SFXDruidDeselect, ResourcePaths.SFXNecromancerDeselect, ResourcePaths.SFXPaladinDeselect, ResourcePaths.SFXSorceressDeselect }, (path => sfxDictionary.Add(path, mpqProvider.GetBytes(path)))); }