volume setting
This commit is contained in:
parent
ef5325bbf2
commit
be3e13794e
|
@ -8,13 +8,16 @@ module Funfriend::ConfigMan
|
|||
|
||||
CONFIG_NAME = "cfg.ini"
|
||||
|
||||
alias ConfigValue = String | Int32 | Bool
|
||||
alias ConfigValue = String | Int32 | Bool | Float64
|
||||
alias ConfigSection = Hash(String, ConfigValue)
|
||||
alias Config = Hash(String, ConfigSection)
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"window" => {
|
||||
"funfriend_size" => 64.as(ConfigValue)
|
||||
},
|
||||
"sound" => {
|
||||
"volume" => 0.2.as(ConfigValue)
|
||||
}
|
||||
}.as(Config)
|
||||
|
||||
|
@ -59,8 +62,9 @@ module Funfriend::ConfigMan
|
|||
when String
|
||||
value
|
||||
when Int32
|
||||
puts "huh"
|
||||
value.to_i32?
|
||||
when Float64
|
||||
value.to_f64?
|
||||
when Bool
|
||||
value === "1" || value.downcase === "true"
|
||||
end
|
||||
|
@ -70,9 +74,13 @@ module Funfriend::ConfigMan
|
|||
# write to config
|
||||
@@config[sect_i][key] = casted_val.not_nil!
|
||||
end
|
||||
else
|
||||
# keep as a string just incase it's ever needed
|
||||
@@config[sect_i][key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
File.write(config_file, INI.build(@@config))
|
||||
end
|
||||
|
||||
@@config_initialized = true
|
||||
|
|
|
@ -20,6 +20,6 @@ module Funfriend::SoundMan
|
|||
SDL::Mix.init(SDL::Mix::Init::OGG); at_exit { SDL::Mix.quit }
|
||||
SDL::Mix.open
|
||||
|
||||
SDL::Mix::Channel.volume = SDL::Mix::MAX_VOLUME // 5
|
||||
SDL::Mix::Channel.volume = SDL::Mix::MAX_VOLUME * ConfigMan.config["sound"]["volume"].as(Float64)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue