Old 02-17-2016, 10:59 AM   #1
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 851
Default BR_GetCurrentTheme() function : how to use it ?

Lua attempt : the following code works...
Code:
function gTheme()
local lThemePath = reaper.GetLastColorThemeFile()
reaper.ShowConsoleMsg("Theme info :".."\n"..lThemePath)
end

gTheme()
I get this, which is what was expected :

Theme info :
F:\Reaper5_Portable\ColorThemes\EyssinaFM.ReaperTh eme



The following code doesn't...
Code:
function gTheme()
local lThemePath, lThemeName = reaper.BR_GetCurrentTheme()
reaper.ShowConsoleMsg("Theme info :".."\n"..lThemePath.."\n"..lThemeName)
end

gTheme()
I just get this :

Theme info :


The problem is that I want only the name of the current theme, without path or extension, which is exactly what the BR_GetCurrentTheme function is supposed to provide, as a second return string. The 'ReaScript documentation' states this :

Lua: string themePathOut retval, string themeNameOut reaper.BR_GetCurrentTheme()
...
[BR] Get current theme information. themePathOut is set to full theme path and themeNameOut is set to theme name excluding any path info and extension


So :
1) What am I doing wrong ?
2) What does 'retval' means, actually ?
3) Additionaly, is there any actual examples of using this kind of functions somewhere as, even using this documentation, I'm not still sure about how to use the parameters call (again, the 'retval' one...) ?

Thanks for any help...


EDIT : I have the SWS extensions 2.8.3 installed and working, just in case...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...

Last edited by cubic13; 02-20-2016 at 02:11 AM.
cubic13 is offline   Reply With Quote
Old 02-20-2016, 03:21 AM   #2
cubic13
Human being with feelings
 
cubic13's Avatar
 
Join Date: Dec 2013
Location: Near Serre-Ponçon lake, french Alps
Posts: 851
Default

A little bump...

I really need this one to work, so, if any lua guru could test the two pieces of code above and give me hints about what's happening...
__________________
DAW: Ryzen 3700X|Asus X-470Pro|32Gb|2 SSD512(M2)+1024|W10Pro(64)|RME Fireface UCX+ADA8200
Soft: Reaper|Cubase 10|Emulator X3 & several other VSTis (2 bridged)...
Gear: VMK-188+|MPD32|ME30P|Korg 05R/W|Roland D110|Yamaha TX802|Pre-MIDI stuff...
cubic13 is offline   Reply With Quote
Old 12-17-2019, 12:34 PM   #3
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 2,670
Default

reaper.BR_GetCurrentTheme still not working (SWS v2.11.0.0 pre-release 2019-12-07).

Do you guys just read the REAPER.INI (lastthemefn5=) to get this info?

EDIT Never mind, reading the ini did the trick, reason I needed it was so when I start REAPER the theme is set depending on time of day it is, used in my "__startup.lua" on Win10, ...

Code:
function GetFilename(filepath)
  local lastpos = (filepath:reverse()):find('\\')
  return (filepath:sub(-lastpos+1))
end

-- Set theme depending on hour of the day.
function SetTheme() 
  local fn = reaper.GetResourcePath()
  local _, curTheme = reaper.BR_Win32_GetPrivateProfileString('REAPER', 'lastthemefn5', '', fn .. '/REAPER.ini')
  
  local tm = (os.time())
  if tonumber(os.date("%H", tm)) < 17 then  -- Before 5pm use light theme
    fn = fn .."\\ColorThemes\\Eds_5.01_AGYR.ReaperThemeZip"
  else  -- after 5pm use dark theme
    fn = fn .."\\ColorThemes\\Eds_6.0.ReaperThemeZip" 
  end  
  -- load theme if not the current theme
  if GetFilename(curTheme) ~= GetFilename(fn) then
    reaper.OpenColorThemeFile(fn)
  end
end

Last edited by Edgemeal; 12-17-2019 at 01:14 PM.
Edgemeal is offline   Reply With Quote
Old 12-17-2019, 04:06 PM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 3,795
Default

BR_GetCurrentTheme reads the lastthemefn4 ini key (and removes the file extension). Looks like it was changed to lastthemefn5 for REAPER 5 and 6. Fixing!

EDIT: However that ini key does not exist unless the theme was changed at least once. It's better to use reaper.GetLastColorThemeFile instead (was added in 5.02).

Last edited by cfillion; 12-17-2019 at 04:16 PM.
cfillion is offline   Reply With Quote
Old 12-17-2019, 04:18 PM   #5
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 2,670
Default

Quote:
Originally Posted by cfillion View Post
BR_GetCurrentTheme reads the lastthemefn4 ini key (and removes the file extension). Looks like it was changed to lastthemefn5 for REAPER 5 and 6. Fixing!

EDIT: However that ini key does not exist unless the theme was changed at least once. It's better to use reaper.GetLastColorThemeFile instead (was added in 5.02).
THANKS! Not sure how I missed GetLastColorThemeFile, didn't even see it! Will give that a try.
Edgemeal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.