Skip to content

Commit

Permalink
framerate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 31, 2024
1 parent 4fdfa26 commit 5fbec47
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Autoload/Columnset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func export_toml_columnset(filePath, fullExport): #"res://columnset.toml"
if fullExport == false:
column_diffs = find_all_different_columns()
if column_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved. Did you mean to enable 'Full'?")
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return

var textFile = File.new()
Expand Down
5 changes: 3 additions & 2 deletions Autoload/Settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ func game_setting(doWhat,string,value):
if doWhat == SET: OS.vsync_enabled = value
if doWhat == GET: return OS.vsync_enabled
"framerate_limit":
if doWhat == SET: Engine.target_fps = value
if doWhat == GET: return Engine.target_fps
var oEditor = $'../Main/Editor'
if doWhat == SET: oEditor.framerate_limit = value
if doWhat == GET: return oEditor.framerate_limit
"always_decompress":
var oOpenMap = $'../Main/OpenMap'
if doWhat == SET: oOpenMap.ALWAYS_DECOMPRESS = value
Expand Down
2 changes: 1 addition & 1 deletion Autoload/Slabset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func export_toml_slabset(filePath, fullExport): #"res://slabset.toml"
dat_diffs = find_all_dat_differences()
tng_diffs = find_all_tng_differences()
if tng_diffs.size() == 0 and dat_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved. Did you mean to enable 'Full'?")
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return

# Print differences for debugging
Expand Down
2 changes: 1 addition & 1 deletion Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func fetch_id_string(thing_type, sub_type):
return nameId[0].capitalize()
return "Error1337"
else:
return "Unknown " + data_structure_name[thing_type] + ": " + str(sub_type)
return "Unknown " + data_structure_name.get(thing_type, "Unknown") + ": " + str(sub_type)


var data_structure_name = {
Expand Down
13 changes: 9 additions & 4 deletions Scenes/Editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum {
var currentView = VIEW_2D
var fieldBoundary = Rect2()
var mapHasBeenEdited = false setget set_map_has_been_edited
var framerate_limit = 120 setget set_framerate_limit

func set_map_has_been_edited(setVal):
if int(setVal) == oEditor.SET_EDITED_WITHOUT_SAVING_STATE: #If you save, then click Undo, it should mark as not saved but not create a new undo state when marking as edited.
Expand Down Expand Up @@ -71,10 +72,10 @@ func _notification(what):
Utils.popup_centered(oConfirmSaveBeforeQuit)
else:
get_tree().quit()
# elif what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
# Engine.target_fps = 0
# elif what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
# Engine.target_fps = 12
elif what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
Engine.target_fps = framerate_limit
elif what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
Engine.target_fps = min(12, framerate_limit)

func just_opened_editor():
yield(get_tree(),'idle_frame')
Expand Down Expand Up @@ -103,3 +104,7 @@ func update_boundaries():
fieldBoundary = Rect2(Vector2(1,1), Vector2(M.xSize-2,M.ySize-2)) # Position, Size
if oEditableBordersCheckbox.pressed == true:
fieldBoundary = Rect2(Vector2(0,0), Vector2(M.xSize,M.ySize))

func set_framerate_limit(val):
Engine.target_fps = val
framerate_limit = val

0 comments on commit 5fbec47

Please sign in to comment.