project-navigation
Personal tools

Author Topic: Lazy battlescape HUD  (Read 12705 times)

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Lazy battlescape HUD
« on: December 22, 2011, 03:00:04 pm »
This is a UFO:AI battlescape HUD that attempts to reduce the required clicking.
This makes it a convenience mod, not a gameplay mod.

Started out as an attempt to popularize mouse wheel use, but found several other ways to make the HUD more convenient, like using the weapon container as a button for shooting rather than having a small button to open the firemode list.

Main features are:

1) The rather large weapon box is used as a button for shooting (right click for shooting, left mouse button for dragging the weapon to another container or floor).
A menu of firemodes pops up when mouse hovers over weapon hand, and the firemodes in the menu can also be clicked with both mouse buttons to shoot.
Alternatively, firemode selection can be changed by mouse wheel.

2) Putting a grenade in hand is as simple as dragging the grenade from belt to hand container (without opening inventory popup, and afterwards closing it).
In the attached screenshot the secondary hand is not visible right now (because the hand is empty), but it will get highlighted when you start dragging.
I think this is a great improvement, as otherwise the inconvenience of opening the inventory popup has often been enough to make me decide in favor of shooting where using a grenade would have been more appropriate.

Also, reaction fire button displays more info (TU of the selected firemode in button label and firemode info in tooltip), option to highlight tiles that are reachable for a soldier, selected soldier panel displays wounds as little bars in main screen in 2.5-dev version, etc.

The 'readme.txt' and 'lazy.bat' are no longer included in the .zip.
Because "it is just a mod" and there are probably many (and possibly more correct) ways of enabling it.
My instructions are as follows:
Quote
the way i use this (ufo:ai battle screen hud mod) on windows xp:
extract (unpack) into userdata folder (folder 'mods' should appear next to the 'base' there):

C:\Documents and Settings\<user name>\Application Data\UFOAI\2.4\mods
(for 2.5, it would be C:\Documents and Settings\<user name>\Application Data\UFOAI\2.5-dev\mods)

and run the game (from where you installed the game) as:
ufo +set fs_gamedir mods
me being lazy enough i certainly don't type it in command prompt, but i have 'lazy.bat' in the folder where i installed the game (same folder where 'ufo.exe' is), and i use a desktop shortcut to the bat.

there are probably other ways to enable the mod, this is just what i did.

summary:
1. unpack in userdata folder
2. create lazy.bat in the folder where the game is installed.
lazy.bat contains one line: ufo +set fs_gamedir mods
3. create shortcut to lazy.bat
4. change icon of lazy.bat shortcut (if you wish) and drag the shortcut to desktop
5. 'lazy hud' should now appear in hud selection in gameplay options.
I hope this is clear, at least it looks clear to me (but I am the one who wrote it, so that doesn't mean much).
You can ask questions if something is not clear.
And I am interested in feedback, especially about things that people don't like about this HUD (because the only person I have got criticism from so far is myself).
« Last Edit: September 14, 2012, 09:21:26 am by homunculus »

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #1 on: December 23, 2011, 05:01:38 pm »
1.1, 1.2 very good idea
1.3 should be standard for all battlescape HUDs, right click could reload the weapon
1.4 good idea also
1.5 visually better than using just a string

2.1 I am not sure if I like that one, but I see your point.
2.2 2.1 implies that
2.3 it would be enough to drop it anywhere outside the weapon and belt/holster zones

3.1 also a good idea, some kind of visual level indication is nice to have
3.2 I am not sure how this would end up as it is important to see the main soldier stats of all the soldiers at one glance
3.3 the player should have more control over this one, but currently the code just allows to switch to the next visible alien or the next visible alien from the selected character, so this needs some C code to work
3.4 for consistency...

4.1 I agree (as you know).
4.2 should already be possible (OnMouseEnter, OnMouseLeave script commands)

The biggest problem you will face is the implementation of this - it looks like a LOT of work ;)

If you ask me: GO FOR IT !

You have proven already that you have great ideas regarding the UI, time to implement them :)
If you have troubles with something just ask. Someone always can help you. You could also join our IRC channel...

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #2 on: December 23, 2011, 10:54:38 pm »
The biggest problem you will face is the implementation of this - it looks like a LOT of work ;)
Well, I like to work intensely, or not at all.
I hope it will be done in a few days.
If you have troubles with something just ask. Someone always can help you. You could also join our IRC channel...
No experience at IRC, but as for troubles with scripting, I certainly have some : )
I think I should concentrate on the firemode selection and shooting, that seems to be "the greatest learning barrier", before I do anything else.

