mirror of
https://github.com/minetest/minetest.git
synced 2024-12-27 16:37:30 +01:00
Add object crosshair, disable entity selectionboxes by default (#9523)
Adds new object crosshair base pack texture
This commit is contained in:
parent
4fa1e03f68
commit
88ffd64124
@ -741,9 +741,11 @@ selectionbox_color (Selection box color) string (0,0,0)
|
||||
selectionbox_width (Selection box width) int 2 1 5
|
||||
|
||||
# Crosshair color (R,G,B).
|
||||
# Also controls the object crosshair color
|
||||
crosshair_color (Crosshair color) string (255,255,255)
|
||||
|
||||
# Crosshair alpha (opaqueness, between 0 and 255).
|
||||
# Also controls the object crosshair color
|
||||
crosshair_alpha (Crosshair alpha) int 255 0 255
|
||||
|
||||
# Maximum number of recent chat messages to show
|
||||
@ -817,7 +819,8 @@ world_aligned_mode (World-aligned textures mode) enum enable disable,enable,forc
|
||||
autoscale_mode (Autoscaling mode) enum disable disable,enable,force
|
||||
|
||||
# Show entity selection boxes
|
||||
show_entity_selectionbox (Show entity selection boxes) bool true
|
||||
# A restart is required after changing this.
|
||||
show_entity_selectionbox (Show entity selection boxes) bool false
|
||||
|
||||
[*Menus]
|
||||
|
||||
|
@ -72,7 +72,12 @@ by texture packs. All existing fallback textures can be found in the directory
|
||||
* `crosshair.png`
|
||||
* the crosshair texture in the center of the screen. The settings
|
||||
`crosshair_color` and `crosshair_alpha` are used to create a cross
|
||||
when no texture was found
|
||||
when no texture is found.
|
||||
|
||||
* `object_crosshair.png`
|
||||
* the crosshair seen when pointing at an object. The settings
|
||||
`crosshair_color` and `crosshair_alpha` are used to create a cross
|
||||
when no texture is found.
|
||||
|
||||
* `halo.png`: used for the node highlighting mesh
|
||||
|
||||
|
@ -955,8 +955,9 @@
|
||||
# autoscale_mode = disable
|
||||
|
||||
# Show entity selection boxes
|
||||
# A restart is required after changing this.
|
||||
# type: bool
|
||||
# show_entity_selectionbox = true
|
||||
# show_entity_selectionbox = false
|
||||
|
||||
## Menus
|
||||
|
||||
@ -3374,4 +3375,3 @@
|
||||
# so see a full list at https://content.minetest.net/help/content_flags/
|
||||
# type: string
|
||||
# contentdb_flag_blacklist = nonfree, desktop_default
|
||||
|
||||
|
@ -3176,11 +3176,14 @@ PointedThing Game::updatePointedThing(
|
||||
const NodeDefManager *nodedef = map.getNodeDefManager();
|
||||
|
||||
runData.selected_object = NULL;
|
||||
hud->pointing_at_object = false;
|
||||
|
||||
RaycastState s(shootline, look_for_object, liquids_pointable);
|
||||
PointedThing result;
|
||||
env.continueRaycast(&s, &result);
|
||||
if (result.type == POINTEDTHING_OBJECT) {
|
||||
hud->pointing_at_object = true;
|
||||
|
||||
runData.selected_object = client->getEnv().getActiveObject(result.object_id);
|
||||
aabb3f selection_box;
|
||||
if (show_entity_selectionbox && runData.selected_object->doShowSelectionBox() &&
|
||||
|
@ -41,6 +41,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "gui/touchscreengui.h"
|
||||
#endif
|
||||
|
||||
#define OBJECT_CROSSHAIR_LINE_SIZE 8
|
||||
#define CROSSHAIR_LINE_SIZE 10
|
||||
|
||||
Hud::Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
|
||||
Inventory *inventory)
|
||||
{
|
||||
@ -76,6 +79,7 @@ Hud::Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
|
||||
selectionbox_argb = video::SColor(255, sbox_r, sbox_g, sbox_b);
|
||||
|
||||
use_crosshair_image = tsrc->isKnownSourceImage("crosshair.png");
|
||||
use_object_crosshair_image = tsrc->isKnownSourceImage("object_crosshair.png");
|
||||
|
||||
m_selection_boxes.clear();
|
||||
m_halo_boxes.clear();
|
||||
@ -601,6 +605,31 @@ void Hud::drawHotbar(u16 playeritem) {
|
||||
|
||||
void Hud::drawCrosshair()
|
||||
{
|
||||
if (pointing_at_object) {
|
||||
if (use_object_crosshair_image) {
|
||||
video::ITexture *object_crosshair = tsrc->getTexture("object_crosshair.png");
|
||||
v2u32 size = object_crosshair->getOriginalSize();
|
||||
v2s32 lsize = v2s32(m_displaycenter.X - (size.X / 2),
|
||||
m_displaycenter.Y - (size.Y / 2));
|
||||
driver->draw2DImage(object_crosshair, lsize,
|
||||
core::rect<s32>(0, 0, size.X, size.Y),
|
||||
nullptr, crosshair_argb, true);
|
||||
} else {
|
||||
driver->draw2DLine(
|
||||
m_displaycenter - v2s32(OBJECT_CROSSHAIR_LINE_SIZE,
|
||||
OBJECT_CROSSHAIR_LINE_SIZE),
|
||||
m_displaycenter + v2s32(OBJECT_CROSSHAIR_LINE_SIZE,
|
||||
OBJECT_CROSSHAIR_LINE_SIZE), crosshair_argb);
|
||||
driver->draw2DLine(
|
||||
m_displaycenter + v2s32(OBJECT_CROSSHAIR_LINE_SIZE,
|
||||
-OBJECT_CROSSHAIR_LINE_SIZE),
|
||||
m_displaycenter + v2s32(-OBJECT_CROSSHAIR_LINE_SIZE,
|
||||
OBJECT_CROSSHAIR_LINE_SIZE), crosshair_argb);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_crosshair_image) {
|
||||
video::ITexture *crosshair = tsrc->getTexture("crosshair.png");
|
||||
v2u32 size = crosshair->getOriginalSize();
|
||||
@ -608,12 +637,12 @@ void Hud::drawCrosshair()
|
||||
m_displaycenter.Y - (size.Y / 2));
|
||||
driver->draw2DImage(crosshair, lsize,
|
||||
core::rect<s32>(0, 0, size.X, size.Y),
|
||||
0, crosshair_argb, true);
|
||||
nullptr, crosshair_argb, true);
|
||||
} else {
|
||||
driver->draw2DLine(m_displaycenter - v2s32(10, 0),
|
||||
m_displaycenter + v2s32(10, 0), crosshair_argb);
|
||||
driver->draw2DLine(m_displaycenter - v2s32(0, 10),
|
||||
m_displaycenter + v2s32(0, 10), crosshair_argb);
|
||||
driver->draw2DLine(m_displaycenter - v2s32(CROSSHAIR_LINE_SIZE, 0),
|
||||
m_displaycenter + v2s32(CROSSHAIR_LINE_SIZE, 0), crosshair_argb);
|
||||
driver->draw2DLine(m_displaycenter - v2s32(0, CROSSHAIR_LINE_SIZE),
|
||||
m_displaycenter + v2s32(0, CROSSHAIR_LINE_SIZE), crosshair_argb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,12 +45,16 @@ public:
|
||||
|
||||
video::SColor crosshair_argb;
|
||||
video::SColor selectionbox_argb;
|
||||
|
||||
bool use_crosshair_image = false;
|
||||
bool use_object_crosshair_image = false;
|
||||
std::string hotbar_image = "";
|
||||
bool use_hotbar_image = false;
|
||||
std::string hotbar_selected_image = "";
|
||||
bool use_hotbar_selected_image = false;
|
||||
|
||||
bool pointing_at_object = false;
|
||||
|
||||
Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
|
||||
Inventory *inventory);
|
||||
~Hud();
|
||||
|
@ -86,6 +86,7 @@ void RenderingCore::drawHUD()
|
||||
if (show_hud) {
|
||||
if (draw_crosshair)
|
||||
hud->drawCrosshair();
|
||||
|
||||
hud->drawHotbar(client->getEnv().getLocalPlayer()->getWieldIndex());
|
||||
hud->drawLuaElements(camera->getOffset());
|
||||
camera->drawNametags();
|
||||
|
@ -225,7 +225,7 @@ void set_default_settings(Settings *settings)
|
||||
settings->setDefault("desynchronize_mapblock_texture_animation", "true");
|
||||
settings->setDefault("hud_hotbar_max_width", "1.0");
|
||||
settings->setDefault("enable_local_map_saving", "false");
|
||||
settings->setDefault("show_entity_selectionbox", "true");
|
||||
settings->setDefault("show_entity_selectionbox", "false");
|
||||
settings->setDefault("texture_clean_transparent", "false");
|
||||
settings->setDefault("texture_min_size", "64");
|
||||
settings->setDefault("ambient_occlusion_gamma", "2.2");
|
||||
|
Loading…
Reference in New Issue
Block a user