Skip to content

Commit

Permalink
Merge pull request #384 from db0/fix_rng_images
Browse files Browse the repository at this point in the history
fix: RNG images not appearing
  • Loading branch information
db0 authored Jul 17, 2022
2 parents 155e82a + 5e51cfd commit 7c30db1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,11 @@ config/description="Therapy through nightmares"
run/main_scene="res://src/dreamscape/MainMenu/MainMenu.tscn"
config/icon="res://icon.png"

[audio]

output_latency=60
output_latency.web=600

[autoload]

cfc="*res://src/core/CFControl.gd"
Expand All @@ -1070,6 +1075,7 @@ enabled=PoolStringArray( "res://addons/gut/plugin.cfg", "res://addons/sound_mana
[global]

import=false
buffer=false

[importer_defaults]

Expand Down
7 changes: 5 additions & 2 deletions src/core/CFUtils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static func list_files_in_directory(path: String, prepend_needed := "", full_pat
# Due to the way Godot exports work, we cannot look for image
# Files. Instead we have to explicitly look for their .import
# filenames, and grab the filename from there.
static func list_imported_in_directory(path: String) -> Array:
static func list_imported_in_directory(path: String, full_path := false) -> Array:
var files := []
var dir := Directory.new()
# warning-ignore:return_value_discarded
Expand All @@ -114,7 +114,10 @@ static func list_imported_in_directory(path: String) -> Array:
if file == "":
break
elif file.ends_with(".import"):
files.append(file.rstrip(".import"))
if full_path:
files.append(path + file.rstrip(".import"))
else:
files.append(file.rstrip(".import"))
dir.list_dir_end()
return(files)

Expand Down
2 changes: 1 addition & 1 deletion src/dreamscape/CardBack.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ func _prepare_back_from_texture(true_random := false) -> void:
card_texture.texture = CFUtils.convert_texture_to_image(globals.encounters.card_back_texture, true)

static func get_random_card_back() -> String:
var all_options = CFUtils.list_files_in_directory("res://assets/card_backs/random/", '', true)
var all_options = CFUtils.list_imported_in_directory("res://assets/card_backs/random/", true)
CFUtils.shuffle_array(all_options, true)
return(all_options[0])

2 changes: 1 addition & 1 deletion src/dreamscape/cards/sets/ImageLibrary.gd
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ const BETA_IMAGES := {
}

static func get_multiple_art_option(card_name: String) -> String:
var all_options = CFUtils.list_files_in_directory("res://assets/cards/%s/" % [card_name], '', true)
var all_options = CFUtils.list_imported_in_directory("res://assets/cards/%s/" % [card_name], true)
CFUtils.shuffle_array(all_options, true)
return(all_options[0])

0 comments on commit 7c30db1

Please sign in to comment.