I am currently developing a UI. I have a few questions about class relationship interaction.
My class designs:
A Control class with subclasses Button & Label
A Screen class with subclass StartScreen
The StartScreen creates 2 Buttons and 1 Label
A UIManager which owns the StartScreen class
A RenderManager which controls setting up D3D and rendering
The UIManager and the RenderManager are both singletons
I am drawing the controls from the StartScreen by referencing the UIManager from the RenderManager as such:
hr = d3dDevice->BeginScene();
hr = spriteHandler->Begin(NULL);
hr = spriteHandler->Draw(UIManager::GetSingleton().ss->but_StartButton->GetUnClickedTexture(),
NULL, &UIManager::GetSingleton().ss->but_StartButton->GetCenter(), &UIManager::GetSingleton().ss->but_StartButton->GetPosition(), D3DCOLOR_XRGB(255, 255, 255));
hr = spriteHandler->End();
hr = d3dDevice->EndScene();
hr = d3dDevice->Present(NULL, NULL, NULL, NULL);
===================
This works (using the singleton reference to access the StartScreen control objects) however I think there may exist a cleaner way to do this. I am thinking about how to build the collision detection for button clicks and dont want to continue this method if there is a better way. Any thoughts?
Also, rather than hardcoding the call to Draw each time per control, how can I iterate through the controls and draw them in a better way?
Any help is greatly appreciated.
Thank you
My class designs:
A Control class with subclasses Button & Label
A Screen class with subclass StartScreen
The StartScreen creates 2 Buttons and 1 Label
A UIManager which owns the StartScreen class
A RenderManager which controls setting up D3D and rendering
The UIManager and the RenderManager are both singletons
I am drawing the controls from the StartScreen by referencing the UIManager from the RenderManager as such:
hr = d3dDevice->BeginScene();
hr = spriteHandler->Begin(NULL);
hr = spriteHandler->Draw(UIManager::GetSingleton().ss->but_StartButton->GetUnClickedTexture(),
NULL, &UIManager::GetSingleton().ss->but_StartButton->GetCenter(), &UIManager::GetSingleton().ss->but_StartButton->GetPosition(), D3DCOLOR_XRGB(255, 255, 255));
hr = spriteHandler->End();
hr = d3dDevice->EndScene();
hr = d3dDevice->Present(NULL, NULL, NULL, NULL);
===================
This works (using the singleton reference to access the StartScreen control objects) however I think there may exist a cleaner way to do this. I am thinking about how to build the collision detection for button clicks and dont want to continue this method if there is a better way. Any thoughts?
Also, rather than hardcoding the call to Draw each time per control, how can I iterate through the controls and draw them in a better way?
Any help is greatly appreciated.
Thank you