forked from team-sg/hero-mark-2
initial work on palette selection + load palette from save
This commit is contained in:
parent
dc8408c646
commit
923b638cca
5 changed files with 163 additions and 0 deletions
|
@ -81,6 +81,8 @@ class SaveFile:
|
||||||
var levels: Dictionary
|
var levels: Dictionary
|
||||||
# whether is debug save
|
# whether is debug save
|
||||||
var debug: bool = false
|
var debug: bool = false
|
||||||
|
# palette the save file is using
|
||||||
|
var palette: String = "default"
|
||||||
|
|
||||||
func _init(path: String, debug_save: bool = false) -> void:
|
func _init(path: String, debug_save: bool = false) -> void:
|
||||||
debug = debug_save
|
debug = debug_save
|
||||||
|
@ -125,6 +127,7 @@ class SaveFile:
|
||||||
difficulty = file.get_value("options", "difficulty", Game.Difficulty.SPICY)
|
difficulty = file.get_value("options", "difficulty", Game.Difficulty.SPICY)
|
||||||
# load playtime
|
# load playtime
|
||||||
play_time = file.get_value("options", "play_time", 0.0)
|
play_time = file.get_value("options", "play_time", 0.0)
|
||||||
|
palette = file.get_value("options", "palette", "default")
|
||||||
# TODO: load bought palettes
|
# TODO: load bought palettes
|
||||||
# TODO: load selected palette
|
# TODO: load selected palette
|
||||||
# load level save data
|
# load level save data
|
||||||
|
@ -141,6 +144,7 @@ class SaveFile:
|
||||||
file.set_value("options", "difficulty", difficulty)
|
file.set_value("options", "difficulty", difficulty)
|
||||||
# save playtime
|
# save playtime
|
||||||
file.set_value("options", "play_time", play_time)
|
file.set_value("options", "play_time", play_time)
|
||||||
|
file.set_value("options", "palette", palette)
|
||||||
# TODO: save bought palettes
|
# TODO: save bought palettes
|
||||||
# TODO: save selected palette
|
# TODO: save selected palette
|
||||||
# save level data
|
# save level data
|
||||||
|
|
|
@ -23,6 +23,7 @@ func select() -> void:
|
||||||
# set current file and difficulty
|
# set current file and difficulty
|
||||||
Save.current_file = file
|
Save.current_file = file
|
||||||
Game.difficulty = file.difficulty
|
Game.difficulty = file.difficulty
|
||||||
|
Game.current_palette = file.palette
|
||||||
# update last-played file for continue button
|
# update last-played file for continue button
|
||||||
Options.last_file = number
|
Options.last_file = number
|
||||||
Options.save_options()
|
Options.save_options()
|
||||||
|
@ -59,6 +60,8 @@ func refresh():
|
||||||
$"%DeathCounter".text = "%04d" % file.get_total_deaths()
|
$"%DeathCounter".text = "%04d" % file.get_total_deaths()
|
||||||
$"%TimeCounter".text = "%02d:%02d" % [file.play_time / 3600.0, fmod(file.play_time / 60.0, 60.0)]
|
$"%TimeCounter".text = "%02d:%02d" % [file.play_time / 3600.0, fmod(file.play_time / 60.0, 60.0)]
|
||||||
$"%Difficulty".text = Game.DIFFICULTY_NAMES[file.difficulty]
|
$"%Difficulty".text = Game.DIFFICULTY_NAMES[file.difficulty]
|
||||||
|
var palette = load("res://graphics/player/palettes/%s.png" % file.palette)
|
||||||
|
$"%Palette".material.set_shader_param("palette", palette)
|
||||||
else:
|
else:
|
||||||
file = null
|
file = null
|
||||||
$FileExists.visible = false
|
$FileExists.visible = false
|
||||||
|
|
|
@ -62,6 +62,7 @@ margin_bottom = 57.0
|
||||||
text = "0000"
|
text = "0000"
|
||||||
|
|
||||||
[node name="Palette" type="TextureRect" parent="FileExists"]
|
[node name="Palette" type="TextureRect" parent="FileExists"]
|
||||||
|
unique_name_in_owner = true
|
||||||
material = SubResource( 1 )
|
material = SubResource( 1 )
|
||||||
margin_left = 8.0
|
margin_left = 8.0
|
||||||
margin_top = 16.0
|
margin_top = 16.0
|
||||||
|
|
32
menus/palette_select.gd
Normal file
32
menus/palette_select.gd
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
export (Array, String) var titles: Array
|
||||||
|
export (Array, Texture) var palettes: Array
|
||||||
|
export var previous_screen: PackedScene
|
||||||
|
|
||||||
|
|
||||||
|
var current_palette: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
onready var sg: TextureRect = $SG
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
assert(titles.size() == palettes.size(), "titles and palettes arrays are not same size")
|
||||||
|
sg.material.set_shader_param("palette", palettes[current_palette])
|
||||||
|
$"%PaletteTitle".text = titles[current_palette]
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("ui_cancel"):
|
||||||
|
SceneManager.current_scene = previous_screen.instance()
|
||||||
|
return
|
||||||
|
elif event.is_action_pressed("ui_left"):
|
||||||
|
current_palette -= 1
|
||||||
|
elif event.is_action_pressed("ui_right"):
|
||||||
|
current_palette += 1
|
||||||
|
|
||||||
|
current_palette = posmod(current_palette, palettes.size())
|
||||||
|
sg.material.set_shader_param("palette", palettes[current_palette])
|
||||||
|
$"%PaletteTitle".text = titles[current_palette]
|
123
menus/palette_select.tscn
Normal file
123
menus/palette_select.tscn
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
[gd_scene load_steps=19 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://shaders/ska_plane.gdshader" type="Shader" id=1]
|
||||||
|
[ext_resource path="res://ui/theme.tres" type="Theme" id=2]
|
||||||
|
[ext_resource path="res://menus/palette_select.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://shaders/recolor_border.shader" type="Shader" id=4]
|
||||||
|
[ext_resource path="res://ui/2ndpuberty_scholar_outline.fnt" type="BitmapFont" id=5]
|
||||||
|
[ext_resource path="res://ui/2ndpuberty_outline.tres" type="Material" id=6]
|
||||||
|
[ext_resource path="res://graphics/player/palettes/default.png" type="Texture" id=7]
|
||||||
|
[ext_resource path="res://shaders/wibble_wobble.gdshader" type="Shader" id=8]
|
||||||
|
[ext_resource path="res://graphics/hud/pause_arrow.png" type="Texture" id=9]
|
||||||
|
[ext_resource path="res://graphics/player/sg_idle.png" type="Texture" id=10]
|
||||||
|
[ext_resource path="res://graphics/player/palettes/msx.png" type="Texture" id=11]
|
||||||
|
[ext_resource path="res://graphics/player/palettes/lasertag.png" type="Texture" id=12]
|
||||||
|
[ext_resource path="res://graphics/player/palettes/strawberry.png" type="Texture" id=13]
|
||||||
|
[ext_resource path="res://graphics/player/palettes/db32.png" type="Texture" id=14]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id=1]
|
||||||
|
shader = ExtResource( 1 )
|
||||||
|
shader_param/color_1 = Color( 0.717647, 0.717647, 0.717647, 1 )
|
||||||
|
shader_param/color_2 = Color( 0.360784, 0.360784, 0.360784, 1 )
|
||||||
|
shader_param/checker_size = Vector2( 16, 16 )
|
||||||
|
shader_param/pan_speed = Vector2( 0, 0 )
|
||||||
|
shader_param/cycle_speed = Vector2( 8, 8 )
|
||||||
|
shader_param/cycle_alternation = Vector2( 0, 1 )
|
||||||
|
shader_param/uv_transform = Transform2D( 0.5, -0.5, 0.5, 1, 0, 0 )
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id=2]
|
||||||
|
shader = ExtResource( 4 )
|
||||||
|
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||||
|
shader_param/border_corners = false
|
||||||
|
shader_param/palette = ExtResource( 7 )
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id=3]
|
||||||
|
shader = ExtResource( 8 )
|
||||||
|
shader_param/speed = Vector2( 4, 0 )
|
||||||
|
shader_param/ammount = Vector2( 2, 0 )
|
||||||
|
shader_param/offset = Vector2( 0, 0 )
|
||||||
|
shader_param/delay = Vector2( 0, 0 )
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id=4]
|
||||||
|
shader = ExtResource( 8 )
|
||||||
|
shader_param/speed = Vector2( 4, 0 )
|
||||||
|
shader_param/ammount = Vector2( 2, 0 )
|
||||||
|
shader_param/offset = Vector2( 0, 0 )
|
||||||
|
shader_param/delay = Vector2( 4, 0 )
|
||||||
|
|
||||||
|
[node name="PaletteSelect" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
theme = ExtResource( 2 )
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
titles = [ "Default", "Dawnbringer", "Lasertag", "Ms. X", "Strawberry" ]
|
||||||
|
palettes = [ ExtResource( 7 ), ExtResource( 14 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 13 ) ]
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
material = SubResource( 1 )
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
margin_bottom = 16.0
|
||||||
|
custom_fonts/font = ExtResource( 5 )
|
||||||
|
text = "Choose your colors"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="SG" type="TextureRect" parent="."]
|
||||||
|
material = SubResource( 2 )
|
||||||
|
margin_left = 101.0
|
||||||
|
margin_top = 112.0
|
||||||
|
margin_right = 121.0
|
||||||
|
margin_bottom = 132.0
|
||||||
|
rect_scale = Vector2( 2, 2 )
|
||||||
|
texture = ExtResource( 10 )
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
|
margin_left = 57.0
|
||||||
|
margin_top = 63.0
|
||||||
|
margin_right = 200.0
|
||||||
|
margin_bottom = 98.0
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer"]
|
||||||
|
margin_left = 3.0
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 140.0
|
||||||
|
margin_bottom = 32.0
|
||||||
|
theme = ExtResource( 2 )
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="BackArrow" type="TextureRect" parent="PanelContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
material = SubResource( 3 )
|
||||||
|
margin_left = 34.0
|
||||||
|
margin_top = 10.0
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 18.0
|
||||||
|
size_flags_vertical = 4
|
||||||
|
texture = ExtResource( 9 )
|
||||||
|
flip_h = true
|
||||||
|
|
||||||
|
[node name="PaletteTitle" type="Label" parent="PanelContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
material = ExtResource( 6 )
|
||||||
|
margin_left = 44.0
|
||||||
|
margin_top = 9.0
|
||||||
|
margin_right = 93.0
|
||||||
|
margin_bottom = 19.0
|
||||||
|
theme = ExtResource( 2 )
|
||||||
|
text = "Default"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="ForwardArrow" type="TextureRect" parent="PanelContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
material = SubResource( 4 )
|
||||||
|
margin_left = 97.0
|
||||||
|
margin_top = 10.0
|
||||||
|
margin_right = 103.0
|
||||||
|
margin_bottom = 18.0
|
||||||
|
size_flags_vertical = 4
|
||||||
|
texture = ExtResource( 9 )
|
Loading…
Add table
Add a link
Reference in a new issue