Jump to content
The Dark Mod Forums

Adding Fade To Inventory


Springheel

Recommended Posts

Spar, (or anyone else who knows), I'm trying to add some fade effects to the inventory icons and text. At the moment I'm just trying to get the group text to fade away after five seconds of staying on the same icon. I'm running into some problems though. I can make the text fade away the first time, but it stays that way--it no longer updates when you change to the next inventory object.

 

I need to know what the variable is that makes the icon/text visible, so that I can hopefully reset the GUI timer as soon as a new item is selected--that will allow me to add subtle fades, transitions, and eventually decorative animations. I don't know much about the coding behind the inventory though--specifically this line:

 

visible "gui::Inventory_GroupVisible"*"gui::Inventory_ItemVisible"

 

Can you explain to me how the text and item are set to be visible?

Link to comment
Share on other sites

So gui::Inventory_ItemVisible only has two possible values, 0 and 1? Hmm. Is there any way for the GUI code to know when the player switches from one inventory item to another? I assume there must be because it knows to change the icon.

 

What I'd like to do is add an onTime command to the GUI, so that I can start a timer every time the player changes to a different icon. Do you know how I can do that?

 

Just adding it to the "windowDef InventoryItemIcon " doesn't work, because that windowDef doesn't reset when a new item is selected.

 

Sorry if I'm not being clear--I don't know the proper terms for discussing code. :)

Link to comment
Share on other sites

Yes, there is an event that is triggered when an item switch is happening. You can look at how the loot was done. But I must check if that even is also triggered for regular items, or only for custom gui items. I hadn't had time to add the info on the wiki and then simply forgot about it. :blush:

Gerhard

Link to comment
Share on other sites

Do you mean triggered as in it is given a value of 1 or 0? Or would it be classified as an "event"? If it's the former, then I figured this should work (it doesn't):

onTime 0 {set "InventoryItemName::forecolor" "1 1 1 1" }

onTime 5000 { transition "InventoryItemName::forecolor" "1 1 1 1" "1 1 1 0" "600" ; }

 

 

 

if ("gui::inventory_item_select" = 1)

 

{

resetTime "InventoryItemName" "0" ;

}

 

If it's an event, then I thought this would work (but it doesn't either):

 

onTime 5000 { transition "InventoryItemName::forecolor" "1 1 1 1" "1 1 1 0" "600" ; }

 

onNamedEvent inventory_item_select {set "InventoryItemName::forecolor" "1 1 1 1" }

 

I looked at the loot.gui but I didn't see anything about inventory_item_select.

Link to comment
Share on other sites

Yeah, it's that way in the code. I tried both one equal and two just to be sure. Neither did anything.

 

I'm stumped on this one.

Link to comment
Share on other sites

Guis are a bit strange to work with. :) I already added this to my list of todos on the inventory, but I don't think it's a big deal though at the moment. I rather want to get the functionality working fiorst, because this is just bells and whistles.

Gerhard

Link to comment
Share on other sites

You're right, I was just hoping it was something I could work on without much help. Apparently not. :)

Link to comment
Share on other sites

Yeah, unfortunately it's not on SVN, and it's not on the two backup copies I have from earlier. Anyone still have a copy of it?

Link to comment
Share on other sites

That will take about a day or so...I think I'll wait and see if anyone happens to have a backup copy somewhere. :)

 

What about the last beta-release? Did it have the new inventory?

Link to comment
Share on other sites

I thought SVN had imported the history from CVS.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

