summaryrefslogtreecommitdiff
path: root/demos/misc/window_management
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2015-12-09 08:38:23 +0100
committerRémi Verschelde <rverschelde@gmail.com>2015-12-09 08:38:23 +0100
commit8639cecf4cedd56452b47503be19c44b304cd02f (patch)
treee2a795da15e40c7d9d5b82e33378f8dbf0eaf67a /demos/misc/window_management
parentefbb834936fdc9da9789ad37c9cc61e0b90cda95 (diff)
Improve code formatting and update to 2.0
The scripts were streamlined using more or less the following conventions: - space after a comma in lists of arguments - space around weak operators (+, -), no space around strong operators (*, /) - space after a comment start (#) - removed trailing spaces or tabs, apart from those that delimit the function indentation level (those could be removed too but since they are added automatically by the editor when typing code, keeping them for now) - function blocks separate by two newlines The scene files were resaved with the (current) 2.0 format, and some scenes that were in XML format were converted to SCN, to be consistent across all demos.
Diffstat (limited to 'demos/misc/window_management')
-rw-r--r--demos/misc/window_management/control.gd85
-rw-r--r--demos/misc/window_management/observer/observer.gd29
-rw-r--r--demos/misc/window_management/observer/observer.scnbin1786 -> 3824 bytes
-rw-r--r--demos/misc/window_management/window_management.scnbin5132 -> 4384 bytes
4 files changed, 57 insertions, 57 deletions
diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd
index 1609dda699..881dbdc798 100644
--- a/demos/misc/window_management/control.gd
+++ b/demos/misc/window_management/control.gd
@@ -1,17 +1,18 @@
extends Control
+# member variables
var mousepos
-func _fixed_process(delta):
+func _fixed_process(delta):
var modetext = "Mode:\n"
if(OS.is_window_fullscreen()):
modetext += "Fullscreen\n"
else:
modetext += "Windowed\n"
-
+
if(!OS.is_window_resizable()):
modetext += "FixedSize\n"
@@ -29,119 +30,119 @@ func _fixed_process(delta):
get_node("Label_Mode").set_text(modetext)
- get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) )
+ get_node("Label_Position").set_text(str("Position:\n", OS.get_window_position()))
- get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) )
+ get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size()))
- get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos ) )
+ get_node("Label_MousePosition").set_text(str("Mouse Position:\n", mousepos))
- get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) )
+ get_node("Label_Screen_Count").set_text(str("Screen_Count:\n", OS.get_screen_count()))
- get_node("Label_Screen_Current").set_text( str("Screen:\n", OS.get_current_screen() ) )
+ get_node("Label_Screen_Current").set_text(str("Screen:\n", OS.get_current_screen()))
- get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) )
+ get_node("Label_Screen0_Resolution").set_text(str("Screen0 Resolution:\n", OS.get_screen_size()))
- get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position() ) )
+ get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n", OS.get_screen_position()))
if(OS.get_screen_count() > 1):
get_node("Button_Screen0").show()
get_node("Button_Screen1").show()
get_node("Label_Screen1_Resolution").show()
get_node("Label_Screen1_Position").show()
- get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
- get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
+ get_node("Label_Screen1_Resolution").set_text(str("Screen1 Resolution:\n", OS.get_screen_size(1)))
+ get_node("Label_Screen1_Position").set_text(str("Screen1 Position:\n", OS.get_screen_position(1)))
else:
get_node("Button_Screen0").hide()
get_node("Button_Screen1").hide()
get_node("Label_Screen1_Resolution").hide()
get_node("Label_Screen1_Position").hide()
-
- get_node("Button_Fullscreen").set_pressed( OS.is_window_fullscreen() )
- get_node("Button_FixedSize").set_pressed( !OS.is_window_resizable() )
- get_node("Button_Minimized").set_pressed( OS.is_window_minimized() )
- get_node("Button_Maximized").set_pressed( OS.is_window_maximized() )
- get_node("Button_Mouse_Grab").set_pressed( Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED )
+
+ get_node("Button_Fullscreen").set_pressed(OS.is_window_fullscreen())
+ get_node("Button_FixedSize").set_pressed(!OS.is_window_resizable())
+ get_node("Button_Minimized").set_pressed(OS.is_window_minimized())
+ get_node("Button_Maximized").set_pressed(OS.is_window_maximized())
+ get_node("Button_Mouse_Grab").set_pressed(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED)
func check_wm_api():
var s = ""
- if( !OS.has_method("get_screen_count") ):
+ if(!OS.has_method("get_screen_count")):
s += " - get_screen_count()\n"
- if( !OS.has_method("get_current_screen") ):
+ if(!OS.has_method("get_current_screen")):
s += " - get_current_screen()\n"
- if( !OS.has_method("set_current_screen") ):
+ if(!OS.has_method("set_current_screen")):
s += " - set_current_screen()\n"
- if( !OS.has_method("get_screen_position") ):
+ if(!OS.has_method("get_screen_position")):
s += " - get_screen_position()\n"
- if( !OS.has_method("get_screen_size") ):
+ if(!OS.has_method("get_screen_size")):
s += " - get_screen_size()\n"
- if( !OS.has_method("get_window_position") ):
+ if(!OS.has_method("get_window_position")):
s += " - get_window_position()\n"
- if( !OS.has_method("set_window_position") ):
+ if(!OS.has_method("set_window_position")):
s += " - set_window_position()\n"
- if( !OS.has_method("get_window_size") ):
+ if(!OS.has_method("get_window_size")):
s += " - get_window_size()\n"
- if( !OS.has_method("set_window_size") ):
+ if(!OS.has_method("set_window_size")):
s += " - set_window_size()\n"
- if( !OS.has_method("set_window_fullscreen") ):
+ if(!OS.has_method("set_window_fullscreen")):
s += " - set_window_fullscreen()\n"
- if( !OS.has_method("is_window_fullscreen") ):
+ if(!OS.has_method("is_window_fullscreen")):
s += " - is_window_fullscreen()\n"
- if( !OS.has_method("set_window_resizable") ):
+ if(!OS.has_method("set_window_resizable")):
s += " - set_window_resizable()\n"
- if( !OS.has_method("is_window_resizable") ):
+ if(!OS.has_method("is_window_resizable")):
s += " - is_window_resizable()\n"
- if( !OS.has_method("set_window_minimized") ):
+ if(!OS.has_method("set_window_minimized")):
s += " - set_window_minimized()\n"
- if( !OS.has_method("is_window_minimized") ):
+ if(!OS.has_method("is_window_minimized")):
s += " - is_window_minimized()\n"
- if( !OS.has_method("set_window_maximized") ):
+ if(!OS.has_method("set_window_maximized")):
s += " - set_window_maximized()\n"
- if( !OS.has_method("is_window_maximized") ):
+ if(!OS.has_method("is_window_maximized")):
s += " - is_window_maximized()\n"
- if( s.length() == 0 ):
+ if(s.length() == 0):
return true
else:
var text = get_node("ImplementationDialog/Text").get_text()
- get_node("ImplementationDialog/Text").set_text( text + s )
+ get_node("ImplementationDialog/Text").set_text(text + s)
get_node("ImplementationDialog").show()
return false
func _ready():
- if( check_wm_api() ):
+ if(check_wm_api()):
set_fixed_process(true)
set_process_input(true)
-func _input(ev):
- if (ev.type==InputEvent.MOUSE_MOTION):
- mousepos = ev.pos
+func _input(event):
+ if (event.type == InputEvent.MOUSE_MOTION):
+ mousepos = event.pos
func _on_Button_MoveTo_pressed():
- OS.set_window_position( Vector2(100,100) )
+ OS.set_window_position(Vector2(100, 100))
func _on_Button_Resize_pressed():
- OS.set_window_size( Vector2(1024,768) )
+ OS.set_window_size(Vector2(1024, 768))
func _on_Button_Screen0_pressed():
diff --git a/demos/misc/window_management/observer/observer.gd b/demos/misc/window_management/observer/observer.gd
index d27912a670..c1878bca43 100644
--- a/demos/misc/window_management/observer/observer.gd
+++ b/demos/misc/window_management/observer/observer.gd
@@ -1,16 +1,17 @@
extends Spatial
+# member variables
var r_pos = Vector2()
var state
-const STATE_MENU=0
-const STATE_GRAB=1
+const STATE_MENU = 0
+const STATE_GRAB = 1
+
func direction(vector):
- var v = get_node("Camera").get_global_transform().basis * vector
+ var v = get_node("Camera").get_global_transform().basis*vector
v = v.normalized()
-
return v
@@ -22,7 +23,6 @@ func impulse(event, action):
func _fixed_process(delta):
-
if(state != STATE_GRAB):
return
@@ -34,31 +34,31 @@ func _fixed_process(delta):
var org = get_translation()
if (Input.is_action_pressed("move_forward")):
- dir += direction(Vector3(0,0,-1))
+ dir += direction(Vector3(0, 0, -1))
if (Input.is_action_pressed("move_backwards")):
- dir += direction(Vector3(0,0,1))
+ dir += direction(Vector3(0, 0, 1))
if (Input.is_action_pressed("move_left")):
- dir += direction(Vector3(-1,0,0))
+ dir += direction(Vector3(-1, 0, 0))
if (Input.is_action_pressed("move_right")):
- dir += direction(Vector3(1,0,0))
+ dir += direction(Vector3(1, 0, 0))
dir = dir.normalized()
- move(dir * 10 * delta)
- var d = delta * 0.1
+ move(dir*10*delta)
+ var d = delta*0.1
- var yaw = get_transform().rotated(Vector3(0,1,0), d * r_pos.x)
+ var yaw = get_transform().rotated(Vector3(0, 1, 0), d*r_pos.x)
set_transform(yaw)
var cam = get_node("Camera")
- var pitch = cam.get_transform().rotated(Vector3(1,0,0), d * r_pos.y)
+ var pitch = cam.get_transform().rotated(Vector3(1, 0, 0), d*r_pos.y)
cam.set_transform(pitch)
r_pos.x = 0.0
r_pos.y = 0.0
-func _input( event ):
+func _input(event):
if(event.type == InputEvent.MOUSE_MOTION):
r_pos = event.relative_pos
@@ -76,4 +76,3 @@ func _ready():
set_process_input(true)
state = STATE_MENU
-
diff --git a/demos/misc/window_management/observer/observer.scn b/demos/misc/window_management/observer/observer.scn
index da29ad62b8..813d7d4587 100644
--- a/demos/misc/window_management/observer/observer.scn
+++ b/demos/misc/window_management/observer/observer.scn
Binary files differ
diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn
index 8db43b6638..35662871f1 100644
--- a/demos/misc/window_management/window_management.scn
+++ b/demos/misc/window_management/window_management.scn
Binary files differ