saving, loading, settings, kitchen sink update (sorry hede wan)#58
saving, loading, settings, kitchen sink update (sorry hede wan)#58
Conversation
*for volume (no saving yet)
now with 20% more fps! side effects include but are not limited to - rash, swelling, poison, death, Cerber.
global_settings.gd
Outdated
| emit_signal("on_os_window_mode_changed",DisplayServer.window_get_mode()) | ||
| _prev_win_mode = DisplayServer.window_get_mode() | ||
|
|
||
| func _linear_to_db(value: float) -> float: |
There was a problem hiding this comment.
This function already exists and is exposed in Godot's @globalscope
There was a problem hiding this comment.
godot function caused a horrible error
global_settings.gd
Outdated
| extends Node | ||
| #array[0] volume | ||
| #array[1] display | ||
| var settings_array: =[[1,1,1],[0]] |
There was a problem hiding this comment.
Settings need to be a dictionary like in the old system.
Making it an array unnecessarikly hides the meaning of each entry.
There was a problem hiding this comment.
fixed this in my new update
global_settings.gd
Outdated
| var settings_array: =[[1,1,1],[0]] | ||
| signal volume_change(Array) | ||
| signal window_mode_change(int) | ||
| const window_modes = [DisplayServer.WINDOW_MODE_WINDOWED,DisplayServer.WINDOW_MODE_FULLSCREEN,DisplayServer.WINDOW_MODE_MAXIMIZED]#,DisplayServer.WINDOW_FLAG_BORDERLESS] |
There was a problem hiding this comment.
this array is an unnecessary abstraction that hides the window mode names with "meaningless" numbers
There was a problem hiding this comment.
I can fix this in a few secs, not too bad
There was a problem hiding this comment.
done and fixed, I had just done it a dumb method
global_settings.gd
Outdated
| else: | ||
| return -45 + (value / 100) * 40 | ||
|
|
||
| func _on_window_mode_change(inx:int) -> void: |
There was a problem hiding this comment.
I am extremely confused by how you intended the signals and callbacks to work. They don't make much sense how they are right now. (Also, we haven't put _ in front of any callbacks until now. It's better to keep the consistent format)
This function needs to be changed to work with a dictionary.
There was a problem hiding this comment.
function has been fixed to use the old-new save system
There was a problem hiding this comment.
and I have fixed signals(by pretty much removing them)
global_settings.gd
Outdated
|
|
||
| func _ready() -> void: | ||
| _prev_win_mode = DisplayServer.window_get_mode() | ||
| connect("volume_change",Callable(self,"_on_volume_change")) |
There was a problem hiding this comment.
Callable is not necessary. You can just use stringnames instead of creating a new callable object.
There was a problem hiding this comment.
I didn't know this, this is nice to know
ui/files.gd
Outdated
| label.show() | ||
| texture_rect.hide() | ||
|
|
||
| var image_resource = load(ProjectSettings.globalize_path(file_path)) |
There was a problem hiding this comment.
The files exist in the resource folder so making the path absolute is unnessary.
[This next part is just an idea, not a direct change requuest]
We could also think about loading them only once instead of every time we display them. For that you can change the String array to a Texture2D array.
There was a problem hiding this comment.
I'll note this for later
| var game_root = get_tree().get_first_node_in_group("Game") | ||
| var level = game_root.generator_power | ||
| label.text = str(level,'%') | ||
| bar.value = bar.max_value * (float(level) / 100) |
There was a problem hiding this comment.
You can just set the min/max of the progress bar to the min/max of the power level.
That gets rid of the extra conversion.
There was a problem hiding this comment.
I'll need elaboration, I confuse
| var level = game_root.generator_power | ||
| label.text = str(level,'%') | ||
| bar.value = bar.max_value * (float(level) / 100) | ||
| game_root.connect("on_power_level_changed",Callable(self,"on_power_change")) |
There was a problem hiding this comment.
This script should not connect it's own signal to anything outside of it. If any script needs tpo connect to this signal, they should connect to it inside their own script.
There was a problem hiding this comment.
huh? its connecting to game root for when the power changes
ui/generator.gd
Outdated
| func on_power_change(level:int) -> void: | ||
| if level == 0: | ||
| label.text = str("OUT OF POWER!") | ||
| bar.value = bar.size.x * (float(0) / 100) |
There was a problem hiding this comment.
0 / 100 is still 0. Always. Making 0 a float also doesn't change that. Even if you multiply it by the x size of the bar, The result will be 0 in the end.
ui/main_menu/settings.gd
Outdated
| global_settings.connect("on_os_window_mode_changed",Callable(self,"_update_dropdown")) | ||
|
|
||
| func _on_slider_changed(value: float, id: int) -> void: | ||
| global_settings.emit_signal("volume_change",[id, value]) |
There was a problem hiding this comment.
Do not emmit signals of other scripts. This is a big nono.
There was a problem hiding this comment.
ok, time to rework literally everything in my settings 👍
now comes with 90% less confusing signals when you order now! and if you order within this window(null) you can get a FREE, 90% less signals
(loading description.....)
probably needs a rework, added loading screen for peetza caching
global_settings.gd
Outdated
| var settings: Dictionary = init_default_settings(); | ||
|
|
||
| const default_fps:= 60 | ||
| signal on_os_window_mode_changed(int) |
There was a problem hiding this comment.
@a-fan9823
I still don't quite get this. What would this signal be needed for?
|
I already have the save manager with the changes we decided in the last meeting. |
No description provided.