Skip to content

Commit

Permalink
Replace simple condition assignments with short-circuit evaluations
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyBars3k committed Jun 2, 2024
1 parent 6fcde93 commit e4a71bf
Showing 1 changed file with 23 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- @description MB_Buss Driver - Batch add or remove send(s) or receive(s) on selected track(s)
-- @author MonkeyBars
-- @version 2.6
-- @changelog Update rtk; Refactor globals; Visible Routing Settings button states not updating with saved values; Settings applied to wrong send (https://github.com/MonkeyBars3k/ReaScripts/issues/369)
-- @version 2.6.1
-- @changelog Replace simple condition assignments with short-circuit evaluations
-- @provides [main] .
-- [nomain] rtk.lua
-- [nomain] serpent.lua
Expand Down Expand Up @@ -1151,17 +1151,18 @@ end


function setRoutingSettingsValue(new_routing_settings_values, routing_setting_name, this_field_is_type_value, routing_setting_field, this_field_is_type_selected)
local new_form_field_value
local new_form_field_value

new_form_field_value = new_routing_settings_values[routing_setting_name]
new_form_field_value = new_routing_settings_values[routing_setting_name]

if this_field_is_type_value then
routing_setting_field:attr("value", new_form_field_value)
elseif this_field_is_type_selected then
routing_setting_field:select(new_form_field_value)
end
if this_field_is_type_value then
routing_setting_field:attr("value", new_form_field_value)

elseif this_field_is_type_selected then
routing_setting_field:select(new_form_field_value)
end

updateRoutingSettingsBtns()
updateRoutingSettingsBtns()
end


Expand Down Expand Up @@ -1328,20 +1329,8 @@ function getAudioDestChannelInfo(this_is_refresh)

src_selected_channel_count = getSrcSelectedChannelCount()
src_multichannel_is_selected = src_selected_channel_count > 2

if this_is_refresh then
target_tracks_channel_count_min = _constant.reaper_max_track_channels

else
target_tracks_channel_count_min = getTargetTracksLeastChannelCount()
end

if src_multichannel_is_selected then
multichannel_choices_count = target_tracks_channel_count_min - src_selected_channel_count + 1

else
multichannel_choices_count = target_tracks_channel_count_min - 1
end
target_tracks_channel_count_min = this_is_refresh and _constant.reaper_max_track_channels or getTargetTracksLeastChannelCount()
multichannel_choices_count = src_multichannel_is_selected and target_tracks_channel_count_min - src_selected_channel_count + 1 or target_tracks_channel_count_min - 1

return multichannel_choices_count, src_multichannel_is_selected, src_selected_channel_count, target_tracks_channel_count_min
end
Expand Down Expand Up @@ -1444,13 +1433,7 @@ function getAudioChannelChoiceDivider(src_selected_channel_count)
local this_is_stereo, divider

this_is_stereo = src_selected_channel_count == 2

if this_is_stereo then
divider = "/"

else
divider = "-"
end
divider = this_is_stereo and "/" or "-"

return divider
end
Expand Down Expand Up @@ -1525,32 +1508,26 @@ function populateRoutingSettingsFormValues(reset)
local new_routing_settings_values

if _state.routing.settings_objs then

if _state.routing.settings_objs.all_values and reset ~= "reset" then
new_routing_settings_values = _state.routing.settings_objs.all_values

else
new_routing_settings_values = _constant.default_routing_settings_values
end
new_routing_settings_values = (_state.routing.settings_objs.all_values and reset ~= "reset") and _state.routing.settings_objs.all_values or _constant.default_routing_settings_values

getSetRoutingSettingsValues("set", new_routing_settings_values)

if (reset == "reset") then
if reset == "reset" then
updateRoutingSettingsBtns(reset)
end
end
end


function updateRoutingSettingsBtns(reset)
local all_btn_img_filename_bases, this_btn, this_btn_value, new_btn_img_base_state
local all_btn_img_filename_bases, this_btn, this_btn_value, new_btn_img_base_state

all_btn_img_filename_bases = {
mute = "table_mute",
phase = "gen_phase",
mono_stereo = "gen_mono",
midi_velpan = "gen_midi"
}
all_btn_img_filename_bases = {
mute = "table_mute",
phase = "gen_phase",
mono_stereo = "gen_mono",
midi_velpan = "gen_midi"
}

for btn_name, btn_img_base in pairs(all_btn_img_filename_bases) do
this_btn = _state.routing.settings_objs[btn_name]
Expand Down

0 comments on commit e4a71bf

Please sign in to comment.