Skip to content

Commit

Permalink
New feature and settings.
Browse files Browse the repository at this point in the history
- Added a feature that allows one to add games by specifying the name,
path to the executable, tags (optional), and a Steam AppID to use to
download a banner (optional). The menu can be opened via the "Add game"
custom skin action.
- New settings:
- ToolbarLogoTint
- AddGameButtonColor
- AddGameButtonBackgroundColor
  • Loading branch information
Kapiainen committed May 1, 2015
1 parent 456e37f commit 57d73c2
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 30 deletions.
11 changes: 10 additions & 1 deletion Lauhdutin/@Resources/UserSettings.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,20 @@ ScrollMultiplier=1
;Color and opacity of background (red, green, blue, opacity).
BackgroundColor=0,0,0,128

;Color and opacity of the toolbar icons (red, green, blue, opacity).
ToolbarLogoTint=255,255,255,255

;Color and opacity of toolbar background (red, green, blue, opacity).
ToolbarBackgroundColor=0,0,0,191

;Color of the text on buttons in the menu where games can be added.
AddGameButtonColor=0,0,0,255

;Color of the background of buttons in the menu where games can be added.
AddGameButtonBackgroundColor=127,127,127,255

;The interval between checks for new games. Unit is seconds. -1 = only check upon the skin being initialized/refreshed.
RefreshInterval=-1

;Hide status messages
HideMessages=0
HideMessages=0
122 changes: 99 additions & 23 deletions Lauhdutin/Lauhdutin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function Initialize()
-- Folder paths to resources
S_PATH_DOWNLOADS = SKIN:MakePathAbsolute("DownloadFile\\")
S_PATH_RESOURCES = SKIN:GetVariable('@')

-- State variables
N_SORT_STATE = 1 -- 0 = alphabetically, 1 = most recently played
B_FORCE_SHOW_TOOLBAR = false
Expand Down Expand Up @@ -107,7 +107,7 @@ end
local tResult = {}
if abOld then
tResult[S_USER_SETTING_KEY_WIDTH] = SKIN:GetVariable('OldBannerWidth', nil)
tResult[S_USER_SETTING_KEY_HEIGHT] = SKIN:GetVariable('OldBannerHeight', nil)
tResult[S_USER_SETTING_KEY_HEIGHT] = SKIN:GetVariable('OldBannerHeight', nil)
tResult[S_USER_SETTING_KEY_SLOTS] = SKIN:GetVariable('OldSlotCount', nil)
tResult[S_USER_SETTING_KEY_ORIENTATION] = SKIN:GetVariable('OldOrientation', nil)
tResult[S_USER_SETTINGS_KEY_HIDE_MESSAGES] = SKIN:GetVariable('OldHideMessages', nil)
Expand Down Expand Up @@ -211,27 +211,29 @@ end
local tNonSteamGames = ParseVDFFile(S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES)
if tNonSteamGames ~= nil then
for sKey, sValue in pairs(tNonSteamGames) do
local tGame = {}
tGame[S_VDF_KEY_APPID] = sValue[S_VDF_KEY_APPID]
tGame[S_VDF_KEY_NAME] = sValue[S_VDF_KEY_NAME]
tGame[S_VDF_KEY_TAGS] = sValue[S_VDF_KEY_TAGS]
tGame[S_VDF_KEY_PATH] = sValue[S_VDF_KEY_PATH]
tGame[S_VDF_KEY_LAST_PLAYED] = sValue[S_VDF_KEY_LAST_PLAYED]
if tGame[S_VDF_KEY_LAST_PLAYED] == nil then
tGame[S_VDF_KEY_LAST_PLAYED] = '0'
end
if BannerExists(tGame[S_VDF_KEY_APPID]) == nil then
if tonumber(tGame[S_VDF_KEY_APPID]) ~= nil then
DisplayMessage('Missing banner#CRLF#' .. tGame[S_VDF_KEY_APPID] .. '#CRLF#for#CRLF#' .. tGame[S_VDF_KEY_NAME])
table.insert(T_LOGO_QUEUE, tGame[S_VDF_KEY_APPID])
table.insert(tGames, tGame)
if sValue[S_VDF_KEY_HIDDEN] ~= 'true' then
local tGame = {}
tGame[S_VDF_KEY_APPID] = sValue[S_VDF_KEY_APPID]
tGame[S_VDF_KEY_NAME] = sValue[S_VDF_KEY_NAME]
tGame[S_VDF_KEY_TAGS] = sValue[S_VDF_KEY_TAGS]
tGame[S_VDF_KEY_PATH] = sValue[S_VDF_KEY_PATH]
tGame[S_VDF_KEY_LAST_PLAYED] = sValue[S_VDF_KEY_LAST_PLAYED]
if tGame[S_VDF_KEY_LAST_PLAYED] == nil then
tGame[S_VDF_KEY_LAST_PLAYED] = '0'
end
if BannerExists(tGame[S_VDF_KEY_APPID]) == nil then
if tonumber(tGame[S_VDF_KEY_APPID]) ~= nil then
DisplayMessage('Missing banner#CRLF#' .. tGame[S_VDF_KEY_APPID] .. '#CRLF#for#CRLF#' .. tGame[S_VDF_KEY_NAME])
table.insert(T_LOGO_QUEUE, tGame[S_VDF_KEY_APPID])
table.insert(tGames, tGame)
else
DisplayMessage('Missing banner#CRLF#' .. tGame[S_VDF_KEY_APPID] .. '#CRLF#for#CRLF#' .. tGame[S_VDF_KEY_NAME])
end
else
DisplayMessage('Missing banner#CRLF#' .. tGame[S_VDF_KEY_APPID] .. '#CRLF#for#CRLF#' .. tGame[S_VDF_KEY_NAME])
table.insert(tGames, tGame)
end
else
table.insert(tGames, tGame)
tGame = nil
end
tGame = nil
end
tNonSteamGames = nil
end
Expand All @@ -249,7 +251,7 @@ end
table.insert(tSteamLibraryPaths, sLibraryPath)
end
end

