April 26, 2024, 02:52:58 PM
Welcome,
Guest
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
IRC channel - server:
waelisch.de
channel:
#wme
(
read more
)
Home
Help
Search
Calendar
Login
Register
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Disabling keyboard
« previous
next »
Pages: [
1
]
Print
Author
Topic: Disabling keyboard (Read 3309 times)
0 Members and 1 Guest are viewing this topic.
Chaos
supporter
Lurker
Karma: 1
Offline
Gender:
Posts: 45
"WME rocks!"
Disabling keyboard
«
on:
June 04, 2014, 06:50:00 AM »
Hello guys! I know exactly how to lock the mouse, and actually I've been using this for years by using
"Game.LockMouseRect(0,0,0,0);"
But now I wonder, is there any way to disable an specific key from the keyboard (or the whole keyboard) in a specific
scene, in this case the "Main Menu"? Thanks for your help...
«
Last Edit: June 04, 2014, 06:51:42 AM by Chaos
»
Logged
ciberspace
Regular poster
Karma: 1
Offline
Gender:
Posts: 116
Re: Disabling keyboard
«
Reply #1 on:
June 04, 2014, 02:32:51 PM »
Can it be?
Keyboard object
The Keyboard object represents the current state of the keyboard. There is always one and only Keyboard object available. It's accessible via the Game.Keyboard attribute. For the convenience the templates automatically store the keyboard object in a global variable named Keboard.
Methods
IsKeyDown Queries whether a specified key is pressed.
Attributes
Type (read only) Returns always "keyboard"
Key (read only) Returns a string with the name of the pressed key (if the key is a printable character)
Printable (read only) Returns true if the pressed key is a printable character
KeyCode (read only) Returns a numeric code of a pressed key.
IsShift (read only) Returns true if the SHIFT key has been hold down when the key was pressed
IsAlt (read only) Returns true if the ALT key has been hold down when the key was pressed
IsControl (read only) Returns true if the CONTROL key has been hold down when the key was pressed
Logged
Personal site:
https://ciberspacedesigner.wordpress.com/juegos/
Personal site:
http://ciberspacedesigner.wordpress.com/
Azrael
Regular poster
Karma: 9
Offline
Gender:
Posts: 155
Re: Disabling keyboard
«
Reply #2 on:
June 05, 2014, 07:59:09 AM »
If you need only to disable the main menu there is a simple way, in your game.script you should have something like:
Code: WME Script
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
)
;
}
}
So simply change it on something like:
Code: WME Script
on
"Keypress"
{
// on Esc or F1 key
if
(
(
Keyboard
.
KeyCode
==VK_ESCAPE ||
Keyboard
.
KeyCode
==VK_F1
)
&&
Scene
.
Name
!=
"NameOfTheScene"
)
{
// 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
)
;
}
}
If you have to do it on many scenes you could also use a scene variable. So on your scene.init add somewhere:
Code: WME Script
Scene
.
DontDisplayMenu
=
true
;
And on the game.script:
Code: WME Script
on
"Keypress"
{
// on Esc or F1 key
if
(
(
Keyboard
.
KeyCode
==VK_ESCAPE ||
Keyboard
.
KeyCode
==VK_F1
)
&&
Scene
.
DontDisplayMenu
!=
true
)
{
// 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
)
;
}
}
Also remember to set "Scene.DontDisplayMenu" on "false", "null" or something else not "true" on the other scenes, maybe adding it on "base.inc" so it will be always active except when you don't want
Logged
Print
Pages: [
1
]
« previous
next »
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
Disabling keyboard