Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compass HUD element #9312

Merged
merged 5 commits into from
Aug 29, 2020
Merged

Conversation

EvidenceBKidscode
Copy link
Contributor

This PR adds a "compass" HUD element (new HUD feature).

Basically it is like image HUD element but it rotates or translates according to the current heading direction. This allows to build various compass HUD. The display is entirely updated on client side so it is quite smooth.

To do

This PR is ready for review.

How to test

Here is a sample code for testing it, using default mod textures :

minetest.register_on_joinplayer(function(player)
	player:hud_add({
		hud_elem_type = "compass",
		position = { x = 0, y = 0 },
		offset = { x = 10, y = 10 },
		size = { x = 150, y = 150 },
		alignment = { x = 1, y = 1 },
		text = "gui_furnace_arrow_bg.png",
		dir = 1,
	})

	player:hud_add({
		hud_elem_type = "compass",
		position = { x = 0, y = 0 },
		offset = { x = 10, y = 170 },
		size = { x = 100, y = 50 },
		scale = { x = 1, y = 1 }, -- Required or scale would be 0
		alignment = { x= 1, y = 1 },
		text = "default_ladder_steel.png^[transformR90",
		dir = 2,
	})
end)

This adds two compass HUD elements in the upper left corner of the screen (better texture would be much more suitable 😄) :
screenshot_20200114_164400

@paramat paramat added the Feature ✨ PRs that add or enhance a feature label Jan 14, 2020
Co-authored-by: Jean-Patrick Guerrero <[email protected]>
Co-authored-by: Pierre-Yves Rollo <[email protected]>
@LoneWolfHT
Copy link
Contributor

I support the idea, but am not sure how the second HUD works

@Andrey2470T
Copy link
Contributor

Andrey2470T commented Jan 16, 2020

I don`t understand why the steel ladder element is needed for the compass on the screen?

@pyrollo
Copy link
Contributor

pyrollo commented Jan 16, 2020

I don`t understand why the steel ladder element is needed for the compass on the screen?

This was just provided as an example, I could have put anything else.
Imagine putting your own texture instead. Then it'll be up to you to create various compass, either rotating compass or horizontal bar compass.

Copy link
Member

@nerzhul nerzhul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except the comment fine to me

src/hud.h Outdated
@@ -61,6 +61,7 @@ enum HudElementType {
HUD_ELEM_STATBAR = 2,
HUD_ELEM_INVENTORY = 3,
HUD_ELEM_WAYPOINT = 4,
HUD_ELEM_COMPASS = 6,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 6 and not 5 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks SmallJocker, that's it.
I was hesitating between having same number in the two PRs then reajust, or try to hide this detail from perspicacious eyes of core devs :)

@Andrey2470T
Copy link
Contributor

As I consider if you want to know along which horizontal direction (North/South, East/West) you are currently moving, you can just press F5 and you above see info about it. I don`t understand a point of this feature.

@style-nine
Copy link

Not everyone uses F5 for gameplay. Some people reserve that strictly for debugging.

@Andrey2470T
Copy link
Contributor

I think it would be nice to embed default compass and reserve for it a special key (e.g F11 or any else) to be able to activate/deactivate it. Also, shift it to right or left downer corner as it would overlap the chat text. But probably this is already other topic.

@pyrollo
Copy link
Contributor

pyrollo commented Jan 18, 2020

In my opinion, adding default stuff to engine is a mistake. Specific things like compass (an minimap) should be managed by game and mods. This gives much more freedom to modders to do what they want.
The given example is just an example, you can easily change the position to whatever you want, there is no default position in this PR.

@nerzhul
Copy link
Member

nerzhul commented May 2, 2020

i agree with @pyrollo .
Rebase is needed here. Will do some review stuff after

@nerzhul nerzhul added the Rebase needed The PR needs to be rebased by its author label May 2, 2020
@pyrollo
Copy link
Contributor

pyrollo commented May 5, 2020

Rebased

@SmallJoker SmallJoker removed the Rebase needed The PR needs to be rebased by its author label May 5, 2020
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works. Few small issues.

doc/lua_api.txt Outdated Show resolved Hide resolved
doc/lua_api.txt Outdated Show resolved Hide resolved
src/client/hud.cpp Outdated Show resolved Hide resolved
@paramat
Copy link
Contributor

paramat commented Aug 23, 2020

As pyrollo is now a core dev, this can be merged.

Although, i am unsure this is worth adding.
A compass does not seem much needed and we already have degrees and NESW readouts in F5 for when it is needed.
A compass seems a thing you only occasionally need, so always being on-screen seems obtrusive, in this way F5 seems better.
Although i agree that a compass feature being controlled from server, games and mods is better than client-controlled.

PR #9315 hides yaw according to a privilege, perhaps this is all we need as it makes it server controlled?

@rubenwardy
Copy link
Member

we already have degrees and NESW readouts in F5 for when it is needed

All games could just be text adventures, but that would be no fun

@paramat
Copy link
Contributor

paramat commented Aug 23, 2020

Well, that is just a snarky comment that misrepresents my comment to ridicule it.

@pyrollo
Copy link
Contributor

pyrollo commented Aug 24, 2020

I think Rubenwardy is right, visual effects are important in video games, they improve immersion. This PR is less about showing the heading direction than adding visual effects.

One criticism I could make to my own PR is that it is a bit limited. Such elements could also be able to point to a map point or something else. But HUD specification was too limited to do that. Maybe with #10245 it could be possible to have a very versatile "moving or rotating" image HUD element.

Example use cases:

  • Compass (rotating or vertical + horizontal);
  • Kind of radar indicating direction of a place;
  • Another kind of radar indicating directions of mobs;

So should this PR be improved before merged ? (I guess yes)

@pyrollo pyrollo merged commit 5c4b560 into minetest:master Aug 29, 2020
@pyrollo pyrollo deleted the pr-hud-compass branch August 29, 2020 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants