Skip to content
Permalink
Browse files

Add support for dpi based HUD scaling

Add support for (configurable) multiline hotbar
Improved screensize handling
Add userdefined gui scale by BlockMen
  • Loading branch information...
sapier sapier
sapier authored and sapier committed Apr 5, 2014
1 parent 8d31534 commit 1838a3fd696782b1733a435bbb25accf3e40d1f3
Showing with 266 additions and 151 deletions.
  1. +9 −1 doc/menu_lua_api.txt
  2. +6 −1 minetest.conf.example
  3. +2 −2 src/camera.cpp
  4. +1 −1 src/camera.h
  5. +2 −0 src/defaultsettings.cpp
  6. +9 −17 src/game.cpp
  7. +135 −115 src/hud.cpp
  8. +17 −10 src/hud.h
  9. +3 −1 src/main.cpp
  10. +40 −2 src/porting.cpp
  11. +12 −1 src/porting.h
  12. +28 −0 src/script/lua_api/l_mainmenu.cpp
  13. +2 −0 src/script/lua_api/l_mainmenu.h
@@ -116,6 +116,14 @@ engine.file_open_dialog(formname,caption)
^ -if dialog was canceled "_cancelled"
^ will be added to fieldname value is set to formname itself
^ returns nil or selected file/folder
engine.get_screen_info()
^ returns {
density = <screen density 0.75,1.0,2.0,3.0 ... (dpi)>,
display_width = <width of display>,
display_height = <height of display>,
window_width = <current window width>,
window_height = <current window height>
}

Games:
engine.get_game(index)
@@ -198,7 +206,7 @@ engine.handle_async(async_job,parameters,finished)
^ execute a function asynchronously
^ async_job is a function receiving one parameter and returning one parameter
^ parameters parameter table passed to async_job
^ finished function to be called once async_job has finished
^ finished function to be called once async_job has finished
^ the result of async_job is passed to this function

Limitations of Async operations
@@ -140,13 +140,18 @@
#crosshair_color = (255,255,255)
# Cross alpha (opaqueness, between 0 and 255)
#crosshair_alpha = 255
# scale gui by a user specified value
#gui_scaling = 1.0
# Sensitivity multiplier
#mouse_sensitivity = 0.2
# Sound settings
#enable_sound = true
#sound_volume = 0.7
# Whether node texture animations should be desynchronized per MapBlock
#desynchronize_mapblock_texture_animation = true
# maximum percentage of current window to be used for hotbar
# (usefull if you've there's something to be displayed right or left of hotbar)
#hud_hotbar_max_width = 1.0
# Texture filtering settings
#mip_map = false
#anisotropic_filter = false
@@ -165,7 +170,7 @@
#normalmaps_strength = 0.6
# Strength of generated normalmaps
#normalmaps_smooth = 1
# Defines sampling step of texture (0 - 2)
# Defines sampling step of texture (0 - 2)
# Higher the value normal maps will be smoother
#enable_parallax_occlusion = false
# Scale of parallax occlusion effect
@@ -249,7 +249,7 @@ void Camera::step(f32 dtime)
}

void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
v2u32 screensize, f32 tool_reload_ratio,
f32 tool_reload_ratio,
int current_camera_mode, ClientEnvironment &c_env)
{
// Get player position
@@ -422,7 +422,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime,
fov_degrees = MYMIN(fov_degrees, 170.0);

// FOV and aspect ratio
m_aspect = (f32)screensize.X / (f32) screensize.Y;
m_aspect = (f32) porting::getWindowSize().X / (f32) porting::getWindowSize().Y;
m_fov_y = fov_degrees * M_PI / 180.0;
// Increase vertical FOV on lower aspect ratios (<16:10)
m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect)));
@@ -117,7 +117,7 @@ class Camera
// Update the camera from the local player's position.
// busytime is used to adjust the viewing range.
void update(LocalPlayer* player, f32 frametime, f32 busytime,
v2u32 screensize, f32 tool_reload_ratio,
f32 tool_reload_ratio,
int current_camera_mode, ClientEnvironment &c_env);

// Render distance feedback loop
@@ -119,10 +119,12 @@ void set_default_settings(Settings *settings)
settings->setDefault("selectionbox_color", "(0,0,0)");
settings->setDefault("crosshair_color", "(255,255,255)");
settings->setDefault("crosshair_alpha", "255");
settings->setDefault("gui_scaling", "1.0");
settings->setDefault("mouse_sensitivity", "0.2");
settings->setDefault("enable_sound", "true");
settings->setDefault("sound_volume", "0.8");
settings->setDefault("desynchronize_mapblock_texture_animation", "true");
settings->setDefault("hud_hotbar_max_width","1.0");

settings->setDefault("mip_map", "false");
settings->setDefault("anisotropic_filter", "false");
@@ -1099,7 +1099,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
// Calculate text height using the font
u32 text_height = font->getDimension(L"Random test string").Height;

v2u32 last_screensize(0,0);
v2u32 screensize = driver->getScreenSize();

/*
@@ -1842,15 +1841,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/*
Random calculations
*/
last_screensize = screensize;
screensize = driver->getScreenSize();
v2s32 displaycenter(screensize.X/2,screensize.Y/2);
//bool screensize_changed = screensize != last_screensize;


// Update HUD values
hud.screensize = screensize;
hud.displaycenter = displaycenter;
hud.resizeHotbar();

// Hilight boxes collected during the loop and displayed
@@ -2267,10 +2257,11 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
first_loop_after_window_activation = false;
}
else{
s32 dx = input->getMousePos().X - displaycenter.X;
s32 dy = input->getMousePos().Y - displaycenter.Y;
if(invert_mouse || player->camera_mode == CAMERA_MODE_THIRD_FRONT)
s32 dx = input->getMousePos().X - (driver->getScreenSize().Width/2);
s32 dy = input->getMousePos().Y - (driver->getScreenSize().Height/2);
if(invert_mouse || player->camera_mode == CAMERA_MODE_THIRD_FRONT) {
dy = -dy;
}
//infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;

/*const float keyspeed = 500;
@@ -2292,7 +2283,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,

turn_amount = v2f(dx, dy).getLength() * d;
}
input->setMousePos(displaycenter.X, displaycenter.Y);
input->setMousePos((driver->getScreenSize().Width/2),
(driver->getScreenSize().Height/2));
}
else{
// Mac OSX gets upset if this is set every frame
@@ -2657,7 +2649,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
}
player->camera_mode = current_camera_mode;
tool_reload_ratio = MYMIN(tool_reload_ratio, 1.0);
camera.update(player, dtime, busytime, screensize, tool_reload_ratio,
camera.update(player, dtime, busytime, tool_reload_ratio,
current_camera_mode, client.getEnv());
camera.step(dtime);

@@ -3538,8 +3530,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
*/
if (show_hud)
{
hud.drawHotbar(v2s32(displaycenter.X, screensize.Y),
client.getHP(), client.getPlayerItem(), client.getBreath());
hud.drawHotbar(client.getHP(), client.getPlayerItem(),
client.getBreath());
}

/*

0 comments on commit 1838a3f

Please sign in to comment.
You can’t perform that action at this time.