2011/12/23 20:24:20 [cmd] add_hud_name
2011/12/23 20:24:20 ^2      Confunc callback
2011/12/23 20:24:20 [cmd] disable_crouch
2011/12/23 20:24:20 ^2      Confunc callback
2011/12/23 20:24:20 [cmd] disable_stand
2011/12/23 20:24:20 ^2      Confunc callback

'add_hud_name' is what is called from within the HUD from within 'func onScriptLoaded', but the other two examples look like the game might call those functions, and that would mean those functions should be implemented in the HUD, so that the HUD could, say, set the 'crouch' button to 'disabled' when the game calls 'disable_crouch'.
Now I am wondering what is the meaning of 'Confunc callback'.

And, how do I know what parameters the 'cmd' things want?

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #3 on: December 23, 2011, 11:11:37 pm »
I am sorry, i mostly understand nothing, else generalities.
I think you should create a more precise mockup before coding anything. Especially with a real screen size of 800x600.

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #4 on: December 23, 2011, 11:40:21 pm »
I am sorry, i mostly understand nothing, else generalities.
?
Right now I have been digging into the cvar-s and cmd-s that I got from the cvarlist and cmdlist in the console, to see what is available.
That is where the questions about the meaning of 'Confunc callback' and 'cmd' arguments (like cmd "hud_fireweapon r 0;") came from.
Like trying to learn to cooperate with the framework rather than becoming a victim of the framework and the examples (bit too dramatically said, perhaps, but something in that direction).
« Last Edit: December 23, 2011, 11:47:29 pm by homunculus »

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #5 on: December 24, 2011, 09:25:11 am »
If you haven't, you should also read about the UI scripts in our wiki. Especially the 2.4 dev node behaviours.

A confunc is just like a function you can create and then call as you like. For instance, you can have the following node, which, when clicked on, calls the confunc. When the confunc is called, it hides the node:

Code: [Select]
nodetype mynodename
{
invis false
onClick { cmd "my_confunc_name;" }
}

confunc my_confunc_name
{
*node:parent.mynodename@invis = true
}

The commands you are asking about are special confunc's that are called from within the game. Disable_crouch is called when the selected soldier does not have enough TUs to crouch or for whatever reason is unable to crouch. You should write a confunc into your HUD with the name "disable_crouch" and it should effect your crouch button in a way that makes it clear to the player he can not crouch.

If you search for "disable_crouch" in the existing UI files, you will find several similar confuncs that are called from within the game. (disable_stand, disable_reaction, disable_headgear, deselect_*, startreactiononce, startreactionmany).

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #6 on: December 24, 2011, 11:53:28 am »
Yeah, I'll try to take 'add_hud_name' out of 'onScriptLoaded' and see what happens, to find out if add_hud_name is really a callback or not : )

I guess I should warn people not to take me very personally, some people think I am weird for nitpicking on things like that, and some people even seem to hate me a bit.
Hopefully the result is a HUD, and hopefully the script is as much according to spec as possible, nothing personal about it : )
And hopefully this "horror" will be over soon enough : )

For example, in abstractnode there is such thing as
textalign    V_UI_ALIGN    Alignement of the text into the node, or elements into blocks.
but when I used it, it crashed the game (maybe I would need a layout manager for that, but there is nothing mentioned about it).
So I guess scripting according to spec is not possible to full extent anyway (btw should I report such thing somewhere?).

And the minds of the scripters seem to have worked in the most crazy ways in the past (nothing special about me here), like in hud.ufo
window hud extends levelbuttons {
which should read as 'hud is a levelbuttons', quite an amusing exercise in imagination, I would say.

The question about cmd parameters remains atm, but it looks like it might not be a great obstacle, as I might be able to find examples with the parameters of all the commands that I need in the .ufo files.
« Last Edit: December 24, 2011, 12:08:08 pm by homunculus »

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #7 on: December 25, 2011, 01:33:22 am »
The wiki maybe outdated sometimes...

The best way to learn is to analyze the ufo scripts and the C UI code.

I have integrated some of your ideas into the MiniHUD, so you can look at that file also...

I told you it is more work than one would initially think it is ;)

Do not give up  8)

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #8 on: December 25, 2011, 11:54:45 pm »
There might be some ugly things that I am thinking of doing.

1) There is the container that shows the weapon, I can't seem to be able to find out how to detect that the contents of the container has changed.
But there are confuncs like reserve_shot_clear, deselect_reaction, deselect_primaryright, probably more, that get called at every click the user makes, and the 'ugly thing' would be to use those to check if contents of the container has changed.
Well, unless someone has some other idea.

