Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Uhfgood on August 02, 2012, 09:01:55 PM

Title: Trying to display my own window
Post by: Uhfgood on August 02, 2012, 09:01:55 PM
For some strange reason I can not get a window I created to display at all.  I tried it in game.script, game_loop.script, and scene.script, by setting Visible to true.  It will not show up at all.  I tried modifying the x and y position in the window editor just in case it was showing off screen, and it wasn't.

I *do* know that it *does* load up in game.script -- and will display when the game starts if it's visible flag is true.  But set it to false in game.script, and then try to set it to true in any other script just doesn't work.

What am I doing wrong?
Title: Re: Trying to display my own window
Post by: Mnemonic on August 03, 2012, 06:39:43 AM
Since we don't know *what* exactly you're doing it's hard to say what you're doing wrong. Post your scripts.
Title: Re: Trying to display my own window
Post by: Spellbreaker on August 03, 2012, 09:50:58 AM
As Mnemonic said, show your scripts, but a simple guess from my side would be: Did you forget to set the variable containing your window object to global?
Title: Re: Trying to display my own window
Post by: Uhfgood on August 03, 2012, 05:13:15 PM
game.script --
Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"

// store some of the game's attributes in global variables for convenience
Keyboard = Game.Keyboard;
Scene = Game.Scene;


// load the right-click menu
global WinMenu = Game.LoadWindow("interface\menu\menu.window");
WinMenu.Visible = false;

// load the "caption" window
var win = Game.LoadWindow("interface\system\caption.window");
global WinCaption = win.GetControl("caption");


global PieMenu = Game.LoadWindow("\interface\menu\pie_menu.window");
PieMenu.Visible = false;

global MenuObject = null;


// load our main actor
actor = Game.LoadActor("actors\Harold\Harold.actor");
Game.MainObject = actor;

// run the "game loop" script
Game.AttachScript("scripts\game_loop.script");


// which scene to load?
Game.ChangeScene(Game.StartupScene);



////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
PieMenu.Visibile = true;

/*
// what did we click?
var ActObj = Game.ActiveObject;
if(ActObj!=null)
{
ActObj.ApplyEvent("LeftClick");
}
// else propagate the LeftClick event to a scene
else
{
Scene.ApplyEvent("LeftClick");
}
*/
}



////////////////////////////////////////////////////////////////////////////////
on "RightClick"
{
 
}


////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  // on Esc or F1 key
  if(Keyboard.KeyCode==VK_ESCAPE || Keyboard.KeyCode==VK_F1)
  {
    // load and display the main menu window
    WinCaption.Visible = false;
    var WinMainMenu = Game.LoadWindow("interface\system\mainmenu.window");
    WinMainMenu.Center();
    WinMainMenu.GoSystemExclusive();
    Game.UnloadObject(WinMainMenu);
  }
}


////////////////////////////////////////////////////////////////////////////////
on "QuitGame"
{
  // on Alt+F4 (window close)
  // load and display the quit confirmation window
  WinCaption.Visible = false;
  var WinQuit = Game.LoadWindow("interface\system\quit.window");
  WinQuit.Center();
  WinQuit.GoSystemExclusive();

  // and if the user selected Yes
  if(WinQuit.xResult)
  {
    // quit the game
    Game.QuitGame();
  }
  // otherwise just unload the quit window from memory
  else Game.UnloadObject(WinQuit);
}
Title: Re: Trying to display my own window
Post by: Dan Peach on August 03, 2012, 05:51:28 PM
Spelling mistake on your first LeftClick instruction. Dunno if that's the problem, but it won't help. :)
Title: Re: Trying to display my own window
Post by: Uhfgood on August 03, 2012, 08:03:10 PM
Fixed.  And in fact it's actually displaying now.  Maybe I was spelling it wrong all the time for some reason.

Thanks for spotting it, sometimes people tend to overlook something when they kept looking at it for so long.