Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1] 2  All

Author Topic: Fading in/out the inventory window  (Read 14984 times)

0 Members and 1 Guest are viewing this topic.

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Fading in/out the inventory window
« on: December 09, 2005, 02:31:28 AM »

Hi,

Just wondering how I can fade the inventory window in and out. I have it at the bottom of the screen, and when the player moves the mouse down there I want the window to fade in (I'm assuming all the items will fade in aswell if the actual window is set to fade). Then when they leave that area, the window fades out.

Where can I put the necessary code?

Thanks.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Fading in/out the inventory window
« Reply #1 on: December 09, 2005, 09:17:26 AM »

It's mostly a matter of convenience. Personally, I'd create two methods, FadeIn() and FadeOut() and place them to the script attached to your inventory window. Something like:

Code: [Select]
method FadeIn()
{
  // some fade in code similar to what you're using to fade in the actor
  // http://forum.dead-code.org/index.php?topic=936.msg6969#msg6969
}


Then you'd have to modify the game_daemon.script, which handles the inventory display/hide.
Right now it does something like: Game.InventoryVisible = true;
You'd have to replace this line by something like:

Code: [Select]
var InvWindow = Game.GetInventoryWindow();
InvWindow.FadeIn();


I hope that makes sense. If not, feel free to ask for further details :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #2 on: December 09, 2005, 09:21:49 AM »

Was I really fading in the actor? How crazy of me - I'm not doing that anymore.  ;D Actually, it's a different game.

Thanks for the help - I'll give it a try.

EDIT - had another question here, but I sorted it out.  8)
« Last Edit: December 09, 2005, 09:51:17 AM by TheDerman »
Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #3 on: December 10, 2005, 05:49:35 PM »

Ok, I'm afraid I don't really understand how to do this inventory fading thing.

I put the method code in my inventory.script? But then after I put all the fading stuff, what do I actually tell it to fade?

This is how I'm fading stuff:

  for(var i=1; i<=10; i=i+1)

etc...

But don't I need to actually state what is I'm fading after that code?  ???

I need mucho more help. Cheers.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Fading in/out the inventory window
« Reply #4 on: December 12, 2005, 10:39:58 AM »

You put the two methods to the script attached to the inventory window. In your inventory box defintion there's something like:

