[LuaGUI] Now provides SCREEN_WIDTH, SCREEN_HEIGHT and GUI_SCALE instead of them being hardcoded in init.lua.
This commit is contained in:
parent
41a46ba13b
commit
857c7e4060
@ -38,11 +38,10 @@ namespace {
|
||||
constexpr int SEALEVEL = 4;
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// FIXME: These variables should be renamed
|
||||
extern float SCREEN_WIDTH;
|
||||
extern float SCREEN_HEIGHT;
|
||||
|
||||
// FIXME
|
||||
extern int GUI_SCALE;
|
||||
|
||||
namespace Config {
|
||||
|
@ -22,11 +22,10 @@
|
||||
*/
|
||||
#include "Config.hpp"
|
||||
|
||||
// FIXME
|
||||
// FIXME: These variables should be renamed
|
||||
float SCREEN_WIDTH = 1600;
|
||||
float SCREEN_HEIGHT = 1050;
|
||||
|
||||
// FIXME
|
||||
int GUI_SCALE = 3;
|
||||
|
||||
// Gameplay
|
||||
|
@ -36,8 +36,8 @@ mod:block {
|
||||
|
||||
-- FIXME: Replace this by gui:set_size() and gui:set_centered()
|
||||
local gui_pos = {
|
||||
x = SCREEN_WIDTH / GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = SCREEN_HEIGHT / GUI_SCALE / 2.0 - 166 / 2.0
|
||||
x = gui.SCREEN_WIDTH / gui.GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = gui.SCREEN_HEIGHT / gui.GUI_SCALE / 2.0 - 166 / 2.0
|
||||
}
|
||||
|
||||
gui:furnace {
|
||||
|
@ -20,12 +20,6 @@
|
||||
--
|
||||
-- =====================================================================================
|
||||
--
|
||||
|
||||
-- FIXME
|
||||
SCREEN_WIDTH = 1600
|
||||
SCREEN_HEIGHT = 1050
|
||||
GUI_SCALE = 3
|
||||
|
||||
mod = LuaMod.new("default")
|
||||
|
||||
dofile("mods/default/blocks.lua")
|
||||
@ -71,8 +65,8 @@ function show_inventory(client)
|
||||
|
||||
-- FIXME: Replace this by gui:set_size() and gui:set_centered()
|
||||
local gui_pos = {
|
||||
x = SCREEN_WIDTH / GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = SCREEN_HEIGHT / GUI_SCALE / 2.0 - 166 / 2.0
|
||||
x = gui.SCREEN_WIDTH / gui.GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = gui.SCREEN_HEIGHT / gui.GUI_SCALE / 2.0 - 166 / 2.0
|
||||
}
|
||||
|
||||
gui:player_inventory {
|
||||
|
@ -35,8 +35,8 @@ mod:block {
|
||||
|
||||
-- FIXME: Replace this by gui:set_size() and gui:set_centered()
|
||||
local gui_pos = {
|
||||
x = SCREEN_WIDTH / GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = SCREEN_HEIGHT / GUI_SCALE / 2.0 - 166 / 2.0
|
||||
x = gui.SCREEN_WIDTH / gui.GUI_SCALE / 2.0 - 176 / 2.0,
|
||||
y = gui.SCREEN_HEIGHT / gui.GUI_SCALE / 2.0 - 166 / 2.0
|
||||
}
|
||||
|
||||
gui:button {
|
||||
|
@ -213,8 +213,15 @@ void LuaGUI::show(Client &client) {
|
||||
client.tcpSocket->send(packet);
|
||||
}
|
||||
|
||||
#include "Config.hpp" // FIXME
|
||||
|
||||
void LuaGUI::initUsertype(sol::state &lua) {
|
||||
lua.new_usertype<LuaGUI>("LuaGUI",
|
||||
// FIXME: These variables should be renamed and put somewhere else
|
||||
"SCREEN_WIDTH", sol::var(std::ref(SCREEN_WIDTH)),
|
||||
"SCREEN_HEIGHT", sol::var(std::ref(SCREEN_HEIGHT)),
|
||||
"GUI_SCALE", sol::var(std::ref(GUI_SCALE)),
|
||||
|
||||
"image", &LuaGUI::addImage,
|
||||
"button", &LuaGUI::addTextButton,
|
||||
"inventory", &LuaGUI::addInventoryWidget,
|
||||
|
@ -83,6 +83,7 @@ void ServerCommandHandler::setupCallbacks() {
|
||||
auto &player = m_players.at(client.id);
|
||||
player.setPosition(m_spawnPosition.x, m_spawnPosition.y, m_spawnPosition.z);
|
||||
|
||||
// FIXME: Find a better way to give starting items
|
||||
m_scriptEngine.lua()["init"](player);
|
||||
|
||||
sf::Packet invPacket;
|
||||
|
Loading…
x
Reference in New Issue
Block a user