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 14989 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

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 #15 on: January 13, 2006, 10:22:29 AM »

I am having trouble with this, I have used the scripts listed but the inventory does not show at all now.


I have connected it to my INVENTORY window script.

Updated Game Deamon but still nothing.


Any help or full scripts would be good, save my hair being pulled out. hahahahahahaha


Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #16 on: January 13, 2006, 02:37:17 PM »

These are the scripts I have:


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(40);
   }
 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(40);
   }
 this.AlphaColor = MakeRGBA(255, 255, 255, 0);
 Game.InventoryVisible = false;
 Faded = false;
}


And the relevant section of 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 && Faded==true)
   {
     InvWindow.FadeOut();
   }

Hope that helps.
« Last Edit: January 13, 2006, 02:49:11 PM by TheDerman »
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 #17 on: January 13, 2006, 03:41:30 PM »

Many thanks TheDerman.

In the game deamon scripts does this new code replace the old (unchanged demo script) or does it need to be added with the old code??


Cheers
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #18 on: January 13, 2006, 03:49:02 PM »

It replaces only the part of the daemon script which deals with the inventory (down at the bottom) - everything else should be left as it is.

You will have to change certain things specific to your game, like the Y value - my inventory is at the bottom of the screen - you may have yours at the top or somewhere else.
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 #19 on: January 13, 2006, 03:51:26 PM »

ok many thanks, will give it a bash and let you know.


Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

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 #20 on: January 14, 2006, 01:46:52 PM »

Hi,
     I have tried to implement these scripts but my inventory does not show.

I have attached the inventory fade script to my inventory window and changed Game Deamon script but still no inventory is showing.

TheDerman can you show me your full Game Deamon script on this thread as I think that is the issue here.


Cheers
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

PoselSmrti

  • Guest
Re: Fading in/out the inventory window
« Reply #21 on: January 14, 2006, 04:32:46 PM »

Hi SBOVIS :)!

Did you create a global Faded = false; in your game_daemon.script?
« Last Edit: January 14, 2006, 04:36:02 PM by PoselSmrti »
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 #22 on: January 15, 2006, 12:35:39 AM »

Certainly did, still no show on my inventory though, If I take the fade code out and reset it back the way it was, I get the inventory no problem. (just not fadeing)




Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

TheDerman

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 225
    • View Profile
Re: Fading in/out the inventory window
« Reply #23 on: January 15, 2006, 09:32:29 AM »

Maybe if you post your inventory script and daemon script, we could spot the problem?

Did you insert SCRIPT = "interface\inventory.script" into your inventory.def in the WINDOW section of the file?
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 #24 on: January 15, 2006, 10:15:25 AM »

Also please check your wme.log for error messages. You'll usually find some clues as why it doesn't work there. If there is something written what looks like an error, post it together with requested files too. ;)
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

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 #25 on: January 15, 2006, 03:04:50 PM »

ok will check and post files if needed.


many thanks



cheers
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

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 #26 on: January 16, 2006, 01:43:20 PM »

Got this to work now, many thanks, looks great,

It was the Game.Deamon script as I have other code that conflicted with it.


By the way can this fade method be used for any windows??

I have several that would work well when faded, I have defined windows so do I do a similar script and attach it and call that within other scripts when I want it to fade??


Seems feasible??

Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS

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 #27 on: January 16, 2006, 01:44:55 PM »

yes, you can definitely use it for any window you like.

Glad it works for you now.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

djb

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 28
  • ... dream journey beyond ...
    • View Profile
    • DreamJourneyBeyond.com
Re: Fading in/out the inventory window
« Reply #28 on: January 16, 2006, 03:57:00 PM »

i think, that you can optimize it and skip needlessly tests in game_daemon.script...

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

global Faded;

method FadeIn()
{
 if(!Faded) {
  Game.InventoryVisible = true;
  for(var i = 0; i <= 255; i = i + 25) {
    this.AlphaColor = MakeRGBA(255, 255, 255, i);
    Sleep(40);
   }
   this.AlphaColor = MakeRGBA(255, 255, 255, 255);
   Faded = true;
 }
}

method FadeOut()
{
 if(Faded) {
  for(var i = 255; i >= 0; i = i - 25) {
   this.AlphaColor = MakeRGBA(255, 255, 255, i);
   Sleep(40);
  }
  this.AlphaColor = MakeRGBA(255, 255, 255, 0);
  Game.InventoryVisible = false;
  Faded = false;
 }
}
« Last Edit: January 16, 2006, 04:04:57 PM by djb »
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 #29 on: January 16, 2006, 04:32:33 PM »

This is cool, I now have an inventory and other windows fadeing in and out, many thanks.
Logged
kind Regards
Steve Bovis
MAJESTIC STUDIOS
Pages: 1 2 [All]
 

Page created in 0.062 seconds with 20 queries.