Code: [Select]
INVENTORY_BOX
{
  ITEM_WIDTH = 65
  ITEM_HEIGHT = 65
  blah blah
  ...

  WINDOW
  {
    blah blah
    ...
   

You need to attach the script to the embedded window like this:


Code: [Select]
INVENTORY_BOX
{
  ITEM_WIDTH = 65
  ITEM_HEIGHT = 65
  blah blah

  WINDOW
  {
    SCRIPT = "path\window_fading.script"
    blah blah
    ...
   

And those two methods will look exactly like the actor fading code in the other thread linked above, but you'll replace "actor" with "this". Since the script is attached to the inventory window, the "this" variable points to the window itself.
I hope that helps.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #5 on: December 12, 2005, 11:08:07 AM »

I tried all that you suggest but it still won't fade in - I just get nothing, no inventory.

This is my inventory.script attached to the inventory.def

Code: [Select]
#include "scripts\base.inc"

method FadeIn()
{
  for(var i=1; i<=10; i=i+1)
   {
    this.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
    Sleep(100);
   }
  this.AlphaColor = MakeRGBA(255, 255, 255, 255);
}

method FadeOut()
{
  for(var i=10; i>=10; i=i-1)
   {
    this.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
    Sleep(100);
   }
  this.AlphaColor = MakeRGBA(255, 255, 255, 0);
}

This is my game_daemon.script

Code: [Select]
  // display the inventory window
  var InvWindow = Game.GetInventoryWindow();

  if(Game.Interactive && Game.MouseY > 704 && !Game.ResponsesVisible && !WinMenu.Visible)
    {
      InvWindow.FadeIn();
    }

  else if(Game.MouseY < 704 || Game.ResponsesVisible || !Game.Interactive)
    {
      InvWindow.FadeOut();
    }


But it doesn't work.  ???
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Fading in/out the inventory window
« Reply #6 on: December 12, 2005, 11:20:15 AM »

Ok, one more thing you'll probably have to do, this.Visible = true; at the beginning of FadeIn, and this.Visible = false; at the end of FadeOut. That should do the trick, I hope...?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #7 on: December 12, 2005, 11:36:59 AM »

Nope. I'm afraid that didn't work either.   ;D

Tough one eh?
Logged

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #8 on: December 12, 2005, 11:43:53 AM »

Ok, I replaced your this.Visible = true; with  Game.InventoryVisible = true; at the start of FadeIn and  Game.InventoryVisible = false; at the end of FadeOut.

Now the inventory continuously fades in and in and in and in forever. And just disappears when I move the mouse out of the area, so I guess the fade in is working somewhat but the fadeout not at all...???

 ;D

EDIT - could this be due to the game_daemon.script looping? So everytime that script loops around, and the conditions for fading in the inventory are TRUE (i.e. my mouse is at the bottom of the screen), it's fading in the inventory again and again...???
« Last Edit: December 12, 2005, 11:49:38 AM by TheDerman »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Fading in/out the inventory window
« Reply #9 on: December 12, 2005, 11:57:35 AM »

yes, you should put there condition to fadein or out only  if it's not been faded already.
 
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #10 on: December 12, 2005, 12:17:46 PM »

Thanks Metamorphium, I guessed that -  took me a bit to figue it out how to put that condition in there though.   ;D

But I now have a perfectly fading inventory - yay!!! Just need to adjust the speed now.

Here's the code I ended up with in case anyone else comes looking.

inventory.script
Code: [Select]
#include "scripts\base.inc"

global Faded;

method FadeIn()
{
 Game.InventoryVisible = true;
 for(var i=1; i<=10; i=i+1)
   {
    this.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
    Sleep(100);
   }
 this.AlphaColor = MakeRGBA(255, 255, 255, 255);
 Faded = true;
}

method FadeOut()
{
  for(var i=10; i>=1; i=i-1)
   {
    this.AlphaColor = MakeRGBA(255, 255, 255, 25*i);
    Sleep(100);
   }
  this.AlphaColor = MakeRGBA(255, 255, 255, 0);
 Game.InventoryVisible = false;
 Faded = false;
}

and the game_daemon.script
Code: [Select]
  // display the inventory window
  var InvWindow = Game.GetInventoryWindow();
  if(Game.Interactive && Game.MouseY > 704 && !Game.ResponsesVisible && !WinMenu.Visible && Faded ==false)
   {
     InvWindow.FadeIn();
   }

  else if(Game.MouseY < 704 || Game.ResponsesVisible || !Game.Interactive)
   {
     InvWindow.FadeOut();
   }

And I had to put global Faded = false; at the top of the game_daemon.script (I think - well I did anyway and it works  ;D).

Thanks guys - I'm very happy now.  ::rock
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Fading in/out the inventory window
« Reply #11 on: December 12, 2005, 04:44:57 PM »

This can't work IMO properly. Try to fade it out and then quickly move your cursor up and down. You will probably see another fadeout.
I would recommend trying something like this:

Code: [Select]
method FadeIn()
{
  ... // the code from your function as-is
  Faded = true;
}

method FadeOut()
{
  ... // the code from your function as-is
  Faded = false;
}

// the conditions should be something like
if (!Faded)  InvWindow.FadeIn();
//And
if (Faded)  InvWindow.FadeOut();


It's of course untested, but should work anyway. ;)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #12 on: December 12, 2005, 06:12:43 PM »

It works perfectly with the code I stated as far as the fade in and out goes.

Only problem was that it was continuously running the fadeout code when the inventory was not visible. That didn't affect the fade in or out, but it did slow down my caption window a little, but I fixed that with another condition so no problems here.  8)

Thanks again.
Logged

SBOVIS

  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 404
  • FORGET REALITY SURRENDER TO YOUR DARKEST DREAMS
    • View Profile
    • LIMBO of the LOST
Re: Fading in/out the inventory window
« Reply #13 on: January 12, 2006, 08:42:57 PM »

Hi there,
            Is there any chance oyu could put the full scripts for this and how to achieve this somewhere on the forum.


I would like to have a go at fading in/out my inventory box and maybe other windows??

If not then maybe you can send me the scripts via email and how to achieve this.

(Been trying to do this for ages!! hahahahahahahahahahaha)
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

PoselSmrti

  • Guest
Re: Fading in/out the inventory window
« Reply #14 on: January 12, 2006, 10:03:09 PM »

I have found this thread and it is great  :)!!! Very thx to all! :)
Logged
Pages: [1] 2  All
 

Page created in 0.155 seconds with 23 queries.