-- Steam games and non-Steam games that have been added to the Steam library.
if S_PATH_STEAM ~= nil and S_PATH_STEAM ~= '' then
if S_STEAM_USER_DATA_ID == nil or S_STEAM_USER_DATA_ID == '' then
Expand Down Expand Up @@ -658,7 +660,7 @@ end
end
end
else

for i = 1, #atSelection do
if atSelection[i][asKey] ~= nil and string.find(atSelection[i][asKey]:lower(), asValue) then
table.insert(tFilteredGames, atSelection[i])
Expand Down Expand Up @@ -722,9 +724,20 @@ end
tExceptions[asAppID] = sName
SerializeTableAsVDFFile(tExceptions, (S_PATH_RESOURCES .. S_INCLUDE_FILE_EXCEPTIONS))
Update()
break
end
else
local tNonSteamGames = ParseVDFFile(S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES)
if tNonSteamGames ~= nil then
for sKey, Value in pairs(tNonSteamGames) do
if asAppID == Value[S_VDF_KEY_APPID] then
Value[S_VDF_KEY_HIDDEN] = 'true'
SerializeTableAsVDFFile(tNonSteamGames, (S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES))
Update()
end
end
end
end
break
end
end
end
Expand Down Expand Up @@ -898,3 +911,66 @@ end
function HideMessage()
SKIN:Bang('[!HideMeterGroup MessageOverlay][!Redraw]')
end

-- Adding games
function StartAddGame()
SKIN:Bang('[!SetOption "SkinFilterInput" "Y" "0"][!ShowMeterGroup "AddGameMenu"][!Redraw]')
end

