[Config] Moved to client. SCREEN_WIDTH, SCREEN_HEIGHT and GUI_SCALE renamed. [EngineConfig] Added for common config.
This commit is contained in:
parent
e798541304
commit
93cd68ffe9
@ -25,25 +25,6 @@
|
||||
|
||||
#include <gk/core/IntTypes.hpp>
|
||||
|
||||
namespace {
|
||||
constexpr const char *APP_NAME = "OpenMiner";
|
||||
|
||||
constexpr float DIST_NEAR = 0.1f;
|
||||
constexpr float DIST_FAR = 1000.0f;
|
||||
|
||||
constexpr int CHUNK_WIDTH = 16;
|
||||
constexpr int CHUNK_HEIGHT = 32;
|
||||
constexpr int CHUNK_DEPTH = 16;
|
||||
|
||||
constexpr int SEALEVEL = 4;
|
||||
}
|
||||
|
||||
// FIXME: These variables should be renamed
|
||||
extern float SCREEN_WIDTH;
|
||||
extern float SCREEN_HEIGHT;
|
||||
|
||||
extern int GUI_SCALE;
|
||||
|
||||
namespace Config {
|
||||
// Gameplay
|
||||
extern bool isFlyModeEnabled;
|
||||
@ -57,6 +38,9 @@ namespace Config {
|
||||
extern bool isWireframeModeEnabled;
|
||||
extern bool isFullscreenModeEnabled;
|
||||
extern float cameraFOV;
|
||||
extern u16 screenWidth;
|
||||
extern u16 screenHeight;
|
||||
extern u8 guiScale;
|
||||
|
||||
// Input
|
||||
extern u8 mouseSensitivity;
|
@ -53,7 +53,7 @@ void ClientApplication::init() {
|
||||
m_keyboardHandler.loadKeysFromFile("resources/config/keys.xml");
|
||||
gk::GamePad::init(m_keyboardHandler);
|
||||
|
||||
createWindow(SCREEN_WIDTH, SCREEN_HEIGHT, APP_NAME);
|
||||
createWindow(Config::screenWidth, Config::screenHeight, APP_NAME);
|
||||
m_window.setVerticalSyncEnabled(true);
|
||||
m_window.disableView();
|
||||
|
||||
@ -81,8 +81,8 @@ void ClientApplication::handleEvents() {
|
||||
m_window.setWindowMode(Config::isFullscreenModeEnabled ? gk::Window::Mode::Fullscreen : gk::Window::Mode::Windowed);
|
||||
}
|
||||
|
||||
if (SCREEN_WIDTH != m_window.getSize().x || SCREEN_HEIGHT != m_window.getSize().y) {
|
||||
m_window.resize(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
if (Config::screenWidth != m_window.getSize().x || Config::screenHeight != m_window.getSize().y) {
|
||||
m_window.resize(Config::screenWidth, Config::screenHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,6 @@
|
||||
*/
|
||||
#include "Config.hpp"
|
||||
|
||||
// FIXME: These variables should be renamed
|
||||
float SCREEN_WIDTH = 1600;
|
||||
float SCREEN_HEIGHT = 1050;
|
||||
|
||||
int GUI_SCALE = 3;
|
||||
|
||||
// Gameplay
|
||||
bool Config::isFlyModeEnabled = false;
|
||||
bool Config::isNoClipEnabled = false;
|
||||
@ -40,6 +34,9 @@ bool Config::isAmbientOcclusionEnabled = false;
|
||||
bool Config::isWireframeModeEnabled = false;
|
||||
bool Config::isFullscreenModeEnabled = false;
|
||||
float Config::cameraFOV = 70.0f;
|
||||
u16 Config::screenWidth = 1600;
|
||||
u16 Config::screenHeight = 1050;
|
||||
u8 Config::guiScale = 3;
|
||||
|
||||
// Input
|
||||
u8 Config::mouseSensitivity = 8;
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "Block.hpp"
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
#include "InventoryCube.hpp"
|
||||
#include "TextureAtlas.hpp"
|
||||
|
||||
@ -123,7 +124,7 @@ void InventoryCube::draw(gk::RenderTarget &target, gk::RenderStates states) cons
|
||||
|
||||
states.viewMatrix = gk::Transform::Identity;
|
||||
|
||||
states.projectionMatrix = glm::ortho(0.0f, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT, 0.0f, -40.0f, DIST_FAR);
|
||||
states.projectionMatrix = glm::ortho(0.0f, (float)Config::screenWidth, (float)Config::screenHeight, 0.0f, -40.0f, DIST_FAR);
|
||||
|
||||
states.texture = &m_textureAtlas.texture();
|
||||
states.vertexAttributes = gk::VertexAttribute::Only2d;
|
||||
|
@ -43,8 +43,8 @@ void MenuWidget::onEvent(const SDL_Event &event) {
|
||||
int x = i % m_width;
|
||||
int y = i / m_width;
|
||||
|
||||
m_buttons.at(i).setPosition(SCREEN_WIDTH / getScale().x / 2 - (m_width * (m_buttons.at(i).width() + s_horizontalSpacing) - s_horizontalSpacing) / 2 + x * (m_buttons.at(i).width() + s_horizontalSpacing),
|
||||
SCREEN_HEIGHT / getScale().y / 2 - (m_height * (m_buttons.at(i).height() + s_verticalSpacing) - s_verticalSpacing) / 2 + y * (m_buttons.at(i).height() + s_verticalSpacing), 0);
|
||||
m_buttons.at(i).setPosition(Config::screenWidth / getScale().x / 2.0f - (m_width * (m_buttons.at(i).width() + s_horizontalSpacing) - s_horizontalSpacing) / 2 + x * (m_buttons.at(i).width() + s_horizontalSpacing),
|
||||
Config::screenHeight / getScale().y / 2.0f - (m_height * (m_buttons.at(i).height() + s_verticalSpacing) - s_verticalSpacing) / 2 + y * (m_buttons.at(i).height() + s_verticalSpacing), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,8 +58,8 @@ TextButton &MenuWidget::addButton(const std::string &text, const TextButton::Cpp
|
||||
TextButton &button = m_buttons.back();
|
||||
button.setText(text);
|
||||
button.setCallback(callback);
|
||||
button.setPosition(SCREEN_WIDTH / getScale().x / 2 - (m_width * (button.width() + s_horizontalSpacing) - s_horizontalSpacing) / 2 + x * (button.width() + s_horizontalSpacing),
|
||||
SCREEN_HEIGHT / getScale().y / 2 - (m_height * (button.height() + s_verticalSpacing) - s_verticalSpacing) / 2 + y * (button.height() + s_verticalSpacing), 0);
|
||||
button.setPosition(Config::screenWidth / getScale().x / 2.0f - (m_width * (button.width() + s_horizontalSpacing) - s_horizontalSpacing) / 2 + x * (button.width() + s_horizontalSpacing),
|
||||
Config::screenHeight / getScale().y / 2.0f - (m_height * (button.height() + s_verticalSpacing) - s_verticalSpacing) / 2 + y * (button.height() + s_verticalSpacing), 0);
|
||||
return button;
|
||||
}
|
||||
|
||||
|
@ -268,10 +268,10 @@ glm::vec4 BlockCursor::findSelectedBlock(bool useDepthBuffer) const {
|
||||
if(useDepthBuffer) {
|
||||
// At which voxel are we looking? First, find out coords of the center pixel
|
||||
float depth;
|
||||
glCheck(glReadPixels(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth));
|
||||
glCheck(glReadPixels(Config::screenWidth / 2.0f, Config::screenHeight / 2.0f, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth));
|
||||
|
||||
glm::vec4 viewport = glm::vec4(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
glm::vec3 winCoord = glm::vec3(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, depth);
|
||||
glm::vec4 viewport = glm::vec4(0, 0, Config::screenWidth, Config::screenHeight);
|
||||
glm::vec3 winCoord = glm::vec3(Config::screenWidth / 2.0f, Config::screenHeight / 2.0f, depth);
|
||||
glm::vec3 objCoord = glm::unProject(winCoord,
|
||||
m_player.camera().getViewTransform().getMatrix(),
|
||||
m_player.camera().getTransform().getMatrix(), viewport);
|
||||
|
@ -28,8 +28,8 @@ Crosshair::Crosshair() {
|
||||
}
|
||||
|
||||
void Crosshair::setup() {
|
||||
float xFactor = SCREEN_WIDTH * SCREEN_HEIGHT / 100;
|
||||
float yFactor = SCREEN_HEIGHT * SCREEN_WIDTH / 100;
|
||||
float xFactor = Config::screenWidth * Config::screenHeight / 100;
|
||||
float yFactor = Config::screenHeight * Config::screenWidth / 100;
|
||||
|
||||
m_hShape.setSize(0.002 * xFactor, 0.0002 * yFactor);
|
||||
m_vShape1.setSize(0.0002 * xFactor, 0.001 * yFactor - m_hShape.height() / 2);
|
||||
@ -39,9 +39,9 @@ void Crosshair::setup() {
|
||||
m_vShape1.setFillColor(gk::Color{200, 200, 200, 180});
|
||||
m_vShape2.setFillColor(gk::Color{200, 200, 200, 180});
|
||||
|
||||
m_hShape.setPosition(SCREEN_WIDTH / 2 - m_hShape.width() / 2, SCREEN_HEIGHT / 2 - m_hShape.height() / 2, 0);
|
||||
m_vShape1.setPosition(SCREEN_WIDTH / 2 - m_vShape1.width() / 2, SCREEN_HEIGHT / 2 - m_hShape.height() / 2 - m_vShape1.height(), 0);
|
||||
m_vShape2.setPosition(SCREEN_WIDTH / 2 - m_vShape2.width() / 2, SCREEN_HEIGHT / 2 + m_hShape.height() / 2, 0);
|
||||
m_hShape.setPosition(Config::screenWidth / 2.0f - m_hShape.width() / 2, Config::screenHeight / 2.0f - m_hShape.height() / 2, 0);
|
||||
m_vShape1.setPosition(Config::screenWidth / 2.0f - m_vShape1.width() / 2, Config::screenHeight / 2.0f - m_hShape.height() / 2 - m_vShape1.height(), 0);
|
||||
m_vShape2.setPosition(Config::screenWidth / 2.0f - m_vShape2.width() / 2, Config::screenHeight / 2.0f + m_hShape.height() / 2, 0);
|
||||
}
|
||||
|
||||
void Crosshair::draw(gk::RenderTarget &target, gk::RenderStates states) const {
|
||||
|
@ -33,7 +33,7 @@ HUD::HUD(ClientPlayer &player, ClientWorld &world, ClientCommandHandler &client)
|
||||
m_blockCursor(player, world, client),
|
||||
m_debugOverlay(player, world)
|
||||
{
|
||||
setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
setScale(Config::guiScale, Config::guiScale, 1);
|
||||
|
||||
m_shader.createProgram();
|
||||
m_shader.addShader(GL_VERTEX_SHADER, "resources/shaders/basic.v.glsl");
|
||||
@ -44,13 +44,13 @@ HUD::HUD(ClientPlayer &player, ClientWorld &world, ClientCommandHandler &client)
|
||||
}
|
||||
|
||||
void HUD::setup() {
|
||||
m_orthoMatrix = glm::ortho(0.0f, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT, 0.0f);
|
||||
m_orthoMatrix = glm::ortho(0.0f, (float)Config::screenWidth, (float)Config::screenHeight, 0.0f);
|
||||
|
||||
m_hotbar.setPosition(SCREEN_WIDTH / getScale().x / 2 - m_hotbar.width() / 2, SCREEN_HEIGHT / getScale().y - m_hotbar.height(), 0);
|
||||
m_hotbar.setPosition(Config::screenWidth / getScale().x / 2 - m_hotbar.width() / 2, Config::screenHeight / getScale().y - m_hotbar.height(), 0);
|
||||
|
||||
m_blockInfoWidget.setPosition(SCREEN_WIDTH / getScale().x / 2 - m_blockInfoWidget.width() / 2, 2, 0);
|
||||
m_blockInfoWidget.setPosition(Config::screenWidth / getScale().x / 2 - m_blockInfoWidget.width() / 2, 2, 0);
|
||||
|
||||
m_fpsText.setPosition(SCREEN_WIDTH / getScale().x - 36, 2);
|
||||
m_fpsText.setPosition(Config::screenWidth / getScale().x - 36, 2);
|
||||
|
||||
m_crosshair.setup();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ void ClientCommandHandler::sendPlayerPlaceBlock(s32 x, s32 y, s32 z, u32 block)
|
||||
void ClientCommandHandler::sendPlayerInventoryRequest() {
|
||||
sf::Packet packet;
|
||||
packet << Network::Command::PlayerInventory
|
||||
<< u16(SCREEN_WIDTH) << u16(SCREEN_HEIGHT) << u8(GUI_SCALE);
|
||||
<< u16(Config::screenWidth) << u16(Config::screenHeight) << u8(Config::guiScale);
|
||||
m_client.send(packet);
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ void ClientCommandHandler::sendBlockActivated(const glm::vec4 &selectedBlock) {
|
||||
<< s32(selectedBlock.x)
|
||||
<< s32(selectedBlock.y)
|
||||
<< s32(selectedBlock.z)
|
||||
<< u16(SCREEN_WIDTH) << u16(SCREEN_HEIGHT) << u8(GUI_SCALE);
|
||||
<< u16(Config::screenWidth) << u16(Config::screenHeight) << u8(Config::guiScale);
|
||||
m_client.send(packet);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ GameState::GameState(const std::string &host, int port) {
|
||||
|
||||
m_textureAtlas = &gk::ResourceHandler::getInstance().get<TextureAtlas>("atlas-blocks");
|
||||
|
||||
m_camera.setAspectRatio((float)SCREEN_WIDTH / SCREEN_HEIGHT);
|
||||
m_camera.setAspectRatio((float)Config::screenWidth / Config::screenHeight);
|
||||
|
||||
initShaders();
|
||||
|
||||
@ -67,7 +67,7 @@ GameState::GameState(const std::string &host, int port) {
|
||||
void GameState::onEvent(const SDL_Event &event) {
|
||||
if (&m_stateStack->top() == this) {
|
||||
if (event.type == SDL_MOUSEMOTION) {
|
||||
if(SCREEN_WIDTH / 2 != event.motion.x || SCREEN_HEIGHT / 2 != event.motion.y) {
|
||||
if(Config::screenWidth / 2.0f != event.motion.x || Config::screenHeight / 2.0f != event.motion.y) {
|
||||
m_player.turnH(event.motion.xrel * 0.01 * Config::mouseSensitivity);
|
||||
m_player.turnV(-event.motion.yrel * 0.01 * Config::mouseSensitivity);
|
||||
|
||||
@ -96,10 +96,10 @@ void GameState::onEvent(const SDL_Event &event) {
|
||||
}
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
SCREEN_WIDTH = event.window.data1;
|
||||
SCREEN_HEIGHT = event.window.data2;
|
||||
Config::screenWidth = event.window.data1;
|
||||
Config::screenHeight = event.window.data2;
|
||||
|
||||
m_camera.setAspectRatio((float)SCREEN_WIDTH / SCREEN_HEIGHT);
|
||||
m_camera.setAspectRatio((float)Config::screenWidth / Config::screenHeight);
|
||||
m_hud.setup();
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ InterfaceState::InterfaceState(gk::ApplicationState *parent) : gk::ApplicationSt
|
||||
}
|
||||
|
||||
void InterfaceState::setup() {
|
||||
m_projectionMatrix = glm::ortho(0.0f, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT, 0.0f);
|
||||
m_projectionMatrix = glm::ortho(0.0f, (float)Config::screenWidth, (float)Config::screenHeight, 0.0f);
|
||||
|
||||
m_background.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
m_background.setSize(Config::screenWidth, Config::screenHeight);
|
||||
|
||||
// m_view.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
// m_view.setCenter(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
|
||||
// m_view.setSize(Config::screenWidth, Config::screenHeight);
|
||||
// m_view.setCenter(Config::screenWidth / 2.0f, Config::screenHeight / 2.0f);
|
||||
}
|
||||
|
||||
void InterfaceState::onEvent(const SDL_Event &event) {
|
||||
@ -50,8 +50,8 @@ void InterfaceState::onEvent(const SDL_Event &event) {
|
||||
if (m_parent)
|
||||
m_parent->onEvent(event);
|
||||
else {
|
||||
SCREEN_WIDTH = event.window.data1;
|
||||
SCREEN_HEIGHT = event.window.data2;
|
||||
Config::screenWidth = event.window.data1;
|
||||
Config::screenHeight = event.window.data2;
|
||||
}
|
||||
|
||||
setup();
|
||||
|
@ -46,7 +46,7 @@ LuaGUIState::LuaGUIState(ClientCommandHandler &client, ClientPlayer &player, Cli
|
||||
gk::Mouse::setCursorVisible(true);
|
||||
gk::Mouse::resetToWindowCenter();
|
||||
|
||||
m_mainWidget.setScale(GUI_SCALE, GUI_SCALE);
|
||||
m_mainWidget.setScale(Config::guiScale, Config::guiScale);
|
||||
|
||||
while (!packet.endOfPacket())
|
||||
loadGUI(player, world, packet);
|
||||
|
@ -38,7 +38,7 @@ PauseMenuState::PauseMenuState(gk::ApplicationState *parent)
|
||||
gk::Mouse::setCursorVisible(true);
|
||||
gk::Mouse::resetToWindowCenter();
|
||||
|
||||
m_menuWidget.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_menuWidget.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
|
||||
m_menuWidget.addButton("Back to Game", [this] (TextButton &) {
|
||||
gk::Mouse::setCursorGrabbed(true);
|
||||
|
@ -30,12 +30,12 @@ ServerConnectState::ServerConnectState() {
|
||||
m_textInput.setContent("localhost:4242");
|
||||
m_textInput.setCharacterLimit(15 + 1 + 6);
|
||||
m_textInput.setSize(400, 54);
|
||||
m_textInput.setPosition(SCREEN_WIDTH / 2 - m_textInput.getSize().x / 2, SCREEN_HEIGHT / 2 - m_textInput.getSize().y / 2);
|
||||
m_textInput.setPosition(Config::screenWidth / 2.0f - m_textInput.getSize().x / 2, Config::screenHeight / 2.0f - m_textInput.getSize().y / 2);
|
||||
m_textInput.setCursor("_");
|
||||
|
||||
m_connectButton.setText("Connect");
|
||||
m_connectButton.setPosition(SCREEN_WIDTH / 2 - m_connectButton.getGlobalBounds().width * GUI_SCALE / 2, SCREEN_HEIGHT - 340);
|
||||
m_connectButton.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_connectButton.setPosition(Config::screenWidth / 2.0f - m_connectButton.getGlobalBounds().width * Config::guiScale / 2.0f, Config::screenHeight - 340);
|
||||
m_connectButton.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
m_connectButton.setCallback([this](TextButton &) {
|
||||
size_t sep = m_textInput.content().find_first_of(':');
|
||||
|
||||
@ -56,8 +56,8 @@ ServerConnectState::ServerConnectState() {
|
||||
});
|
||||
|
||||
m_cancelButton.setText("Cancel");
|
||||
m_cancelButton.setPosition(SCREEN_WIDTH / 2 - m_cancelButton.getGlobalBounds().width * GUI_SCALE / 2, SCREEN_HEIGHT - 261);
|
||||
m_cancelButton.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_cancelButton.setPosition(Config::screenWidth / 2.0f - m_cancelButton.getGlobalBounds().width * Config::guiScale / 2.0f, Config::screenHeight - 261);
|
||||
m_cancelButton.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
m_cancelButton.setCallback([this](TextButton &) {
|
||||
m_stateStack->pop();
|
||||
});
|
||||
@ -67,9 +67,9 @@ void ServerConnectState::onEvent(const SDL_Event &event) {
|
||||
InterfaceState::onEvent(event);
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
m_textInput.setPosition(SCREEN_WIDTH / 2 - m_textInput.getSize().x / 2, SCREEN_HEIGHT / 2 - m_textInput.getSize().y / 2);
|
||||
m_connectButton.setPosition(SCREEN_WIDTH / 2 - m_connectButton.getGlobalBounds().width / 2, SCREEN_HEIGHT - 340);
|
||||
m_cancelButton.setPosition(SCREEN_WIDTH / 2 - m_cancelButton.getGlobalBounds().width / 2, SCREEN_HEIGHT - 261);
|
||||
m_textInput.setPosition(Config::screenWidth / 2.0f - m_textInput.getSize().x / 2, Config::screenHeight / 2.0f - m_textInput.getSize().y / 2);
|
||||
m_connectButton.setPosition(Config::screenWidth / 2.0f - m_connectButton.getGlobalBounds().width / 2, Config::screenHeight - 340);
|
||||
m_cancelButton.setPosition(Config::screenWidth / 2.0f - m_cancelButton.getGlobalBounds().width / 2, Config::screenHeight - 261);
|
||||
}
|
||||
|
||||
m_textInput.onEvent(event);
|
||||
|
@ -38,7 +38,7 @@ ServerLoadingState::ServerLoadingState(GameState &game) : m_game(game) {
|
||||
m_text.setCharacterSize(8 * 6);
|
||||
m_text.setString("Loading world...");
|
||||
m_text.setColor(gk::Color::White);
|
||||
m_text.setPosition(SCREEN_WIDTH / 2.0 - m_text.getLocalBounds().width / 2.0, 200);
|
||||
m_text.setPosition(Config::screenWidth / 2.0f - m_text.getLocalBounds().width / 2.0f, 200);
|
||||
|
||||
m_textShadow.setFont(gk::ResourceHandler::getInstance().get<gk::Font>("font-default"));
|
||||
m_textShadow.setCharacterSize(8 * 6);
|
||||
|
@ -35,10 +35,10 @@
|
||||
#include "World.hpp"
|
||||
|
||||
SettingsMenuState::SettingsMenuState(gk::ApplicationState *parent) : InterfaceState(parent) {
|
||||
m_menuWidget.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_menuWidget.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
|
||||
m_doneButton.setPosition(SCREEN_WIDTH / 2 - m_doneButton.getGlobalBounds().width * GUI_SCALE / 2, SCREEN_HEIGHT - 291);
|
||||
m_doneButton.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_doneButton.setPosition(Config::screenWidth / 2.0f - m_doneButton.getGlobalBounds().width * Config::guiScale / 2.0f, Config::screenHeight - 291);
|
||||
m_doneButton.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
m_doneButton.setText("Done");
|
||||
m_doneButton.setCallback([this] (TextButton &) {
|
||||
doneButtonAction();
|
||||
@ -51,7 +51,7 @@ void SettingsMenuState::onEvent(const SDL_Event &event) {
|
||||
InterfaceState::onEvent(event);
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
m_doneButton.setPosition(SCREEN_WIDTH / 2 - m_doneButton.getGlobalBounds().width / 2, SCREEN_HEIGHT - 291);
|
||||
m_doneButton.setPosition(Config::screenWidth / 2.0f - m_doneButton.getGlobalBounds().width / 2.0f, Config::screenHeight - 291);
|
||||
|
||||
if (&m_stateStack->top() != this)
|
||||
m_menuWidget.onEvent(event);
|
||||
@ -127,30 +127,30 @@ void SettingsMenuState::addGraphicsButtons() {
|
||||
addToggleButton("Sun Smooth Lighting", Config::isSunSmoothLightingEnabled, true);
|
||||
addToggleButton("Ambient Occlusion", Config::isAmbientOcclusionEnabled, false);
|
||||
|
||||
m_menuWidget.addButton("GUI Scale: " + std::to_string(GUI_SCALE), [] (TextButton &button) {
|
||||
GUI_SCALE = 1 + (GUI_SCALE + 1) % 3;
|
||||
button.setText("GUI Scale: " + std::to_string(GUI_SCALE));
|
||||
m_menuWidget.addButton("GUI Scale: " + std::to_string(Config::guiScale), [] (TextButton &button) {
|
||||
Config::guiScale = 1 + (Config::guiScale + 1) % 3;
|
||||
button.setText("GUI Scale: " + std::to_string(Config::guiScale));
|
||||
});
|
||||
|
||||
addToggleButton("Fullscreen", Config::isFullscreenModeEnabled, false);
|
||||
m_menuWidget.addButton("Resolution: " + std::to_string((int)SCREEN_WIDTH) + "x" + std::to_string((int)SCREEN_HEIGHT), [] (TextButton &button) {
|
||||
m_menuWidget.addButton("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight), [] (TextButton &button) {
|
||||
if (Config::isFullscreenModeEnabled) return;
|
||||
|
||||
// FIXME: Find a better way to do this
|
||||
if (SCREEN_WIDTH == 1600 && SCREEN_HEIGHT == 1050) {
|
||||
SCREEN_WIDTH = 1280;
|
||||
SCREEN_HEIGHT = 720;
|
||||
if (Config::screenWidth == 1600 && Config::screenHeight == 1050) {
|
||||
Config::screenWidth = 1280;
|
||||
Config::screenHeight = 720;
|
||||
}
|
||||
else if (SCREEN_WIDTH == 1280 && SCREEN_HEIGHT == 720) {
|
||||
SCREEN_WIDTH = 1920;
|
||||
SCREEN_HEIGHT = 1080;
|
||||
else if (Config::screenWidth == 1280 && Config::screenHeight == 720) {
|
||||
Config::screenWidth = 1920;
|
||||
Config::screenHeight = 1080;
|
||||
}
|
||||
else {
|
||||
SCREEN_WIDTH = 1600;
|
||||
SCREEN_HEIGHT = 1050;
|
||||
Config::screenWidth = 1600;
|
||||
Config::screenHeight = 1050;
|
||||
}
|
||||
|
||||
button.setText("Resolution: " + std::to_string((int)SCREEN_WIDTH) + "x" + std::to_string((int)SCREEN_HEIGHT));
|
||||
button.setText("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight));
|
||||
});
|
||||
|
||||
m_menuWidget.addButton("Use VSync: ON", [] (TextButton &) {}).setEnabled(false);
|
||||
|
@ -30,7 +30,7 @@
|
||||
TitleScreenState::TitleScreenState() {
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
m_menuWidget.setScale(GUI_SCALE, GUI_SCALE, 1);
|
||||
m_menuWidget.setScale(Config::guiScale, Config::guiScale, 1);
|
||||
|
||||
m_menuWidget.addButton("Play", [this] (TextButton &) {
|
||||
m_stateStack->push<ServerConnectState>();
|
||||
|
40
common/include/core/EngineConfig.hpp
Normal file
40
common/include/core/EngineConfig.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* OpenMiner
|
||||
* Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
#ifndef ENGINECONFIG_HPP_
|
||||
#define ENGINECONFIG_HPP_
|
||||
|
||||
namespace {
|
||||
// FIXME: Only used in Client
|
||||
constexpr const char *APP_NAME = "OpenMiner";
|
||||
|
||||
constexpr float DIST_NEAR = 0.1f;
|
||||
constexpr float DIST_FAR = 1000.0f;
|
||||
|
||||
constexpr int CHUNK_WIDTH = 16;
|
||||
constexpr int CHUNK_HEIGHT = 32;
|
||||
constexpr int CHUNK_DEPTH = 16;
|
||||
|
||||
constexpr int SEALEVEL = 4;
|
||||
}
|
||||
|
||||
#endif // ENGINECONFIG_HPP_
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <gk/core/IntTypes.hpp>
|
||||
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
|
||||
struct LightNode {
|
||||
LightNode(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <gk/core/GameClock.hpp>
|
||||
|
||||
#include "Chunk.hpp"
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
#include "Registry.hpp"
|
||||
|
||||
Chunk::Chunk(s32 x, s32 y, s32 z, World &world) : m_world(world) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <gk/resource/ResourceHandler.hpp>
|
||||
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
#include "World.hpp"
|
||||
|
||||
bool World::isReloadRequested = false;
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <gk/core/IntTypes.hpp>
|
||||
|
||||
#include "Config.hpp"
|
||||
#include "Chunk.hpp"
|
||||
|
||||
class ServerCommandHandler;
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
#include <gk/core/GameClock.hpp>
|
||||
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
#include "Network.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "ServerCommandHandler.hpp"
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
#include "Config.hpp"
|
||||
#include "EngineConfig.hpp"
|
||||
#include "Registry.hpp"
|
||||
#include "ServerChunk.hpp"
|
||||
#include "TerrainGenerator.hpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user