windowDef Desktop {

rect 0, 0, 640, 480

backcolor 0, 0, 0, 0

visible 1

nocursor 1

 

onActivate

{

set "ItemDisplay::inventoryOpacity" "1";

 

set "gui::itemIcon" "";

set "gui::itemIcon_red" "1";

set "gui::itemIcon_green" "1";

set "gui::itemIcon_blue" "1";

set "gui::itemName" "";

set "gui::itemName_red" "1";

set "gui::itemName_green" "1";

set "gui::itemName_blue" "1";

set "gui::itemName_scale" "1";

set "gui::itemCount" "";

set "gui::itemCount_red" "1";

set "gui::itemCount_green" "1";

set "gui::itemCount_blue" "1";

set "gui::itemCount_scale" "1";

}

 

// I've defined this out here, so I can easily change it for testing purposes.

#define INVENTORY_FADETIME "200"

 

// This windowDef isn't strictly necessary... It merely provides an

// anchor point, so ItemDisplay can do relative transitions.

windowDef Anchor

{

rect 640-8, 480-0, 96, 80

invertRect 1

noclip 1

 

windowDef ItemDisplay

{

rect 0, 0, 96, 80

noclip 1

noTime 1

 

float fade 0

float inventoryOpacity 0

float alpha "fade"*"inventoryOpacity"

 

onNamedEvent updateDisplay

{

set "ItemIcon::background" "gui::itemIcon";

set "ItemIcon::red" "gui::itemIcon_red";

set "ItemIcon::green" "gui::itemIcon_green";

set "ItemIcon::blue" "gui::itemIcon_blue";

set "ItemName::text" "gui::itemName";

set "ItemName::red" "gui::itemName_red";

set "ItemName::green" "gui::itemName_green";

set "ItemName::blue" "gui::itemName_blue";

set "ItemName::tScale" "gui::itemName_scale";

set "ItemCount::text" "gui::itemCount";

set "ItemCount::red" "gui::itemCount_red";

set "ItemCount::green" "gui::itemCount_green";

set "ItemCount::blue" "gui::itemCount_blue";

set "ItemCount::tScale" "gui::itemCount_scale";

}

 

onNamedEvent inventoryUpdateOpacity

{

set "inventoryOpacity" "$gui::inventoryOpacity";

}

 

onNamedEvent fadeIn

{

transition "fade" "0" "1" INVENTORY_FADETIME "0" "1";

}

 

onNamedEvent fadeOut

{

 

transition "fade" "1" "0" INVENTORY_FADETIME "0" "1";

resetTime 0;

}

 

onTime INVENTORY_FADETIME

{

set "gui::deleteMe" "1";

}

 

onNamedEvent shiftLeftIn

{

transition "rect" "50 0 96 80" "0 0 96 80" INVENTORY_FADETIME "0" "1";

}

 

onNamedEvent shiftRightIn

{

transition "rect" "-50 0 96 80" "0 0 96 80" INVENTORY_FADETIME "0" "1";

}

 

onNamedEvent shiftLeftOut

{

transition "rect" "0 0 96 80" "-50 0 96 80" INVENTORY_FADETIME "0" "1";

}

 

onNamedEvent shiftRightOut

{

transition "rect" "0 0 96 80" "50 0 96 80" INVENTORY_FADETIME "0" "1";

}

 

windowDef ItemIcon

{

rect 24, 0, 48, 48

noclip 1

 

matcolor "red", "green", "blue", "ItemDisplay::alpha"

background ""

 

float red 0

float green 0

float blue 0

}

 

windowDef ItemName

{

rect 0, 48, 96, 32

noclip 1

 

textalign 1

font "fonts/carleton"

forecolor "red", "green", "blue", "ItemDisplay::alpha"

textscale 0.2*"tScale"

text ""

 

float red 0

float green 0

float blue 0

float tScale 0

}

 

windowDef ItemCount

{

rect 0, 0, 32, 16

noclip 1

 

textalign 2

font "fonts/carleton"

forecolor "red", "green", "blue", "ItemDisplay::alpha"

textscale 0.2*"tScale"

text ""

 

float red 0

float green 0

float blue 0

float tScale 0

}

}

}

}

 

Ok, here it is. Man, a lot more stuff here than the new version. It looks like Gil defined a couple new "events" for the fade--fadeIn and fadeOut. I'll have to spend some time this afternoon analyzing this and see if I can get it working with inventory_select instead.

 

If

Link to comment
Share on other sites

tdm_inv_opacity | float [0..1] | default "1"

Specifies the alphachannel for the inventory. It determines if and how much you can look through the inventory text and icons.

 

tdm_inv_fade_in | int | default "0"

Specifies how long it should take for the inventory until it becomes visible. 0 means that it will be immediatly visible when activated.

 

tdm_inv_fade_out | int | default "0"

Specifies how long it should take for the inventory until it bcomes invisible. 0 means that it will be immediatly invisible when deactivated.

 

I just noticed these on the wiki...are they actually useable with the current system?

Link to comment
Share on other sites

I'm kind of stumped here Spar, so I think I'm going to stop experimenting for the time being. I'll tell you the effects I'd like to be able to add at some point, and you can tell me if it's currently possible, and if not, store it away to do later. :)

 

 

1. I'd like to implement a very subtle fade in and out for the inventory icons/text as the player cycles through them (I think I could probably fade them in right now, but not out).

 

2. Have the icons be large while cycling through them, but have them shrink to their current size after 5 seconds of staying on the same icon.

 

3. Have the group and name text show up when cycling through them, but fade away after 5 seconds of staying on the same icon.

 

That's pretty much it. I think I could do all of these things if there was a named event called the moment the player 'selects' an inventory item (cycles to it or hotkeys to it), and a named event called the moment the player 'unselects' an item (cycling to the next item or selecting 'clear inventory').

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 2 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...