function AddGame()
local sName = SKIN:GetVariable('AddGameName', nil)
if sName ~= nil and sName ~= '' then
local tNonSteamGames = ParseVDFFile(S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES)
if tNonSteamGames ~= nil then
local nIndex = 0
for sKey, Value in pairs(tNonSteamGames) do
if Value[S_VDF_KEY_NAME] == sName then
if Value[S_VDF_KEY_HIDDEN] == 'true' then
tNonSteamGames[sKey][S_VDF_KEY_HIDDEN] = 'false'
SerializeTableAsVDFFile(tNonSteamGames, (S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES))
Update()
end
nIndex = -1
break
else
nIndex = nIndex + 1
end
end
if nIndex >= 0 then
local sPath = SKIN:GetVariable('AddGamePath', nil)
if sPath ~= nil and sPath ~= '' then
local tGame = {}
local sAppID = SKIN:GetVariable('AddGameSteamAppID', nil)
if sAppID ~= nil and sAppID ~= '' then
tGame[S_VDF_KEY_APPID] = sAppID
else
tGame[S_VDF_KEY_APPID] = sName
end
tGame[S_VDF_KEY_NAME] = sName
tGame[S_VDF_KEY_PATH] = sPath

local sTags = SKIN:GetVariable('AddGameTags', nil)
if sTags ~= nil and sTags ~= '' then
local tTags = {}
for sTag in sTags:gmatch('([^;]+)') do
table.insert(tTags, sTag)
end
if #tTags > 0 then
tGame[S_VDF_KEY_TAGS] = tTags
end
end
tGame[S_VDF_KEY_LAST_PLAYED] = '0'
tNonSteamGames[tostring(nIndex)] = tGame
SerializeTableAsVDFFile(tNonSteamGames, (S_PATH_RESOURCES .. S_INCLUDE_FILE_NON_STEAM_GAMES))
Update()
end
end
StopAddGame()
return
end
end
end

function StopAddGame()
SKIN:Bang('[!HideMeterGroup "AddGameMenu"][!Redraw][!SetVariable "AddGameName" ""][!SetVariable "AddGamePath" ""][!SetVariable "AddGameSteamAppID" ""][!SetVariable "AddGameTags" ""][!UpdateMeterGroup "AddGameMenu"][!SetOption "SkinFilterInput" "Y" "#ToolbarHeight#"]')
end
109 changes: 108 additions & 1 deletion Lauhdutin/Main.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name=Lauhdutin
Author=Kapiainen
Information=A launcher for Steam and non-Steam games, movies, misc. software, etc.
Version=1.1.1
Version=1.2.0
License=MIT

[Rainmeter]
Expand All @@ -17,6 +17,8 @@ ContextTitle2=Steam shortcuts
ContextAction2=[notepad "#@#SteamShortcuts.inc"]
ContextTitle3=Exceptions
ContextAction3=[notepad "#@#Exceptions.inc"]
ContextTitle4=Add game
ContextAction4=[!CommandMeasure "LauncherScript" "StartAddGame()"]

