Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Marcello on August 14, 2006, 05:27:04 PM

Title: Inventory avaiable through Symbol
Post by: Marcello on August 14, 2006, 05:27:04 PM
I would like my inventory to be invisible until you click on a symbol which should be located in the upper left corner of the screen.
If you click it the inventory window should show up.
So far I changed the shape and size of my inventory window. My question now is how do I make the Symbol?
Do I have to load it in each scene script like the actor and the entities and just define that a click on it pauses the game and opens the inventory? Or is there better way to do it?
Title: Re: Inventory avaiable through Symbol
Post by: Mnemonic on August 14, 2006, 05:49:41 PM
Or is there better way to do it?
Yes. Use the user interface instead. Create a transparent window covering the entire screen, the window will contain one button (-> the symbol). The button will open the inventory when it's clicked.

To make a window transparent, add TRANSPARENT = TRUE to its definition.
Title: Re: Inventory avaiable through Symbol
Post by: Marcello on August 28, 2006, 12:51:46 PM
I'm sorry, but I don't get........I can't manage to get the transparant window and its button to show up in the game.
I made a transparant window:
{
  NAME = "transparent"
  TEMPLATE = "interface\transparentwindow.window"

  ; position and size
  X = 0
  Y = 0
  WIDTH = 800
  HEIGHT = 600
  VISIBLE = TRUE
  DISABLED = FALSE
  TITLE = "transparent window"
  TITLE_RECT { 5,5,235,45 } 
  TITLE_ALIGN = left
  DRAG_RECT { 0,0,215,25 }
  FONT = "fonts\bart.font"
  FONT_INACTIVE = "bart.font"
  SCRIPT = "interface\transparentinv.script"
  TRANSPARENT = TRUE
  MENU = TRUE
  IN_GAME = TRUE
  CLIP_CONTENTS = TRUE
 }
 
Containing one button:
  BUTTON
  {
    NAME = "truhe"
    TEXT = "Truhe"
    X = 0
    Y = 0
    WIDTH = 100
    HEIGHT = 60
  }
This is the button definition (truhe.button):
BUTTON
{
  FONT = "fonts\outline_white.font"
  FONT_DISABLE = "fonts\outline_disabled.font"

  BACK = "ui_elements\truhe.png"
  BACK_HOVER = "ui_elements\truhe.png"
  BACK_PRESS = "ui_elements\truhe.png"
  BACK_DISABLE = "ui_elements\truhe.png"
  BACK_FOCUS = "ui_elements\truhe.png"

  PARENT_NOTIFY = TRUE

  WIDTH = 100
  HEIGHT = 50

  TEXT_ALIGN = CENTER
  CENTER_IMAGE = TRUE
}
It also has an truhe.image file:
TILED_IMAGE
{
IMAGE="ui_elements\truhe.png"
VERTICAL_TILES {10,10,10}
HORIZONTAL_TILES {10,10,10}
}
I think I have to change this part of the gam_daemon.script:
  if(Game.Interactive && Game.MouseY < 45 && !Game.ResponsesVisible && !WinMenu.Visible) Game.InventoryVisible = true;
  else if(Game.MouseY > 100 || Game.ResponsesVisible || !Game.Interactive) Game.InventoryVisible = false;
but I don't know what it should be...
Title: Re: Inventory avaiable through Symbol
Post by: Mnemonic on August 28, 2006, 04:05:57 PM
Ummm, ok:

1) Copy the definition of the button directly into the .window file. No need to keep it separately, and you're not refrencing it anway.
2) You're not referencing the truhe.image anywhere.
3) You don't need that code in game_daemon.script at all. It was used to automatically show/hide the inventory depending on mouse pointer position. I suppose you don't want to do that in this case. So, remove those lines.

Instead, edit the "transparentinv.script" and add something like:

Code: [Select]
on "truhe"
{
   Game.InventoryVisible = true;
}

That is, when the "truhe" button is pressed, the inventory window will pop-up.

You didn't say how you want to dismiss the inventory window...
Title: Re: Inventory avaiable through Symbol
Post by: Marcello on August 28, 2006, 07:37:01 PM
Okay, I tried but still no button in game, don't I have to load the transparant window somewhere?
Title: Re: Inventory avaiable through Symbol
Post by: Mnemonic on August 29, 2006, 05:52:33 PM
Yes, yes of course. Since it's supposed to be always visible, you can load it directly in game.script.

global InvButtonWindow = Game.LoadWindow("path\filename.window");
Title: Re: Inventory avaiable through Symbol
Post by: Marcello on September 04, 2006, 02:05:16 PM
Okay, its nearly working now, I'll guess I figure out the last mistakes.

But I have another question I couldn't find an answer for:
What is a non-variable Entity and how do I change it? Because I get the Error message that I'm trying to call a method from a non-variable Entity when I try to use  Entity.PlayAnim.
Title: Re: Inventory avaiable through Symbol
Post by: adonf on September 04, 2006, 04:53:52 PM
are you calling it like this: Entity.PlayAnim("my_anim") ?

in this case you're calling the function on the Entity class, instead of callling it on the object. PlayAnim must be called on a specific object of type Entity (same as non-static vs static methods if you're familiar with C++ or java)

so you need to do something like

Code: [Select]
var entity_obj = Scene.GetNode("my_entity_name");
entity_obj.PlayAnim("my_anim");
Title: Re: Inventory avaiable through Symbol
Post by: Marcello on September 04, 2006, 08:45:49 PM
I'm not familiar with any kind of programming language which is why I'm asking such stupid questions.  :-[