1
0
Fork 0
mirror of https://github.com/tonytins/dressupzack synced 2025-05-07 14:04:48 -04:00

Moved common functions to GameKit.gd

- GameKit.gd is meant to act as library. Right now it contains functions for simplfying game pausing and making it easier to switch between commonly used scenes. This should ONLY be used for scripts that inherent the base node type (i.e. Node).
- Screenshot was updated to remove the menu bar.
This commit is contained in:
Anthony Wilcox 2019-01-05 14:29:39 -05:00
parent e96a904041
commit 67dac38ded
7 changed files with 35 additions and 31 deletions

View file

@ -7,7 +7,7 @@
[ext_resource path="res://assets/dressup_title.svg" type="Texture" id=5]
[ext_resource path="res://WinDialogs.tscn" type="PackedScene" id=6]
[node name="Start" type="Node"]
[node name="Start" type="Node" index="0"]
script = ExtResource( 1 )
@ -48,7 +48,6 @@ __meta__ = {
[node name="MenuRf" type="ReferenceRect" parent="." index="3"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
@ -239,6 +238,7 @@ group = null
text = "Modern"
flat = false
align = 1
_sections_unfolded = [ "Pause" ]
__meta__ = {
"_edit_lock_": true
}

View file

@ -3,18 +3,8 @@
[ext_resource path="res://src/WinDialogs.gd" type="Script" id=1]
[ext_resource path="res://music/song.ogg" type="AudioStream" id=2]
[node name="WinDialogs" type="Control" index="0"]
[node name="WinDialogs" type="Node" index="0"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
script = ExtResource( 1 )
[node name="Music" type="AudioStreamPlayer" parent="." index="0"]
@ -29,6 +19,7 @@ bus = "Master"
[node name="PauseWin" type="PopupDialog" parent="." index="1"]
pause_mode = 2
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
@ -160,6 +151,7 @@ align = 1
[node name="CreditsWin" type="AcceptDialog" parent="." index="2"]
editor/display_folded = true
visible = false
anchor_left = 0.0
anchor_top = 0.0
@ -280,7 +272,6 @@ columns = 3
[node name="Languages" type="MenuButton" parent="SettingsWin/Grid" index="0"]
pause_mode = 1
visible = false
anchor_left = 0.0
anchor_top = 0.0
@ -311,7 +302,8 @@ anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 65.0
margin_left = 60.0
margin_right = 125.0
margin_bottom = 24.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
@ -327,6 +319,7 @@ group = null
text = "KMUS"
flat = false
align = 1
_sections_unfolded = [ "Pause" ]
[node name="LicenseWin" type="AcceptDialog" parent="." index="4"]

17
project/src/GameKit.gd Normal file
View file

@ -0,0 +1,17 @@
# Anthony Wilcox licenses this file to you under the GPL license.
# See the LICENSE file in the project root for more information.
extends Node
func is_game_paused(is_paused):
if is_paused == true:
get_tree().paused = true
else:
get_tree().paused = false
func switch_scenes(new_mode):
if new_mode == "classic":
get_tree().change_scene("res://ClassicScn.tscn")
elif new_mode == "modern":
get_tree().change_scene("res://ModernScn.tscn")
elif new_mode == "start":
get_tree().change_scene("res://StartScn.tscn")

View file

@ -1,8 +1,8 @@
# Anthony Wilcox licenses this file to you under the GPL license.
# See the LICENSE file in the project root for more information.
extends Node
extends "res://src/GameKit.gd"
func _process(delta):
if Input.is_action_pressed("ui_pause"):
get_tree().paused = true
$WinDialogs/PauseWin.show()
is_game_paused(true)
$WinDialogs/PauseWin.show()

View file

@ -1,12 +1,12 @@
# Anthony Wilcox licenses this file to you under the GPL license.
# See the LICENSE file in the project root for more information.
extends Node
extends "res://src/GameKit.gd"
func _on_ClassicBtn_pressed():
get_tree().change_scene("res://ClassicScn.tscn")
switch_scenes("classic")
func _on_ModernBtn_pressed():
get_tree().change_scene("res://ModernScn.tscn")
switch_scenes("modern")
func _on_ClassicBtn_mouse_entered():
$Modern.hide()

View file

@ -1,16 +1,10 @@
# Anthony Wilcox licenses this file to you under the GPL license.
# See the LICENSE file in the project root for more information.
extends Control
func pause_zdressup(is_paused):
if is_paused == true:
get_tree().paused = true
else:
get_tree().paused = false
extends "res://src/GameKit.gd"
func _on_ExitBtn_pressed():
pause_zdressup(false)
get_tree().change_scene("res://StartScn.tscn")
is_game_paused(false)
switch_scenes("start")
func _on_SettingsBtn_pressed():
$SettingsWin.show()
@ -32,4 +26,4 @@ func _on_MusicBtn_toggled(button_pressed):
func _on_ResumeBtn_pressed():
$PauseWin.hide()
pause_zdressup(false)
is_game_paused(false)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 121 KiB