May 16, 2024, 11:56:10 AM
Welcome,
Guest
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Forum rules
-
please read before posting, it can save you a lot of time.
Home
Help
Search
Calendar
Login
Register
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Load window on Keypress
« previous
next »
Pages: [
1
]
Print
Author
Topic: Load window on Keypress (Read 5231 times)
0 Members and 1 Guest are viewing this topic.
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Load window on Keypress
«
on:
December 09, 2007, 05:18:37 AM »
Hey all,
How can I load a window when I press F5 at any point in the game?
I tried to add to the "Keypress" section of game.script.
I added:
if(Keyboard.KeyCode==VK_F5)
{
...
}
...after the escape key code, but it won't load my window.
Do I need to do something else?
Thanks.
Logged
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Re: Load window on Keypress
«
Reply #1 on:
December 09, 2007, 08:50:31 AM »
Ok - I sorted that problem - just forgot some ()
But now I want the window to close down when you press F5 for a second time, so I have this isn my window script:
Code: WME Script
////////////////////////////////////////////////////////////////////////////////
on
"Keypress"
{
if
(
Keyboard
.
KeyCode
==VK_F5
)
self.
Close
(
)
;
}
But it doesn't work. Is that wrong?
Thanks.
Logged
Mnemonic
WME developer
Administrator
Addicted to WME forum
Karma: 41
Offline
Gender:
Posts: 5683
Re: Load window on Keypress
«
Reply #2 on:
December 09, 2007, 09:24:57 AM »
It should work, as long as the window is exclusive.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Re: Load window on Keypress
«
Reply #3 on:
December 09, 2007, 09:34:09 AM »
Well I have tried it, GoExclusive and GoSystemExclusive, but it still won't close the window down.
Logged
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Re: Load window on Keypress
«
Reply #4 on:
December 09, 2007, 09:53:46 AM »
These are my scripts:
game.script
Code: WME Script
////////////////////////////////////////////////////////////////////////////////
on
"Keypress"
{
if
(
Keyboard
.
KeyCode
==VK_F5
)
{
var
MyWindow =
Game
.
LoadWindow
(
"windows\MyWindow\MyWindow.window"
)
;
MyWindow.
Center
(
)
;
MyWindow.
GoExclusive
(
)
;
Game
.
UnloadObject
(
MyWindow
)
;
}
}
MyWindow.window
Code: WME Script
WINDOW
{
X
=
348
Y
=
266
WIDTH =
328
HEIGHT =
237
NAME =
"my_window"
IMAGE =
"windows\MyWindow\MyWindow.jpg"
SCRIPT =
"windows\MyWindow\MyWindow.script"
PAUSE_MUSIC = FALSE
EDIT
{
NAME =
"my_editor"
FONT =
"fonts\sserif.font"
CURSOR =
"sprites\system\text_select_windows_mouse_cursor.sprite"
X
=
68
Y
=
130
WIDTH =
194
HEIGHT =
20
FRAME_WIDTH =
2
TEXT =
""
PARENT_NOTIFY = TRUE
}
BUTTON
{
PARENT_NOTIFY = TRUE
NAME =
"ok"
IMAGE =
"windows\MyWindow\MyWindow_ok_up.jpg"
IMAGE_PRESS =
"windows\MyWindow\MyWindow_ok_down.jpg"
X
=
125
Y
=
193
WIDTH =
77
HEIGHT =
26
}
}
MyWindow.script
Code: WME Script
#include
"scripts\base.inc"
#include
"scripts\keys.inc"
var
MyEditor =
this
.
GetControl
(
"my_editor"
)
;
////////////////////////////////////////////////////////////////////////////////
on
"ok"
{
do stuff
}
////////////////////////////////////////////////////////////////////////////////
on
"Keypress"
{
if
(
Keyboard
.
KeyCode
==VK_F5
)
self.
Close
(
)
;
}
Logged
Mnemonic
WME developer
Administrator
Addicted to WME forum
Karma: 41
Offline
Gender:
Posts: 5683
Re: Load window on Keypress
«
Reply #5 on:
December 09, 2007, 04:31:28 PM »
I don't see anything obviously wrong, IMO it should work. That's pretty much what all the windows in WME demos do, to handle the Escape key...
Try adding Game.Msg("something"); to the beginning of the script and to the Keypress handler to see if the script gets executed and if the event handler is triggered.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Re: Load window on Keypress
«
Reply #6 on:
December 09, 2007, 08:11:33 PM »
Tried that but it still didn't work.
Curously though if I just put Game.Msg("Something."), in the window script under "Keypress" and LEAVE OUT the if(Keyboard...) etc. I get the game message when I then press the Escape key.
What's that about? Is there something I don't understand about these windows?
Thanks.
Logged
Mnemonic
WME developer
Administrator
Addicted to WME forum
Karma: 41
Offline
Gender:
Posts: 5683
Re: Load window on Keypress
«
Reply #7 on:
December 09, 2007, 10:07:21 PM »
Ok, I know what's the problem. Your window contains an editor control, which is focused and eats the key presses. This is an issue, the editor should only eat the keys it can handle and pass the other ones back to the window. I'm adding it to my todo list.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.
TheDerman
Regular poster
Karma: 0
Offline
Posts: 225
Re: Load window on Keypress
«
Reply #8 on:
December 09, 2007, 10:14:30 PM »
Those greedy editor controls, eating everything they want.
That's cool - the window wasn't for anything important anyway - so I just added a normal "close" button.
Logged
Print
Pages: [
1
]
« previous
next »
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Load window on Keypress