Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Inventory window hidden  (Read 3961 times)

0 Members and 2 Guests are viewing this topic.

Squinage

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
    • Re:Gamed
Inventory window hidden
« on: September 16, 2012, 10:52:48 AM »

I'm new to this forum so I'll start by saying hello to everyone. Hello!  :)

I've been using Wintermute (which is an awesome bit of kit) for a few months now, and I think I understand the basics.

Now things are getting a bit more advanced, I'm having a bit of trouble with utilising windows to create an inventory that opens when the player clicks on an inventory icon in the top left hand corner of the screen (a bag).

The icon displays great. It's hidden when I don't need it and it doesn't break the game. What I'm trying to do now is when the player left clicks the icon, a window appears displaying the "inventory" (although I haven't coded this bit yet).

The code I have implemented thus far is as follows:

game.script

Code: WME Script
  1. //load the inventory window
  2. var WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  3. //load the inventory bag icon
  4. var WinInventoryIcon = Game.LoadWindow("interface\inventory\inventoryicon.window");
  5.  
  6. //Hide the inventory window
  7. WinInventoryOpen.Visible = false;
  8. WinInventoryOpen.Active = false;
  9.  
  10. //hide the inventory icon
  11. WinInventoryIcon.Visible = false;
  12. WinInventoryIcon.Active = false;

scene_init.script (for a scene in which I don't want the inventory icon OR window to display:
Code: WME Script
  1. //load the inventory window
  2. var WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  3.  
  4. //Hide the inventory window
  5. WinInventoryOpen.Visible = false;
  6. WinInventoryOpen.Active = false;
  7.  
  8. //load the inventory icon
  9. var WinInventoryIcon = Game.LoadWindow("interface\inventory\inventoryicon.window");
  10.  
  11. //Hide the inventory icon
  12. WinInventoryIcon.Visible = false;
  13. WinInventoryIcon.Active = false;

scene_init.script where I want the icon to display, but not the window
Code: WME Script
  1. //get the inventory icon
  2. var WinInventoryIcon = Game.LoadWindow("interface\inventory\inventoryicon.window");
  3. //and display it
  4. WinInventoryIcon.Active = true;
  5.  
  6. //load the inventory window
  7. var WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  8. //but make it disappear until needed
  9. WinInventoryOpen.Visible = false;
  10. WinInventoryOpen.Active = false;
  11.  

and finally, the script for when you click the icon, when the inventory window should display:
Code: WME Script
  1. var WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  2.  
  3. ////////////////////////////////////////////////////////////////////////////////
  4. on "LeftClick"
  5. {
  6.   WinInventoryOpen.Active = true;
  7.   WinInventoryOpen.Visible = true;
  8. }
  9.  

The behaviour at the moment is that the inventory icon displays and hides when I want it to, but the inventory window is always there.

What have I done wrong here?

Thanks for your responses in advance.

Squin
« Last Edit: September 16, 2012, 04:21:56 PM by Squinage »
Logged

Squinage

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
    • Re:Gamed
Re: Inventory window hidden
« Reply #1 on: September 16, 2012, 10:55:03 AM »

Oh and just to add, I do not appear to be getting any errors in the log or debug mode.

Thanks!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Inventory window hidden
« Reply #2 on: September 16, 2012, 11:50:58 AM »

Hi and welcome,

with this code you will be loading the windows over and over again, that's not good. Only load the windows once (in game.script), store them in global variables and just show/hide them when needed.

In game.script replace:

Code: WME Script
  1. var WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  2.  

with

Code: WME Script
  1. global WinInventoryOpen = Game.LoadWindow("interface\inventory\inventory.window");
  2.  

In the other scripts you just need to declare the global variable to access its shared content:


Code: WME Script
  1. global WinInventoryOpen;
  2. WinInventoryOpen.Visible = true;
  3.  

Secondly, you only need to set the .Visible property. Unlike scene entities, windows don't have an .Active property, they are just visible or hidden.

Other than that, I think your code should work. Make sure you remove the default handling in game_loop.script which displays/hides the inventory when the mouse pointer is moved to the top of the screen.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Squinage

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 11
    • View Profile
    • Re:Gamed
Re: Inventory window hidden
« Reply #3 on: September 16, 2012, 05:53:53 PM »

Amazing! Works a treat. Thank you very much for the assistance. I'm sure I'll have loads more questions ;D
Logged
 

Page created in 0.054 seconds with 19 queries.