Skip to content

Commit

Permalink
Update smandrap_Search Tracks.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
smandrap authored Oct 17, 2023
1 parent 13d2a25 commit 246c58e
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions Tracks/smandrap_Search Tracks.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- @description Search Tracks
-- @author smandrap
-- @version 1.1
-- @version 1.1.1
-- @donation https://paypal.me/smandrap
-- @changelog
-- + Add basic send tooltip (maybe will improve)
Expand Down Expand Up @@ -41,25 +41,25 @@


local script_name = "Search Tracks"
local version = 1.1
local reaper = reaper
if not reaper.ImGui_GetVersion() then
local ok = reaper.MB('Install now?', 'ReaImGui Missing', 1)
if ok == 1 then reaper.ReaPack_BrowsePackages("ReaImGui API") end
return
end


--[[
local separator = (reaper.GetOS() == "Win32" or reaper.GetOS() == "Win64") and "\\" or "/"
local data_path = reaper.GetResourcePath()..separator..'Data'
local config_filename = 'smandrap_SearchTracks_cfg.ini'
local config_path = data_path..separator..config_filename

--]]
----------------------
-- DEFAULT SETTINGS
----------------------

local settings = {
version = '1.1.1',
uncollapse_selection = false,
show_in_tcp = true,
show_in_mcp = false,
Expand Down Expand Up @@ -112,7 +112,7 @@ local colorbox_flags = reaper.ImGui_ColorEditFlags_NoAlpha()

local was_dragging = false

local help_text = script_name..' v'..tostring(version)..'\n'..
local help_text = script_name..' v'..settings.version..'\n'..
[[- Cmd/Ctrl+F : focus search field
- Arrows/Tab: navigate
- Enter/Double Click on name: GO
Expand Down Expand Up @@ -225,6 +225,8 @@ local function DoActionOnTrack(track)
if settings.close_on_action then open = false end
end

-- Deprecated in v1.1.1
--[[
local function ReadSettingsFromConfigFile()
if not reaper.file_exists(config_path) then return end -- Use defaults if file not found
Expand Down Expand Up @@ -258,6 +260,22 @@ local function WriteSettingsToConfigFile()
io.close(file)
end
--]]

local function ReadSettingsFromExtState()
if not reaper.HasExtState('smandrap_SearchTracks', 'version') then return end

for k, v in pairs(settings) do
settings[k] = reaper.GetExtState('smandrap_SearchTracks', tostring(k)) == 'true' and true or false
end

end

local function WriteSettingsToExtState()
for k, v in pairs(settings) do
reaper.SetExtState('smandrap_SearchTracks', k, tostring(v), true)
end
end

----------------------
-- GUI FUNCS
Expand Down Expand Up @@ -503,12 +521,12 @@ local function init()
reaper.ImGui_Attach(ctx, tooltip_font)
reaper.ImGui_SetConfigVar(ctx, reaper.ImGui_ConfigVar_MouseDoubleClickTime(), 0.2)

ReadSettingsFromConfigFile()
ReadSettingsFromExtState()
UpdateAllData()
end

local function exit()
WriteSettingsToConfigFile()
WriteSettingsToExtState()
end


Expand Down

0 comments on commit 246c58e

Please sign in to comment.