mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-02 10:15:32 +00:00
Merge pull request #188 from AnonymusRaccoon/new_win_size
UI Improvement (Vol. 2)
This commit is contained in:
@@ -80,7 +80,8 @@ const RAY::Vector2 &RAY::Window::getDimensions(void)
|
||||
RAY::Window &RAY::Window::setDimensions(const Vector2 &dims)
|
||||
{
|
||||
this->_dimensions = dims;
|
||||
SetWindowSize(dims.x, dims.y);
|
||||
if (this->_isOpen)
|
||||
SetWindowSize(dims.x, dims.y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -200,6 +201,11 @@ unsigned RAY::Window::getConfigFlags(void) const
|
||||
return this->_flags;
|
||||
}
|
||||
|
||||
bool RAY::Window::isFullscreen(void) const
|
||||
{
|
||||
return IsWindowFullscreen();
|
||||
}
|
||||
|
||||
RAY::Window &RAY::Window::setConfigFlags(unsigned flags)
|
||||
{
|
||||
if (this->_isOpen)
|
||||
@@ -212,4 +218,16 @@ RAY::Window &RAY::Window::toggleFullscreen()
|
||||
{
|
||||
ToggleFullscreen();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Window &RAY::Window::maximize()
|
||||
{
|
||||
MaximizeWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RAY::Window &RAY::Window::restore()
|
||||
{
|
||||
RestoreWindow();
|
||||
return *this;
|
||||
}
|
||||
@@ -148,6 +148,15 @@ namespace RAY {
|
||||
//! @brief set window to fullscreen
|
||||
RAY::Window &toggleFullscreen();
|
||||
|
||||
//! @return true if the window is fullscreen
|
||||
bool isFullscreen(void) const;
|
||||
|
||||
//! @brief set window to max size
|
||||
RAY::Window &maximize();
|
||||
|
||||
//! @brief reset window size
|
||||
RAY::Window &restore();
|
||||
|
||||
private:
|
||||
//! @brief Creates window, and opens it if openNow is set to true
|
||||
Window(int width, int height, std::string title, unsigned flags = 0, bool openNow = true);
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace BBM
|
||||
void Runner::enableRaylib(WAL::Wal &wal)
|
||||
{
|
||||
RAY::TraceLog::setLevel(LOG_WARNING);
|
||||
RAY::Window &window = RAY::Window::getInstance(1920, 1080, "Bomberman", FLAG_WINDOW_RESIZABLE);
|
||||
RAY::Window &window = RAY::Window::getInstance(1280, 720, "Bomberman", FLAG_WINDOW_RESIZABLE);
|
||||
wal.addSystem<AnimationsSystem>()
|
||||
.addSystem<AnimatorSystem>()
|
||||
.addSystem<RenderSystem>(window);
|
||||
|
||||
@@ -184,18 +184,15 @@ namespace BBM
|
||||
{
|
||||
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
|
||||
RAY::Window &window = RAY::Window::getInstance();
|
||||
unsigned oldFlags = window.getConfigFlags();
|
||||
|
||||
if (oldFlags == FLAG_WINDOW_RESIZABLE)
|
||||
window.toggleFullscreen();
|
||||
else
|
||||
window.setConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
if (text->getString().find("Off") != std::string::npos) {
|
||||
text->setText("Fullscreen: On");
|
||||
window.setDimensions(RAY::Vector2(1920, 1080));
|
||||
} else {
|
||||
text->setText("Fullscreen: Off");
|
||||
window.setDimensions(RAY::Vector2(1280, 720));
|
||||
}
|
||||
window.toggleFullscreen();
|
||||
})
|
||||
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
|
||||
{
|
||||
|
||||
@@ -206,10 +206,8 @@ namespace BBM
|
||||
int mapWidth = 16;
|
||||
int mapHeight = 16;
|
||||
int playerCount = 0;
|
||||
int playerID = 0;
|
||||
|
||||
for (auto &[_, lobby] : wal.getScene()->view<LobbyComponent>()) {
|
||||
playerID++;
|
||||
if (lobby.layout == ControllableComponent::NONE)
|
||||
continue;
|
||||
auto &player = Runner::createPlayer(*scene);
|
||||
@@ -220,8 +218,8 @@ namespace BBM
|
||||
auto *model = dynamic_cast<RAY3D::Model *>(player.getComponent<Drawable3DComponent>().drawable.get());
|
||||
model->setTextureToMaterial(MAP_DIFFUSE, "assets/player/textures/" + _colors[lobby.color] + ".png");
|
||||
std::string texturePath = "assets/player/ui/" + _colors[lobby.color] + ".png";
|
||||
int x = (playerID % 2 == 0) ? 1920 - 10 - 320 : 10;
|
||||
int y = playerID > 2 ? 1080 - 10 - 248 : 10;
|
||||
int x = (playerCount % 2 == 0) ? 1920 - 10 - 320 : 10;
|
||||
int y = (playerCount % 3 != 0) ? 1080 - 10 - 248 : 10;
|
||||
scene->addEntity("player color tile")
|
||||
.addComponent<PositionComponent>(x, y - 2, 0)
|
||||
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(x, y, 320, 248, _rayColors[lobby.color]);
|
||||
|
||||
@@ -60,8 +60,6 @@ namespace BBM
|
||||
Vector2f buttonPos(positionComponent.getX(), positionComponent.getY());
|
||||
Vector2f dimensions;
|
||||
|
||||
WAL::Entity *newButton = nullptr;
|
||||
|
||||
if (texture) {
|
||||
dimensions.x = texture->getDimensions().x;
|
||||
dimensions.y = texture->getDimensions().y;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace BBM
|
||||
void RenderSystem::resizeWindow(Vector2f &newDims)
|
||||
{
|
||||
newDims.y = (newDims.x * 720) / 1280;
|
||||
if (newDims.y < 720 || newDims.x < 1280) {
|
||||
if ((newDims.y < 720 || newDims.x < 1280)) {
|
||||
newDims.y = 720;
|
||||
newDims.x = 1280;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user