Get rid of default UI

Get rid of default UI

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Get rid of default UI

Post by Funkencool »

Edit:
Here's a simple widget to disable all the apparent default UI elements.

Code: Select all

function widget:GetInfo()
  return {
    name = "Clean slate",
    desc = "Get rid of default UI",
    author = "Funk",
    date = "Feb, 2015",
    license = "Public Domain",
    layer = 0,
    enabled = true,
  }
end

function widget:Initialize()
  -- get rid of engine UI
  Spring.SendCommands("resbar 0", "tooltip 0","fps 0","console 0","info 0")

  -- leaves rendering duty to widget (we won't)
  gl.SlaveMiniMap(true)

  -- a hitbox remains for the minimap, unless you do this
  gl.ConfigMiniMap(0,0,0,0)
end

-- sets status to ready; avoiding any pre-game UI
function widget:GameSetup()
  return true, true
end
It seem's I've got everything now but let me know otherwise.
Last edited by Funkencool on 06 Mar 2015, 04:28, edited 2 times in total.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: How do I get rid of default UI?

Post by jK »

all you are missing is a callin GameSetup... or somehting
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: How do I get rid of default UI?

Post by Funkencool »

addon.GameSetup(state, ready, playerStates)
return: bool success, bool newReady
???
That's all I found in the wiki.

I would guess this is an unsynced gadget callin from what I've seen elsewhere in the forum.
Does anyone have some example code? This makes no sense to me without context.

edit: found this works

Code: Select all

function widget:GameSetup()
  return true, true
end
My best guess it it sets the state to ready and therefor skips the drawing
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Get rid of default UI

Post by 8611 »

Spring.SendCommands ("hideinterface 1")
will also hide widgets...at least those that use IsGUIHidden()
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Get rid of default UI

Post by Silentwings »

Iirc the first returned argument from GameSetup controls whether or not the engine prints a coloured list of names showing players readyStates, and the second argument sets the readyState of the player.

Obviously your widget should avoid changing the readyState of the player, so you should want to return true,nil - but seems the widgetHandler is currently not clever enough to deal with that (https://github.com/spring/spring/blob/d ... .lua#L1662).

So imo leave out GameSetup; the readyStates might get overruled/re-implemented by a gadget anyway.
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

Probably true in most cases but specifically this is for my in game menu; so a completely blank slate is really all I want.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Get rid of default UI

Post by gajop »

Once you've figured it out, send your changes here: https://github.com/gajop/IngameLobby/bl ... _lobby.lua ;)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: How do I get rid of default UI?

Post by Jools »

Funkencool wrote:
addon.GameSetup(state, ready, playerStates)
return: bool success, bool newReady
???
That's all I found in the wiki.

I would guess this is an unsynced gadget callin from what I've seen elsewhere in the forum.
Does anyone have some example code? This makes no sense to me without context.

edit: found this works

Code: Select all

function widget:GameSetup()
  return true, true
end
My best guess it it sets the state to ready and therefor skips the drawing
Look at xta commander change widget for and example how it's used.

Widget can set the playerstate as ready, but once it's set as ready it can not reverse it.I don't really remember but I think the second return parameter is whether you want to implement your own ready button or not, at least it was possible to do that somewhere.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Get rid of default UI

Post by FLOZi »

Please feed the wiki. 8)
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

FLOZi wrote:Please feed the wiki. 8)
Splendid idea :-)
As an expert on the wiki, do you have any suggestions on where I should put it?
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Get rid of default UI

Post by Jools »

User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Get rid of default UI

Post by FLOZi »

Jools wrote:How about here: https://springrts.com/wiki/Lua:Callins
That is indeed the page that needs updating to fill in the details of how GameSetup works. You will find it is templated for your pleasure.
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

Jools wrote:How about here: https://springrts.com/wiki/Lua:Callins
I guess I was thinking along the lines of a quick guide to springs default UIs but that could definitely use a little more info too.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Get rid of default UI

Post by gajop »

I'm also using gl.SlaveMiniMap(true), but I've noticed that if I put the mouse cursor near the place where the map usually is, it will put that blue pointer on the map (representing where my mouse cursor is on the invisible minimap). It looks kinda weird, and even appears on those blank maps.
Image

Is this a Spring bug or maybe we aren't turning off something?

PS: I'm invoking it once (initially) in the DrawWorld - I thought you need to do it in an opengl context like most gl. commands - am I wrong?
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Get rid of default UI

Post by 8611 »

User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

Now that you mention it, I've had that problem as well. I think the minimap geo has to be set with something like

Code: Select all

gl.ConfigMiniMap(0,0,0,0)
Can anyone else confirm that?

Chili is hidden with the rest of the UI. Which is wanted behavior and why that won't work.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Get rid of default UI

Post by 8611 »

gl.ConfigMiniMap(0,0,0,0) will work but leave a small group of pixels, perhaps the minimap's frame. Maybe there is a setting to get rid of that too but imo that is all a bit cumbersome.

The original question is "Get rid of default UI" and Spring.SendCommands ("hideinterface 1") does excactly that without having to figure out dozen of small extra cases.

widgets do not automatically get hidden when engineGUI is disabled.
They use Spring.isGUIHidden() to stop drawing/reacting to user input.
If chiliGUI always hides each chili-widget once engineGUI is turned off then that is imo too restrictive and worth changing:
chili has functions Hide() / Show() so each widget could already implent anyway how it wants to handle the situation.

Or instead for more silly tricks: Spring.SendCommands ("minimap minimize 1") and to get rid of the maximize button include a transparent minimapbuttons.png
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

8611 wrote:gl.ConfigMiniMap(0,0,0,0) will work but leave a small group of pixels
If in slave mode the pixels could be drawn manually; otherwise nothing would be visible and it would prevent what gajop mentioned.
8611 wrote:The original question is "Get rid of default UI"
I'm completely aware of the original question I myself asked.

Spring.isGUIHidden() does not refer to "engine" but instead to the entire GUI, same goes for Spring.SendCommands ("hideinterface 1"). IMO those functions should be reserved to let widgets know and adjust when the user wants their GUI hidden.
8611 wrote:for more silly tricks
You're a silly trick :wink:
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Get rid of default UI

Post by gajop »

Just to confirm, using Spring.SendCommands("hideinterface 1") is something I also want to avoid. The way I see it, the semantic of that assumes the user wants to remove the entire interface, usually for screenshot taking purpose. This is also probably the intended behaviour by the people that implemented this and Spring.isGUIHidden().

Now on to gl.ConfigMiniMap(0,0,0,0), what does this do? Is it basically a configuration that says the minimap appears in the rectangle (0,0), (0,0)? It seems one can set it to (-1,-1), (-1, -1) as well, but both seem to do exactly what I wanted.

PS: Both commands can be started in widget:Initialize() it seems, don't need to be in OpenGL context.
User avatar
Funkencool
Posts: 542
Joined: 02 Dec 2011, 22:31

Re: Get rid of default UI

Post by Funkencool »

I think you nailed what it does, but I'm not sure. I just I came across it in zk's minimap where it was in an if statement for showing/hiding the minimap. When toggled it would switch between values from a chili window and (0,0,0,0)

edit: Updated OP with some comments and this
Post Reply

Return to “Lua Scripts”