2) I don't know how ugly this one is, but thinking of using 'onSelect' to make the container behave as button for shooting.
Because the container seems to consume the LMB otherwise.
Could try to use RMB for shooting, though, and maybe then reloading would be dragging ammo to weapon.
But LMB for shooting would be nice, even if it duplicates the RMB shooting.

3) There is such thing as scrollbar, and it would be nice to use scrollbar for scrollables, like level and firemode.
Scrollbar on a panel that can show one item at a time should do the trick.
But there is limited space and I would sort of like to indicate the scrollbar position as a combination of two bars in the whole background area of the selection box, which is nonstandard (and therefore, ugly solution imho, matter of taste).
It would be one bar with dark foreground and light background in forward direction, and another bar with dark foreground and transparent background in the opposite direction on top of it, so that the "scrollbar" would appear as a light bar in the center.
Like this:
|-------bar-1------->|---bar-1-background---|<-------bar-2-------|

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #9 on: December 26, 2011, 09:34:47 am »
1) The content of the container is the weapon, so it should be quite easy to check if the weapon changes...  ::)

2) The problem here is that you are able to drag the weapon from the container, so that is why the left mousebutton is already checked and ignored. You could create an invisible empty panel on top of the weapon, which would allow you to assign the LMB again, but you would lose the drag functionality then, which you wanna use also...

3) I'm sorry, I do not get what exactly you wanna do here  :-\

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #10 on: December 26, 2011, 12:12:18 pm »
1) I guess I'll need to store the weapon in some variable, and when the user clicks then check if the weapon in the 'container right' is the same as the stored weapon. Edit: Actually I was more worried about not knowing a better shortcut.

2) No, I wouldn't loose the drag functionality : )
I would exclude a 25x25 rectangle in the lower right corner of the firemode string on top of the weapon container (and put a ghost 'hand' icon at that spot; or maybe change cursor, but I havn't tried changing cursors yet).

3) Maybe it is bit more clear this way.
I want to put two bars on top of each other (the lower one in the script would appear on top).
Code: [Select]
|----bar-1-(dark)---->|-----bar-1-background-(light)--------|
|----bar-2-background-(transparent)----|<---bar-2-(dark)----|
This way the light colored area (background of the first bar) would indicate the position in the list like a scrollbar (but without the icons at both ends).

I don't know if that now clarified it or not, but for the last 5 hours or so (lol!), I have been trying to figure out how to create such reusable component, but without success.
The thing I can't figure out how to do is child node variables based on parent node variables (tried several variations).
Code: [Select]
component bar forwardBar
{
    {
        size     <some default values here>
        max      <some default value here>
        current  <some default value here>
    }
    bar oppositeBar
    {
        <i would like size to be the same as the parent size>
        <i would like max to be the same as the max in the parent>
        <i would like to calculate current based on current in the parent>
    }
}
Tried things like:
<calculate current based on current in the parent!>
<i would like current calculated based on current in parent>
<i would like current calculated based on current in parent, please>
but nothing seemed to help.
(well, maybe not exactly like that, but the end result was the same)
« Last Edit: December 26, 2011, 01:01:22 pm by homunculus »

Offline MCR

  • PHALANX veteran
  • ******
  • Posts: 1244
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #11 on: December 26, 2011, 04:49:20 pm »
1) The weapons are already stored: see mn_lweapon_item and mn_rweapon_item

2) This would be a possibility

3) I would not try to code that with bars as you do not need any of the bar functionality here...
To achieve that simply take a backgound image and a foreground image and change the x size and x position of the foreground image dynamically, no ?

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2539
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #12 on: December 26, 2011, 05:23:12 pm »
0. textalign was renamed to contentalign
1.a. onselect event of a container is called on selecting an element of the container AFAIK.
1.b. if you have weapon name in a cvar (like normal hud does), you can set up a cvar-listener to it

-geever

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #13 on: December 26, 2011, 05:49:53 pm »
1.b. if you have weapon name in a cvar (like normal hud does), you can set up a cvar-listener to it
Are you sure? or somebody implement it? i know it is a feature request only.

Offline homunculus

  • Sergeant
  • *****
  • Posts: 380
    • View Profile
Re: A try at a wheel-intensive HUD
« Reply #14 on: December 26, 2011, 06:09:28 pm »
1.b. I think I saw a cvarlistener in some .ufo file yesterday.

1.a. onSelect for shooting looks unusable because each time the user drags the item, onSelect is called.
The node (with a hole) over the weapon container is better.

0. Thanks, that makes me feel better (it does feel bit strange doing things not according to spec otherwise).