[Variables]
@Include=#@#Variables.inc
Expand All @@ -26,6 +28,10 @@ ToolbarButtonWidth=(#CURRENTCONFIGWIDTH# / 3)
ToolbarHeight=40
MessageOverlayText=
LogoToDownload=
AddGameName=
AddGamePath=
AddGameSteamAppID=
AddGameTags=

;#### Measures ####
[LauncherScript]
Expand Down Expand Up @@ -66,6 +72,10 @@ FocusDismiss=1
DefaultValue=
Command1=[!CommandMeasure "LauncherScript" "Filter('$UserInput$')"][!CommandMeasure "LauncherScript" "ForceShowToolbar(false)"]
OnDismissAction=[!CommandMeasure "LauncherScript" "ForceShowToolbar(false)"]
Command2=[!SetVariable AddGameName "$UserInput$"][!UpdateMeterGroup "AddGameMenu"][!Redraw]
Command3=[!SetVariable AddGamePath "$UserInput$"][!UpdateMeterGroup "AddGameMenu"][!Redraw]
Command4=[!SetVariable AddGameSteamAppID "$UserInput$"][!UpdateMeterGroup "AddGameMenu"][!Redraw]
Command5=[!SetVariable AddGameTags "$UserInput$"][!UpdateMeterGroup "AddGameMenu"][!Redraw]

;#### Meters ####
@Include3=#@#Meters.inc
Expand Down Expand Up @@ -95,6 +105,100 @@ FontSize=16
FontColor=255,255,255,255
Group=MessageOverlay

[SkinAddGameOverlay]
Meter=Image
SolidColor=#ToolbarBackgroundColor#
X=0
Y=0
W=#BannerWidth#
H=#BannerHeight#
DynamicVariables=1
Hidden=1
LeftMouseUpAction=[]
Group=AddGameMenu

[SkinAddGameName]
Meter=String
Text=Name: #AddGameName#
StringAlign=LeftCenter
X=(#BannerWidth# / 20)
Y=(2 * #BannerHeight# / 7)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "SkinFilterInput" "ExecuteBatch 2"]
Group=AddGameMenu

[SkinAddGamePath]
Meter=String
Text=Path: #AddGamePath#
StringAlign=LeftCenter
X=(#BannerWidth# / 20)
Y=(3 * #BannerHeight# / 7)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "SkinFilterInput" "ExecuteBatch 3"]
Group=AddGameMenu

[SkinAddGameTags]
Meter=String
Text=Tags: #AddGameTags#
StringAlign=LeftCenter
X=(#BannerWidth# / 20)
Y=(4 * #BannerHeight# / 7)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "SkinFilterInput" "ExecuteBatch 5"]
Group=AddGameMenu

[SkinAddGameSteamAppID]
Meter=String
Text=Steam AppID: #AddGameSteamAppID#
StringAlign=LeftCenter
X=(#BannerWidth# / 20)
Y=(5 * #BannerHeight# / 7)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "SkinFilterInput" "ExecuteBatch 4"]
Group=AddGameMenu

[SkinAddSteamAddText]
Meter=String
Text=Add
StringAlign=CenterCenter
X=(#BannerWidth# / 3)
Y=(7 * #BannerHeight# / 8)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
LeftMouseUpAction=[!CommandMeasure "LauncherScript" "AddGame()"]
Group=AddGameMenu

[SkinAddSteamCancelText]
Meter=String
Text=Cancel
StringAlign=CenterCenter
X=(2 * #BannerWidth# / 3)
Y=(7 * #BannerHeight# / 8)
FontSize=(#BannerHeight# / 15)
FontColor=#AddGameButtonColor#
SolidColor=#AddGameButtonBackgroundColor#
Hidden=1
LeftMouseUpAction=[!CommandMeasure "LauncherScript" "StopAddGame()"]
Group=AddGameMenu

[SkinToolbarBackground]
Meter=Image
SolidColor=#ToolbarBackgroundColor#
Expand All @@ -115,6 +219,7 @@ X=0r
Y=0r
W=(#CURRENTCONFIGWIDTH# / 3)
H=#ToolbarHeight#
ImageTint=#ToolbarLogoTint#
DynamicVariables=1
PreserveAspectRatio=1
LeftMouseUpAction=[!CommandMeasure "LauncherScript" "ForceShowToolbar(true)"][!CommandMeasure "SkinFilterInput" "ExecuteBatch 1"]
Expand All @@ -129,6 +234,7 @@ X=0R
Y=0r
W=(#CURRENTCONFIGWIDTH# / 3)
H=#ToolbarHeight#
ImageTint=#ToolbarLogoTint#
DynamicVariables=1
PreserveAspectRatio=1
LeftMouseUpAction=[!CommandMeasure "LauncherScript" "SortGames()"]
Expand All @@ -142,6 +248,7 @@ X=0R
Y=0r
W=(#CURRENTCONFIGWIDTH# / 3)
H=#ToolbarHeight#
ImageTint=#ToolbarLogoTint#
DynamicVariables=1
PreserveAspectRatio=1
LeftMouseUpAction=[notepad "#@#UserSettings.inc"]
Expand Down
Loading

0 comments on commit 57d73c2

Please sign in to comment.