From 7b3f8b20909e05b56a7857355e6ad687653096bf Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 7 Jun 2010 23:24:19 -0500 Subject: [PATCH] Script cleanup, add aliases for SCREEN_* (_screen.w, etc, check alias.lua). [shakesoda] --- Themes/_fallback/Scripts/00 init.lua | 10 +- Themes/_fallback/Scripts/01 alias.lua | 17 +- Themes/_fallback/Scripts/01 compat.lua | 81 ++++--- Themes/_fallback/Scripts/02 Actor.lua | 16 +- Themes/_fallback/Scripts/02 ActorDef.lua | 108 +++++---- Themes/_fallback/Scripts/02 Branches.lua | 40 ++-- Themes/_fallback/Scripts/02 Colors.lua | 120 ++++++---- Themes/_fallback/Scripts/02 Debug.lua | 31 ++- Themes/_fallback/Scripts/02 Enum.lua | 26 +- Themes/_fallback/Scripts/02 HelpDisplay.lua | 12 +- Themes/_fallback/Scripts/02 Lyrics.lua | 42 ++-- Themes/_fallback/Scripts/02 OptionsMenu.lua | 42 ++-- Themes/_fallback/Scripts/02 Sound.lua | 7 +- Themes/_fallback/Scripts/02 Sprite.lua | 25 +- Themes/_fallback/Scripts/02 StageMods.lua | 8 +- Themes/_fallback/Scripts/02 Utilities.lua | 37 +-- .../_fallback/Scripts/03 CustomSpeedMods.lua | 226 +++++++++--------- Themes/_fallback/Scripts/03 DateTime.lua | 23 +- Themes/_fallback/Scripts/03 EnvUtils2.lua | 10 +- Themes/_fallback/Scripts/03 Gameplay.lua | 163 +++++++------ Themes/_fallback/Scripts/03 HSV.lua | 225 ++++++++--------- .../Scripts/03 ProductivityHelpers.lua | 81 ++++--- .../_fallback/Scripts/03 UserPreferences2.lua | 101 ++++---- Themes/_fallback/Scripts/04 FileUtils.lua | 10 +- .../Scripts/04 WidescreenHelpers.lua | 12 +- 25 files changed, 787 insertions(+), 686 deletions(-) diff --git a/Themes/_fallback/Scripts/00 init.lua b/Themes/_fallback/Scripts/00 init.lua index 11b1c00a9a..ea82a43458 100644 --- a/Themes/_fallback/Scripts/00 init.lua +++ b/Themes/_fallback/Scripts/00 init.lua @@ -17,11 +17,13 @@ PLAYER_2 = "PlayerNumber_P2" NUM_PLAYERS = #PlayerNumber function string:find_last( text ) - local LastPos = 0; + local LastPos = 0 while true do - local p = string.find( self, text, LastPos+1, true ); - if not p then return LastPos end - LastPos = p; + local p = string.find( self, text, LastPos+1, true ) + if not p then + return LastPos + end + LastPos = p end end diff --git a/Themes/_fallback/Scripts/01 alias.lua b/Themes/_fallback/Scripts/01 alias.lua index e8b1c33d8c..240872b7e9 100644 --- a/Themes/_fallback/Scripts/01 alias.lua +++ b/Themes/_fallback/Scripts/01 alias.lua @@ -6,9 +6,18 @@ wouldn't otherwise belong somewhere else. -- in fact, this probably belongs in Sprite.lua... function Sprite:cropto(w,h) - self:CropTo(w,h); -end; + self:CropTo(w,h) +end function Actor:SetSize(w,h) - self:setsize(w,h); -end; \ No newline at end of file + self:setsize(w,h) +end + +-- shorthand! this is tedious to type and makes things ugly so let's make it shorter. +-- screen.w, screen.h, etc. +local _screen = { + w = SCREEN_WIDTH, + h = SCREEN_HEIGHT, + cx = SCREEN_CENTER_X, + cy = SCREEN_CENTER_Y +} \ No newline at end of file diff --git a/Themes/_fallback/Scripts/01 compat.lua b/Themes/_fallback/Scripts/01 compat.lua index 4d3a6e0d5f..077e727616 100644 --- a/Themes/_fallback/Scripts/01 compat.lua +++ b/Themes/_fallback/Scripts/01 compat.lua @@ -5,77 +5,82 @@ Also, certain things are deprecated/removed from sm-ssc (and sometimes SM4 too). --[[ Actor ]] function Actor:hidden(bHide) - Warn("hidden is deprecated, use visible instead. (used on ".. self:GetName() ..")"); - self:visible(not bHide); -end; + Warn("hidden is deprecated, use visible instead. (used on ".. self:GetName() ..")") + self:visible(not bHide) +end --- for when horizalign and vertalign get killed: +-- for when horizalign and vertalign get killed by glenn: --[[ function Actor:horizalign(v) local values = { - left = 0; - center = 0.5; - right = 1; - }; - self:halign(values[v]); -end; + left = 0, + center = 0.5, + right = 1 + } + self:halign(values[v]) +end function Actor:vertalign(v) local values = { - top = 0; - middle = 0.5; - bottom = 1; - }; - self:valign(values[v]); -end; + top = 0, + middle = 0.5, + bottom = 1 + } + self:valign(values[v]) +end --]] --[[ ActorScroller: all of these got renamed, so alias the lowercase ones if things are going to look for them. ]] function ActorScroller:getsecondtodestination() - self:GetSecondsToDestination(); -end; + self:GetSecondsToDestination() +end function ActorScroller:setsecondsperitem(secs) - self:SetSecondsPerItem(secs); -end; + self:SetSecondsPerItem(secs) +end function ActorScroller:setnumsubdivisions(subs) - self:SetNumSubdivisions(subs); -end; + self:SetNumSubdivisions(subs) +end function ActorScroller:scrollthroughallitems() - self:ScrollThroughAllItems(); -end; + self:ScrollThroughAllItems() +end function ActorScroller:scrollwithpadding(fPadStart,fPadEnd) - self:ScrollWithPadding(fPadStart,fPadEnd); -end; + self:ScrollWithPadding(fPadStart,fPadEnd) +end function ActorScroller:setfastcatchup(bFastCatchup) - self:SetFastCatchup(bFastCatchup); -end; + self:SetFastCatchup(bFastCatchup) +end -- renaming various StepMania functions to sm-ssc ones: -if ScreenString then ScreenString = Screen.String; end; -if ScreenMetric then ScreenMetric = Screen.Metric; end; +if ScreenString then + ScreenString = Screen.String +end + +if ScreenMetric then + ScreenMetric = Screen.Metric +end -- SM4SVN r28330: "add IsFullCombo bindings" - Chris Danford -- Unfortunately we already bound FullComboOfScore(tns), meaning we're not -- going to go back and redefine bindings that match it. Alias them instead -- for any themes expecting to use them: function PlayerStageStats:IsFullComboW1() - return self:FullComboOfScore('TapNoteScore_W1'); -end; + return self:FullComboOfScore('TapNoteScore_W1') +end function PlayerStageStats:IsFullComboW2() - return self:FullComboOfScore('TapNoteScore_W2'); -end; + return self:FullComboOfScore('TapNoteScore_W2') +end function PlayerStageStats:IsFullComboW3() - return self:FullComboOfScore('TapNoteScore_W3'); -end; + return self:FullComboOfScore('TapNoteScore_W3') +end function PlayerStageStats:IsFullComboW4() - return self:FullComboOfScore('TapNoteScore_W4'); -end; \ No newline at end of file + return self:FullComboOfScore('TapNoteScore_W4') +end \ No newline at end of file diff --git a/Themes/_fallback/Scripts/02 Actor.lua b/Themes/_fallback/Scripts/02 Actor.lua index f9adbb1a3e..68e3decaa2 100644 --- a/Themes/_fallback/Scripts/02 Actor.lua +++ b/Themes/_fallback/Scripts/02 Actor.lua @@ -123,27 +123,27 @@ This function will stretch any background up to 640x480]] function Actor:scale_or_crop_background() --local bgAspectRatio = self:GetWidth() / self:GetHeight(); if self:GetWidth() <= 640 and self:GetHeight() <= 480 then - self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ); + self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) else - self:scaletocover( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ); + self:scaletocover( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) end end -- Testing function Actor:scale_or_crop_alternative() if self:GetWidth() and self:GetHeight() then - local fRatio = self:GetWidth() / self:GetHeight(); + local fRatio = self:GetWidth() / self:GetHeight() if fRatio == 4/3 then - self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ); + self:stretchto( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) else - self:scaletocover( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ); + self:scaletocover( 0,0,SCREEN_WIDTH,SCREEN_HEIGHT ) end end end function Actor:Center() - self:x(SCREEN_CENTER_X); - self:y(SCREEN_CENTER_Y); -end; + self:x(SCREEN_CENTER_X) + self:y(SCREEN_CENTER_Y) +end -- (c) 2006 Glenn Maynard -- All rights reserved. diff --git a/Themes/_fallback/Scripts/02 ActorDef.lua b/Themes/_fallback/Scripts/02 ActorDef.lua index c1f0b85d6e..bcc42d372b 100644 --- a/Themes/_fallback/Scripts/02 ActorDef.lua +++ b/Themes/_fallback/Scripts/02 ActorDef.lua @@ -1,42 +1,45 @@ -- Convert "@/path/file" to "/path/". local function DebugPathToRealPath( p ) if not p or p:sub( 1, 1 ) ~= "@" then - return nil; + return nil end - local Path = p:sub( 2 ); - local pos = Path:find_last( '/' ); - return string.sub( Path, 1, pos ); + local Path = p:sub( 2 ) + local pos = Path:find_last( '/' ) + return string.sub( Path, 1, pos ) end local function MergeTables( left, right ) local ret = { } for key, val in pairs(left) do - ret[key] = val; + ret[key] = val end for key, val in pairs(right) do if ret[key] then if type(val) == "function" and type(ret[key]) == "function" then - local f1 = ret[key]; + local f1 = ret[key] local f2 = val - val = function(...) f1(...); return f2(...) end + val = function(...) + f1(...) + return f2(...) + end else Warn( string.format( "%s\n\nOverriding \"%s\": %s with %s", - debug.traceback(), key, type(ret[key]), type(val)) ); + debug.traceback(), key, type(ret[key]), type(val)) ) end end - ret[key] = val; + ret[key] = val end - setmetatable( ret, getmetatable(left) ); + setmetatable( ret, getmetatable(left) ) return ret end DefMetatable = { __concat = function(left, right) - return MergeTables( left, right ); + return MergeTables( left, right ) end } @@ -50,11 +53,11 @@ setmetatable( Def, { -- given to Def. Fill in standard fields. return function(t) if not ActorUtil.IsRegisteredClass(Class) then - error( Class .. " is not a registered actor class", 2 ); + error( Class .. " is not a registered actor class", 2 ) end - t.Class = Class; - + t.Class = Class + local level = 2 if t._Level then level = t._Level + 1 @@ -62,30 +65,30 @@ setmetatable( Def, { local info = debug.getinfo(level,"Sl"); -- Source file of caller: - local Source = info.source; - t._Source = Source; + local Source = info.source + t._Source = Source t._Dir = DebugPathToRealPath( Source ) -- Line number of caller: - t._Line = info.currentline; + t._Line = info.currentline - setmetatable( t, DefMetatable ); - return t; + setmetatable( t, DefMetatable ) + return t end end, -}); +}) function ResolveRelativePath( path, level ) if path:sub(1,1) ~= "/" then -- "Working directory": local sDir = DebugPathToRealPath( debug.getinfo(level+1,"S").source ) - assert( sDir ); + assert( sDir ) path = sDir .. path end - path = ActorUtil.ResolvePath( path, level+1 ); + path = ActorUtil.ResolvePath( path, level+1 ) return path end @@ -94,21 +97,21 @@ function LoadActorFunc( path, level ) level = level or 1 if path == "" then - error( "Passing in a blank filename is a great way to eat up RAM. Good thing we warn you about this." ); - end; + error( "Passing in a blank filename is a great way to eat up RAM. Good thing we warn you about this." ) + end - local ResolvedPath = ResolveRelativePath( path, level+1 ); + local ResolvedPath = ResolveRelativePath( path, level+1 ) if not ResolvedPath then - error( path .. ": not found", level+1 ); + error( path .. ": not found", level+1 ) end path = ResolvedPath - local Type = ActorUtil.GetFileType( path ); - Trace( "Loading " .. path .. ", type " .. tostring(Type) ); + local Type = ActorUtil.GetFileType( path ) + Trace( "Loading " .. path .. ", type " .. tostring(Type) ) if Type == "FileType_Lua" then -- Load the file. - local chunk, errmsg = loadfile( path ); + local chunk, errmsg = loadfile( path ) if not chunk then error(errmsg) end return chunk end @@ -140,38 +143,38 @@ function LoadActorFunc( path, level ) return function() return Def.BGAnimation { _Level = level+1, - AniDir = path, + AniDir = path } end end - error( path .. ": unknown file type (" .. tostring(Type) .. ")", level+1 ); + error( path .. ": unknown file type (" .. tostring(Type) .. ")", level+1 ) end -- Load and create an actor template. function LoadActor( path, ... ) - local t = LoadActorFunc( path, 2 ); - assert(t); - return t(...); + local t = LoadActorFunc( path, 2 ) + assert(t) + return t(...) end function LoadActorWithParams( path, params, ... ) - local t = LoadActorFunc( path, 2 ); - assert(t); - return lua.RunWithThreadVariables( function(...) return t(...) end, params, ... ); + local t = LoadActorFunc( path, 2 ) + assert(t) + return lua.RunWithThreadVariables( function(...) return t(...) end, params, ... ) end function LoadFont(a, b) - local sSection = b and a or ""; - local sFile = b or a; + local sSection = b and a or "" + local sFile = b or a if (sFile == "" and sSection == "") or (sFile == nil and sSection == nil) then - sSection = "Common"; - sFile = "normal"; - end; - local sPath = THEME:GetPathF(sSection, sFile); + sSection = "Common" + sFile = "normal" + end + local sPath = THEME:GetPathF(sSection, sFile) return Def.BitmapText { - _Level = 2; - File = sPath; + _Level = 2, + File = sPath } end @@ -182,20 +185,23 @@ end function StandardDecorationFromTable( MetricsName, t ) if type(t) == "table" then t = t .. { - InitCommand=function(self) self:name(MetricsName); ActorUtil.LoadAllCommandsAndSetXY(self,Var "LoadingScreen"); end; - }; + InitCommand=function(self) + self:name(MetricsName) + ActorUtil.LoadAllCommandsAndSetXY(self,Var "LoadingScreen") + end + } end - return t; + return t end function StandardDecorationFromFile( MetricsName, FileName ) - local t = LoadActor( THEME:GetPathG(Var "LoadingScreen",FileName) ); - return StandardDecorationFromTable( MetricsName, t ); + local t = LoadActor( THEME:GetPathG(Var "LoadingScreen",FileName) ) + return StandardDecorationFromTable( MetricsName, t ) end function StandardDecorationFromFileOptional( MetricsName, FileName ) if ShowStandardDecoration(MetricsName) then - return StandardDecorationFromFile( MetricsName, FileName ); + return StandardDecorationFromFile( MetricsName, FileName ) end end diff --git a/Themes/_fallback/Scripts/02 Branches.lua b/Themes/_fallback/Scripts/02 Branches.lua index 54112f82ae..ca3a698e92 100644 --- a/Themes/_fallback/Scripts/02 Branches.lua +++ b/Themes/_fallback/Scripts/02 Branches.lua @@ -9,34 +9,38 @@ If the line is a function, you'll have to use Branch.keyname() instead. -- used for various SMOnline-enabled screens: function SMOnlineScreen() for pn in ivalues(GAMESTATE:GetHumanPlayers()) do - if not IsSMOnlineLoggedIn(pn) then return "ScreenSMOnlineLogin" end; - end; + if not IsSMOnlineLoggedIn(pn) then + return "ScreenSMOnlineLogin" + end + end return "ScreenNetRoom" -end; +end function SelectMusicOrCourse() if IsNetSMOnline() then return "ScreenNetSelectMusic"; elseif GAMESTATE:IsCourseMode() then - return "ScreenSelectCourse"; + return "ScreenSelectCourse" else - return "ScreenSelectMusic"; - end; -end; + return "ScreenSelectMusic" + end +end Branch = { TitleMenu = function() -- home mode is the most assumed use of sm-ssc. - if GAMESTATE:GetCoinMode() == "CoinMode_Home" then return "ScreenTitleMenu" end; + if GAMESTATE:GetCoinMode() == "CoinMode_Home" then + return "ScreenTitleMenu" + end -- arcade junk: if GAMESTATE:GetCoinsNeededToJoin() > GAMESTATE:GetCoins() then -- if no credits are inserted, don't show the Join screen. SM4 has -- this as the initial screen, but that means we'd be stuck in a -- loop with ScreenInit. No good. - return "ScreenDemonstration"; + return "ScreenDemonstration" else return "ScreenTitleJoin" - end; + end end, AfterProfileLoad = function() return "ScreenSelectProfile" @@ -58,8 +62,12 @@ Branch = { ReportStyle() GAMESTATE:ApplyGameCommand("playmode,regular") end - if IsNetSMOnline() then return SMOnlineScreen() end - if IsNetConnected() then return "ScreenNetRoom" end + if IsNetSMOnline() then + return SMOnlineScreen() + end + if IsNetConnected() then + return "ScreenNetRoom" + end return "ScreenSelectPlayMode" end, AfterSelectStyle = function() @@ -82,8 +90,8 @@ Branch = { end end, GetGameInformationScreen = function() - bTrue = PREFSMAN:GetPreference("ShowInstructions"); - return (bTrue and GoToMusic() or "ScreenGameInformation"); + bTrue = PREFSMAN:GetPreference("ShowInstructions") + return (bTrue and GoToMusic() or "ScreenGameInformation") end, AfterSMOLogin = SMOnlineScreen(), BackOutOfPlayerOptions = function() @@ -138,5 +146,5 @@ Branch = { QuickSetupB = "ScreenQuickSetupPhaseTwo", QuickSetupC = "ScreenQuickSetupPhaseThree", QuickSetupD = "ScreenQuickSetupPhaseFour", - QuickSetupFinished = "ScreenQuickSetupFinished", -}; \ No newline at end of file + QuickSetupFinished = "ScreenQuickSetupFinished" +} \ No newline at end of file diff --git a/Themes/_fallback/Scripts/02 Colors.lua b/Themes/_fallback/Scripts/02 Colors.lua index a1867788bf..fe1e16882d 100644 --- a/Themes/_fallback/Scripts/02 Colors.lua +++ b/Themes/_fallback/Scripts/02 Colors.lua @@ -1,5 +1,5 @@ -- SSC Color Module and Library -local nilColor = color("0,0,0,0"); +local nilColor = color("0,0,0,0") -- Original Color Module. Color = { -- UI Colors @@ -19,7 +19,7 @@ Color = { -- ( Do note that I want to remove '*Color' entirely, it'll look neater ) Player = { P1 = color("#ef403d"), - P2 = color("#0089cf"), + P2 = color("#0089cf") }, Difficulty = { --[[ These are for 'Custom' Difficulty Ranks. It can be very useful @@ -42,7 +42,7 @@ Color = { Difficulty_Challenge = color("0.2,0.6,1.0,1"), -- light blue Difficulty_Edit = color("0.8,0.8,0.8,1"), -- gray Difficulty_Couple = color("#ed0972"), -- hot pink - Difficulty_Routine = color("#ff9a00"), -- orange + Difficulty_Routine = color("#ff9a00") -- orange }, Course = { Beginner = color("0.0,0.9,1.0,1"), -- purple @@ -60,7 +60,7 @@ Color = { Difficulty_Easy = color("0.9,0.9,0.0,1"), -- green Difficulty_Medium = color("1.0,0.1,0.1,1"), -- yellow Difficulty_Hard = color("0.2,1.0,0.2,1"), -- red - Difficulty_Challenge = color("0.2,0.6,1.0,1"), -- light blue + Difficulty_Challenge = color("0.2,0.6,1.0,1") -- light blue }, CourseDifficultyColors = { Beginner = color("0.0,0.9,1.0,1"), -- purple @@ -78,7 +78,7 @@ Color = { Difficulty_Easy = color("0.9,0.9,0.0,1"), -- green Difficulty_Medium = color("1.0,0.1,0.1,1"), -- yellow Difficulty_Hard = color("0.2,1.0,0.2,1"), -- red - Difficulty_Challenge = color("0.2,0.6,1.0,1"), -- light blue + Difficulty_Challenge = color("0.2,0.6,1.0,1") -- light blue }, Stage = { Stage_1st = color("#00ffc7"), @@ -95,7 +95,7 @@ Color = { Stage_Oni = color("#FFFFFF"), Stage_Endless = color("#FFFFFF"), Stage_Event = color("#FFFFFF"), - Stage_Demo = color("#FFFFFF"), + Stage_Demo = color("#FFFFFF") }, Judgment = { JudgmentLine_W1 = color("#00ffc7"), @@ -105,7 +105,7 @@ Color = { JudgmentLine_W5 = color("#e44dff"), JudgmentLine_Held = color("#FFFFFF"), JudgmentLine_Miss = color("#ff3c3c"), - JudgmentLine_MaxCombo = color("#ffc600"), + JudgmentLine_MaxCombo = color("#ffc600") }, JudgmentLine = { JudgmentLine_W1 = color("#00ffc7"), @@ -115,7 +115,7 @@ Color = { JudgmentLine_W5 = color("#e44dff"), JudgmentLine_Held = color("#FFFFFF"), JudgmentLine_Miss = color("#ff3c3c"), - JudgmentLine_MaxCombo = color("#ffc600"), + JudgmentLine_MaxCombo = color("#ffc600") }, Grade = {}, Menu = {}, @@ -125,11 +125,11 @@ Color = { StreakW1 = nilColor, StreakW2 = nilColor, StreakW3 = nilColor, - Misses = nilColor, + Misses = nilColor }, Song = { Extra = nilColor, - Unlock = nilColor, + Unlock = nilColor }, -- Color Library -- These colors are pure swatch colors and are here purely to be used @@ -157,15 +157,16 @@ Color = { Alpha = function(cColor,fAlpha) local c = cColor; return { c[1],c[2],c[3],fAlpha }; - end, -}; + end +} + -- Remapped Color Module, since some themes are crazy -Colors = Color; +Colors = Color local PlayerColors = { PLAYER_1 = color("#ef403d"), - PLAYER_2 = color("#0089cf"), -}; + PLAYER_2 = color("#0089cf") +} local DifficultyColors = { --[[ These are for 'Custom' Difficulty Ranks. It can be very useful @@ -188,8 +189,9 @@ local DifficultyColors = { Difficulty_Challenge = color("#1cd8ff"), -- light blue Difficulty_Edit = color("0.8,0.8,0.8,1"), -- gray Difficulty_Couple = color("#ed0972"), -- hot pink - Difficulty_Routine = color("#ff9a00"), -- orange -}; + Difficulty_Routine = color("#ff9a00") -- orange +} + local StageColors = { Stage_1st = color("#00ffc7"), Stage_2nd = color("#58ff00"), @@ -205,8 +207,9 @@ local StageColors = { Stage_Oni = color("#FFFFFF"), Stage_Endless = color("#FFFFFF"), Stage_Event = color("#FFFFFF"), - Stage_Demo = color("#FFFFFF"), -}; + Stage_Demo = color("#FFFFFF") +} + local JudgmentColors = { JudgmentLine_W1 = color("#00ffc7"), JudgmentLine_W2 = color("#f6ff00"), @@ -215,77 +218,90 @@ local JudgmentColors = { JudgmentLine_W5 = color("#e44dff"), JudgmentLine_Held = color("#FFFFFF"), JudgmentLine_Miss = color("#ff3c3c"), - JudgmentLine_MaxCombo = color("#ffc600"), -}; + JudgmentLine_MaxCombo = color("#ffc600") +} + --[[ Fallbacks ]] function Color(c) - return Colors[c]; -end; + return Colors[c] +end function BoostColor( cColor, fBoost ) - local c = cColor; - return { c[1]*fBoost, c[2]*fBoost, c[3]*fBoost, c[4] }; -end; + local c = cColor + return { c[1]*fBoost, c[2]*fBoost, c[3]*fBoost, c[4] } +end function ColorLightTone(c) - return { c[1]+(c[1]/2), c[2]+(c[2]/2), c[3]+(c[3]/2), c[4] }; -end; + return { c[1]+(c[1]/2), c[2]+(c[2]/2), c[3]+(c[3]/2), c[4] } +end function ColorMidTone(c) - return { c[1]/1.5, c[2]/1.5, c[3]/1.5, c[4] }; -end; + return { c[1]/1.5, c[2]/1.5, c[3]/1.5, c[4] } +end function ColorDarkTone(c) - return { c[1]/2, c[2]/2, c[3]/2, c[4] }; -end; + return { c[1]/2, c[2]/2, c[3]/2, c[4] } +end function PlayerColor( pn ) - if pn == PLAYER_1 then return color("#ef403d") end -- pink-red - if pn == PLAYER_2 then return color("#0089cf") end -- sea-blue + if pn == PLAYER_1 then + return color("#ef403d") -- pink-red + end + if pn == PLAYER_2 then + return color("#0089cf") -- sea-blue + end return color("1,1,1,1") end function PlayerScoreColor( pn ) - if pn == PLAYER_1 then return color("#ef403d") end -- pink-red - if pn == PLAYER_2 then return color("#0089cf") end -- sea-blue + if pn == PLAYER_1 then + return color("#ef403d") -- pink-red + end + if pn == PLAYER_2 then + return color("#0089cf") -- sea-blue + end return color("1,1,1,1") end function CustomDifficultyToColor( sCustomDifficulty ) - return DifficultyColors[sCustomDifficulty]; + return DifficultyColors[sCustomDifficulty] end function CustomDifficultyToDarkColor( sCustomDifficulty ) - local c = DifficultyColors[sCustomDifficulty]; - return { c[1]/2, c[2]/2, c[3]/2, c[4] }; + local c = DifficultyColors[sCustomDifficulty] + return { c[1]/2, c[2]/2, c[3]/2, c[4] } end function CustomDifficultyToLightColor( sCustomDifficulty ) - local c = DifficultyColors[sCustomDifficulty]; - return { scale(c[1],0,1,0.5,1), scale(c[2],0,1,0.5,1), scale(c[3],0,1,0.5,1), c[4] }; + local c = DifficultyColors[sCustomDifficulty] + return { scale(c[1],0,1,0.5,1), scale(c[2],0,1,0.5,1), scale(c[3],0,1,0.5,1), c[4] } end function StepsOrTrailToColor(StepsOrTrail) - return CustomDifficultyToColor( StepsOrTrailToCustomDifficulty(stepsOrTrail) ); + return CustomDifficultyToColor( StepsOrTrailToCustomDifficulty(stepsOrTrail) ) end function StageToColor( stage ) - local c = Colors.Stage[stage]; - if c then return c end - return color("#000000"); + local c = Colors.Stage[stage] + if c then + return c + end + return color("#000000") end function StageToStrokeColor( stage ) - local c = StageColors[stage]; - return { c[1]/2, c[2]/2, c[3]/2, c[4] }; + local c = StageColors[stage] + return { c[1]/2, c[2]/2, c[3]/2, c[4] } end function JudgmentLineToColor( i ) - local c = JudgmentColors[i]; - if c then return c end - return color("#000000"); + local c = JudgmentColors[i] + if c then + return c + end + return color("#000000") end function JudgmentLineToStrokeColor( i ) - local c = JudgmentColors[i]; - return { c[1]/2, c[2]/2, c[3]/2, c[4] }; + local c = JudgmentColors[i] + return { c[1]/2, c[2]/2, c[3]/2, c[4] } end \ No newline at end of file diff --git a/Themes/_fallback/Scripts/02 Debug.lua b/Themes/_fallback/Scripts/02 Debug.lua index 925df271b7..97ff27ff75 100644 --- a/Themes/_fallback/Scripts/02 Debug.lua +++ b/Themes/_fallback/Scripts/02 Debug.lua @@ -10,11 +10,20 @@ function debug.traceback(...) local thread = coroutine.running() local msg = "" local level = 1 - local args = {...}; + local args = {...} - if type(args[1]) == "thread" then thread = args[1]; table.remove(args) end - if type(args[1]) == "string" then msg = args[1]; table.remove(args) end - if type(args[1]) == "number" then level = args[1]; table.remove(args) end + if type(args[1]) == "thread" then + thread = args[1] + table.remove(args) + end + if type(args[1]) == "string" then + msg = args[1] + table.remove(args) + end + if type(args[1]) == "number" then + level = args[1] + table.remove(args) + end if thread == coroutine.running() then level = level + 1 -- skip this function @@ -22,22 +31,22 @@ function debug.traceback(...) local stack = {} repeat - local info = debug.getinfo(level, "Sln"); - table.insert( stack, info ); + local info = debug.getinfo(level, "Sln") + table.insert( stack, info ) level = level + 1 until not info if #stack == 0 then - return ""; + return "" end -- The original caller is usually C; remove it. if( stack[#stack].what == "C" ) then - table.remove( stack ); + table.remove( stack ) end local function FormatFrame(level, frame) local sFrameInfo = "" - sFrameInfo = sFrameInfo .. "#" .. level .. " "; + sFrameInfo = sFrameInfo .. "#" .. level .. " " if( frame.what == "tail" ) then -- sFrameInfo = sFrameInfo .. "(tail call)" -- return sFrameInfo @@ -46,7 +55,7 @@ function debug.traceback(...) elseif frame.name then sFrameInfo = sFrameInfo .. frame.name .. "() in " else - sFrameInfo = sFrameInfo .. "... in "; + sFrameInfo = sFrameInfo .. "... in " end sFrameInfo = sFrameInfo .. frame.short_src @@ -61,7 +70,7 @@ function debug.traceback(...) for level, frame in ipairs(stack) do FrameInfo[level] = FormatFrame(level, frame) end - return table.concat( FrameInfo, "\n" ); + return table.concat( FrameInfo, "\n" ) end -- (c) 2006 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 Enum.lua b/Themes/_fallback/Scripts/02 Enum.lua index 316b7e001f..c277529d70 100644 --- a/Themes/_fallback/Scripts/02 Enum.lua +++ b/Themes/_fallback/Scripts/02 Enum.lua @@ -1,23 +1,29 @@ function Enum:Compare( e1, e2 ) - local Reverse = self:Reverse(); - local Value1 = Reverse[e1]; - local Value2 = Reverse[e2]; + local Reverse = self:Reverse() + local Value1 = Reverse[e1] + local Value2 = Reverse[e2] - assert( Value1, tostring(e1) .. " is not an enum of type " .. self:GetName() ); - assert( Value2, tostring(e2) .. " is not an enum of type " .. self:GetName() ); + assert( Value1, tostring(e1) .. " is not an enum of type " .. self:GetName() ) + assert( Value2, tostring(e2) .. " is not an enum of type " .. self:GetName() ) -- Nil enums correspond to "invalid". These compare greater -- than any valid enum value, to line up with the equivalent -- C++ code. - if not e1 then Value1 = 99999999 end; - if not e2 then Value2 = 99999999 end; - return Value1 - Value2; + + -- should this be changed to math.huge()? -shake + if not e1 then + Value1 = 99999999 + end + if not e2 then + Value2 = 99999999 + end + return Value1 - Value2 end function ToEnumShortString( e ) local pos = string.find( e, '_' ) - assert( pos, "'" .. e .. "' is not an enum value" ); - return string.sub( e, pos+1 ); + assert( pos, "'" .. e .. "' is not an enum value" ) + return string.sub( e, pos+1 ) end -- (c) 2006 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 HelpDisplay.lua b/Themes/_fallback/Scripts/02 HelpDisplay.lua index 58afd12a6c..d8ae376532 100644 --- a/Themes/_fallback/Scripts/02 HelpDisplay.lua +++ b/Themes/_fallback/Scripts/02 HelpDisplay.lua @@ -2,16 +2,16 @@ function HelpDisplay:setfromsongorcourse() local Artists = {} local AltArtists = {} - local Song = GAMESTATE:GetCurrentSong(); - local Trail = GAMESTATE:GetCurrentTrail( GAMESTATE:GetMasterPlayerNumber() ); + local Song = GAMESTATE:GetCurrentSong() + local Trail = GAMESTATE:GetCurrentTrail( GAMESTATE:GetMasterPlayerNumber() ) if Song then - table.insert( Artists, Song:GetDisplayArtist() ); - table.insert( AltArtists, Song:GetTranslitArtist() ); + table.insert( Artists, Song:GetDisplayArtist() ) + table.insert( AltArtists, Song:GetTranslitArtist() ) elseif Trail then - Artists, AltArtists = Trail:GetArtists(); + Artists, AltArtists = Trail:GetArtists() end - self:settips( Artists, AltArtists ); + self:settips( Artists, AltArtists ) end -- (c) 2006 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 Lyrics.lua b/Themes/_fallback/Scripts/02 Lyrics.lua index 8663e3f843..bf324299a7 100644 --- a/Themes/_fallback/Scripts/02 Lyrics.lua +++ b/Themes/_fallback/Scripts/02 Lyrics.lua @@ -1,16 +1,18 @@ function Actor:LyricCommand(side) - self:settext( Var "LyricText" ); + self:settext( Var "LyricText" ) - self:stoptweening(); - self:shadowlengthx(0); - self:shadowlengthy(5); - self:strokecolor(color("#000000")); + self:stoptweening() + self:shadowlengthx(0) + self:shadowlengthy(5) + self:strokecolor(color("#000000")) - local Zoom = SCREEN_WIDTH/(self:GetZoomedWidth()+1); - if( Zoom > 1 ) then Zoom = 1 end - self:zoomx( Zoom ); + local Zoom = SCREEN_WIDTH / (self:GetZoomedWidth()+1) + if( Zoom > 1 ) then + Zoom = 1 + end + self:zoomx( Zoom ) - local lyricColor = Var "LyricColor"; + local lyricColor = Var "LyricColor" local Factor = 1 if side == "Back" then Factor = 0.5 @@ -24,23 +26,23 @@ function Actor:LyricCommand(side) lyricColor[4] * Factor } ) if side == "Front" then - self:cropright(1); + self:cropright(1) else - self:cropleft(0); + self:cropleft(0) end - self:diffusealpha(0); - self:linear(0.2); - self:diffusealpha(0.75); - self:linear( Var "LyricDuration" * 0.75); + self:diffusealpha(0) + self:linear(0.2) + self:diffusealpha(0.75) + self:linear( Var "LyricDuration" * 0.75) if side == "Front" then - self:cropright(0); + self:cropright(0) else - self:cropleft(1); + self:cropleft(1) end - self:sleep( Var "LyricDuration" * 0.25 ); - self:linear(0.2); - self:diffusealpha(0); + self:sleep( Var "LyricDuration" * 0.25 ) + self:linear(0.2) + self:diffusealpha(0) end -- (c) 2006 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 OptionsMenu.lua b/Themes/_fallback/Scripts/02 OptionsMenu.lua index 82c64bacef..6fa59e9cce 100644 --- a/Themes/_fallback/Scripts/02 OptionsMenu.lua +++ b/Themes/_fallback/Scripts/02 OptionsMenu.lua @@ -31,8 +31,10 @@ function OptionsRowTest() -- Set list[1] to true if Option1 should be selected, and -- list[2] if Option2 should be selected. This will be -- called once per enabled player. - LoadSelections = (function(self,list,pn) list[1] = true; end), - SaveSelections = Set, + LoadSelections = function(self,list,pn) + list[1] = true + end, + SaveSelections = Set } end @@ -62,37 +64,35 @@ OptionRowTable = function OptionsRandomJukebox() local function AllChoices() - Trace('all choices'); - local ret = { } - ret[1] = 'Off'; - ret[2] = 'Random'; + Trace('all choices') + local ret = { 'Off', 'Random' } return ret end local t = { -- Name is used to retrieve the header and explanation text. - Name = "OptionsRandomJukebox"; - LayoutType = "ShowAllInRow"; - SelectType = "SelectOne"; - OneChoiceForAllPlayers = true; - ExportOnChange = false; - Choices = AllChoices(); + Name = "OptionsRandomJukebox", + LayoutType = "ShowAllInRow", + SelectType = "SelectOne", + OneChoiceForAllPlayers = true, + ExportOnChange = false, + Choices = AllChoices(), LoadSelections = function(self, list, pn) list[1] = true - end; + end, SaveSelections = function(self, list, pn) - local val; + local val if list[1] then - val = false; + val = false else - val = true; + val = true end - GAMESTATE:SetJukeboxUsesModifiers(val); - end; - }; - setmetatable( t, t ); - return t; + GAMESTATE:SetJukeboxUsesModifiers(val) + end + } + setmetatable( t, t ) + return t end -- (c) 2005 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 Sound.lua b/Themes/_fallback/Scripts/02 Sound.lua index 7ee60e4816..d685247882 100644 --- a/Themes/_fallback/Scripts/02 Sound.lua +++ b/Themes/_fallback/Scripts/02 Sound.lua @@ -1,9 +1,10 @@ +-- Can this be moved into some other file? Feels like clutter. -shake -- Play the sound on the given player's side. Must set SupportPan = true -- on load. function ActorSound:playforplayer(pn) - local fBalance = SOUND:GetPlayerBalance(pn); - self:get():SetProperty("Pan", fBalance); - self:play(); + local fBalance = SOUND:GetPlayerBalance(pn) + self:get():SetProperty("Pan", fBalance) + self:play() end -- (c) 2007 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 Sprite.lua b/Themes/_fallback/Scripts/02 Sprite.lua index 12a69f3948..30baef8a32 100644 --- a/Themes/_fallback/Scripts/02 Sprite.lua +++ b/Themes/_fallback/Scripts/02 Sprite.lua @@ -8,7 +8,7 @@ function Sprite:LoadFromSongBanner(song) self:LoadBanner( Path ) else self:LoadBanner( THEME:GetPathG("Common","fallback banner") ) - end; + end end function Sprite:LoadFromSongBackground(song) @@ -22,34 +22,33 @@ end function LoadSongBackground() return Def.Sprite { - InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y); - BeginCommand=cmd(LoadFromSongBackground,GAMESTATE:GetCurrentSong();scale_or_crop_background); - }; + InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y), + BeginCommand=cmd(LoadFromSongBackground,GAMESTATE:GetCurrentSong();scale_or_crop_background) + } end function Sprite:position( f ) - self:GetTexture():position( f ); + self:GetTexture():position( f ) end function Sprite:loop( f ) - self:GetTexture():loop( f ); + self:GetTexture():loop( f ) end function Sprite:rate( f ) - self:GetTexture():rate( f ); + self:GetTexture():rate( f ) end function Sprite.LinearFrames(NumFrames, Seconds) - local Frames = {}; + local Frames = {} for i = 0,NumFrames-1 do Frames[#Frames+1] = { - Frame = i; - Delay = (1/NumFrames)*Seconds; - }; + Frame = i, + Delay = (1/NumFrames)*Seconds + } end - - return Frames; + return Frames end -- (c) 2005 Glenn Maynard diff --git a/Themes/_fallback/Scripts/02 StageMods.lua b/Themes/_fallback/Scripts/02 StageMods.lua index 78f0653890..4f094e2cf7 100644 --- a/Themes/_fallback/Scripts/02 StageMods.lua +++ b/Themes/_fallback/Scripts/02 StageMods.lua @@ -32,11 +32,11 @@ function ScreenSelectMusic:setupmusicstagemods() local song, steps = SONGMAN:GetExtraStageInfo( bExtra2, style ) local po, so if bExtra2 then - po = "default,1.5x,reverse"; - so = "suddendeath"; + po = "default,1.5x,reverse" + so = "suddendeath" else - po = "default,1.5x,reverse"; - so = "norecover"; + po = "default,1.5x,reverse" + so = "norecover" end local difficulty = steps:GetDifficulty() local Reverse = PlayerNumber:Reverse() diff --git a/Themes/_fallback/Scripts/02 Utilities.lua b/Themes/_fallback/Scripts/02 Utilities.lua index 9ad7b76387..210769b724 100644 --- a/Themes/_fallback/Scripts/02 Utilities.lua +++ b/Themes/_fallback/Scripts/02 Utilities.lua @@ -58,7 +58,7 @@ function wrap(val,n) local x = val Trace( "wrap "..x.." "..n ) if x<0 then - x = x + (math.ceil(-x/n)+1)*n; + x = x + (math.ceil(-x/n)+1)*n end Trace( "adjusted "..x ) local ret = math.mod(x,n) @@ -67,21 +67,26 @@ function wrap(val,n) end function fapproach( val, other_val, to_move ) - if val == other_val then return val end - local fDelta = other_val - val - local fSign = fDelta / math.abs( fDelta ) - local fToMove = fSign*to_move - if math.abs(fToMove) > math.abs(fDelta) then - fToMove = fDelta -- snap + if val == other_val then + return val -- already done! end - val = val + fToMove + + local delta = other_val - val + local sign = delta / math.abs(delta) + local toMove = sign*to_move + + if math.abs(toMove) > math.abs(delta) then + toMove = delta -- snap + end + + val = val + toMove return val end function tableshuffle( t ) local ret = { } for i=1,table.getn(t) do - table.insert( ret, math.random(i), t[i] ); + table.insert( ret, math.random(i), t[i] ) end return ret end @@ -89,7 +94,7 @@ end function tableslice( t, num ) local ret = { } for i=1,table.getn(t) do - table.insert( ret, i, t[i] ); + table.insert( ret, i, t[i] ) end return ret end @@ -100,7 +105,9 @@ function GetRandomSongBackground() local song = SONGMAN:GetRandomSong() if song then local path = song:GetBackgroundPath() - if path then return path end + if path then + return path + end end end return THEME:GetPathG("", "_blank") @@ -110,17 +117,19 @@ function GetSongBackground() local song = GAMESTATE:GetCurrentSong() if song then local path = song:GetBackgroundPath() - if path then return path end + if path then + return path + end end return THEME:GetPathG("Common","fallback background") end function StepsOrTrailToCustomDifficulty( stepsOrTrail ) if lua.CheckType("Steps", stepsOrTrail) then - return StepsToCustomDifficulty( stepsOrTrail ); + return StepsToCustomDifficulty( stepsOrTrail ) end if lua.CheckType("Trail", stepsOrTrail) then - return TrailToCustomDifficulty( stepsOrTrail ); + return TrailToCustomDifficulty( stepsOrTrail ) end end diff --git a/Themes/_fallback/Scripts/03 CustomSpeedMods.lua b/Themes/_fallback/Scripts/03 CustomSpeedMods.lua index 81e31d00e8..2b7db89960 100644 --- a/Themes/_fallback/Scripts/03 CustomSpeedMods.lua +++ b/Themes/_fallback/Scripts/03 CustomSpeedMods.lua @@ -46,36 +46,36 @@ anticipated future changes: -- ProfileDir(slot): gets the profile dir for slot, -- where slot is a 'ProfileSlot_*' enum value. local function ProfileDir(slot) - local profileDir = PROFILEMAN:GetProfileDir(slot); - return profileDir or nil; -end; + local profileDir = PROFILEMAN:GetProfileDir(slot) + return profileDir or nil +end -- Tries to parse the file at path. If successful, returns a table of mods. -- If it can't open the file, it will write a fallback set of mods. local function ParseSpeedModFile(path) - local file = RageFileUtil.CreateRageFile(); + local file = RageFileUtil.CreateRageFile() if file:Open(path, 1) then -- success - local contents = file:Read(); - mods = split(',',contents); + local contents = file:Read() + mods = split(',',contents) -- strip any whitespace for i=1,#mods do - string.gsub(mods[i], "%s", ""); + string.gsub(mods[i], "%s", "") end - file:destroy(); - return mods; + file:destroy() + return mods else -- error; write a fallback mod file and return it - local fallbackString = "0.5x,1x,1.5x,2x,3x,4x,8x,C200,C400"; - Trace("[CustomSpeedMods]: Could not read SpeedMods; writing fallback to "..path); - file:Open(path, 2); - file:Write(fallbackString); - file:destroy(); - return split(',',fallbackString); - end; -end; + local fallbackString = "0.5x,1x,1.5x,2x,3x,4x,8x,C200,C400" + Trace("[CustomSpeedMods]: Could not read SpeedMods; writing fallback to "..path) + file:Open(path, 2) + file:Write(fallbackString) + file:destroy() + return split(',',fallbackString) + end +end -- MarkDupes(src,parent) -- Marks duplicates in src from any matches in parent. @@ -84,32 +84,34 @@ local function MarkDupes(src,parent) for iPar=1,#parent do for iSrc=1,#src do if parent[iPar] == src[iSrc] then - src[iSrc] = "XXX"; - end; - end; - end; - return src; -end; + src[iSrc] = "XXX" + end + end + end + return src +end -- RemoveMarked(src) -- Removes any values marked for deletion. local function RemoveMarked(src) for iSrc=1,#src do if src[iSrc] == "XXX" then - table.remove(src,iSrc); - end; - end; - return src; -end; + table.remove(src,iSrc) + end + end + return src +end -- MergeTables(parent,child) -- Adds the child's contents to the parent. -- the overall mods are usually used as the parent. local function MergeTables(parent,child) - child = RemoveMarked(child); - if #child == 0 then return parent; end; + child = RemoveMarked(child) + if #child == 0 then + return parent + end - local addMe = true; + local addMe = true for iC=1,#child do --[[ for iP=1,#parent do @@ -118,133 +120,137 @@ local function MergeTables(parent,child) -- why am I doing this anyways? -- by the time these tables are passed in, -- dupes should be gone. - end; - end; + end + end ]] if addMe then - table.insert(parent,child[iC]); - end; - end; - return parent; -end; + table.insert(parent,child[iC]) + end + end + return parent +end -- code in this function is based off of code in -- http://astrofra.com/weblog/files/sort.lua local function AnonSort(t) - local index_min; + local index_min for i=1,#t,1 do - index_min = i; + index_min = i for j=i+1,#t,1 do if (t[j] < t[index_min]) then - index_min = j; - end; - end; - t[i], t[index_min] = t[index_min], t[i]; - end; - return t; -end; + index_min = j + end + end + t[i], t[index_min] = t[index_min], t[i] + end + return t +end local function SpeedModSort(tab) - local xMods = {}; - local cMods = {}; - --local mMods = {}; + local xMods = {} + local cMods = {} + --local mMods = {} -- convert to numbers so sorting works: for i=1,#tab do - local typ,val; + local typ,val -- xxx: If people use a floating point CMod (e.g. C420.50), -- it will get rounded. C420.50 gets rounded to 421, btw. -aj if string.find(tab[i],"C%d") then - typ = cMods; - val = string.gsub(tab[i], "C", ""); + typ = cMods + val = string.gsub(tab[i], "C", "") elseif string.find(tab[i],"M%d") then - Trace("[CustomSpeedMods] OpenITG's M-Mods are not supported yet in sm-ssc."); - --typ = mMods; - --val = string.gsub(tab[i], "M", ""); + Trace("[CustomSpeedMods] OpenITG's M-Mods are not supported yet in sm-ssc.") + --typ = mMods + --val = string.gsub(tab[i], "M", "") else - typ = xMods; - val = string.gsub(tab[i], "x", ""); - end; - table.insert(typ,tonumber(val)); - end; + typ = xMods + val = string.gsub(tab[i], "x", "") + end + table.insert(typ,tonumber(val)) + end -- sort xMods - xMods = AnonSort(xMods); + xMods = AnonSort(xMods) -- sort cMods - cMods = AnonSort(cMods); + cMods = AnonSort(cMods) -- sort mMods --mMods = AnonSort(mMods) - local fin = {}; + local fin = {} -- convert it back to a string since that's what it expects - for i=1,#xMods do table.insert(fin, xMods[i].."x"); end; - for i=1,#cMods do table.insert(fin, "C"..cMods[i]); end; + for i=1,#xMods do + table.insert(fin, xMods[i].."x") + end + for i=1,#cMods do + table.insert(fin, "C"..cMods[i]) + end --for i=1,#mMods do table.insert(fin, "M"..mMods[i]); end; - return fin; -end; + return fin +end -- parse everything local function GetSpeedMods() - local finalMods = {}; + local finalMods = {} local baseFilename = "SpeedMods.txt" local profileDirs = { Fallback = "Data/", Machine = ProfileDir('ProfileSlot_Machine'), PlayerNumber_P1 = ProfileDir('ProfileSlot_Player1'), - PlayerNumber_P2 = ProfileDir('ProfileSlot_Player2'), - }; + PlayerNumber_P2 = ProfileDir('ProfileSlot_Player2') + } -- figure out how many players we have to deal with. - local numPlayers = GAMESTATE:GetNumPlayersEnabled(); + local numPlayers = GAMESTATE:GetNumPlayersEnabled() -- load fallback - local fallbackMods = ParseSpeedModFile(profileDirs.Fallback..baseFilename); + local fallbackMods = ParseSpeedModFile(profileDirs.Fallback..baseFilename) -- load machine - local machineMods = ParseSpeedModFile(profileDirs.Machine..baseFilename); + local machineMods = ParseSpeedModFile(profileDirs.Machine..baseFilename) - local playerMods = {}; + local playerMods = {} for pn in ivalues(GAMESTATE:GetHumanPlayers()) do -- file loading logic per player; -- only bother if it's not the machine profile though. if PROFILEMAN:IsPersistentProfile(pn) or MEMCARDMAN:GetCardState(pn) == 'MemoryCardState_ready' then - playerMods[#playerMods+1] = ParseSpeedModFile(profileDirs[pn]..baseFilename); - end; - end; + playerMods[#playerMods+1] = ParseSpeedModFile(profileDirs[pn]..baseFilename) + end + end -- with all loaded... the merging BEGINS!! - finalMods = fallbackMods; + finalMods = fallbackMods -- mine for duplicates, first pass (fallback <-> machine) - machineMods = MarkDupes(machineMods,finalMods); + machineMods = MarkDupes(machineMods,finalMods) for ply=1,#playerMods do - playerMods[ply] = MarkDupes(playerMods[ply],finalMods); - end; + playerMods[ply] = MarkDupes(playerMods[ply],finalMods) + end -- remove XXX, first pass machineMods = RemoveMarked(machineMods); for ply=1,#playerMods do - playerMods[ply] = RemoveMarked(playerMods[ply]); - end; + playerMods[ply] = RemoveMarked(playerMods[ply]) + end -- mine for duplicates, second pass (machine <-> player) for ply=1,#playerMods do - playerMods[ply] = MarkDupes(playerMods[ply],machineMods); - end; + playerMods[ply] = MarkDupes(playerMods[ply],machineMods) + end -- remove XXX, second pass - machineMods = RemoveMarked(machineMods); + machineMods = RemoveMarked(machineMods) for ply=1,#playerMods do - playerMods[ply] = RemoveMarked(playerMods[ply]); - end; + playerMods[ply] = RemoveMarked(playerMods[ply]) + end -- merge zone - finalMods = MergeTables(finalMods,machineMods); + finalMods = MergeTables(finalMods,machineMods) for ply=1,#playerMods do - finalMods = MergeTables(finalMods,playerMods[ply]); - end; + finalMods = MergeTables(finalMods,playerMods[ply]) + end -- final removal of XXX before sorting - finalMods = RemoveMarked(finalMods); + finalMods = RemoveMarked(finalMods) -- sort the mods before returning them - return SpeedModSort(finalMods); -end; + return SpeedModSort(finalMods) +end function SpeedMods() -- here we see the option menu itself. @@ -257,36 +263,36 @@ function SpeedMods() Choices = GetSpeedMods(), LoadSelections = function(self, list, pn) - local pMods = GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred"); + local pMods = GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred") for i = 1,table.getn(self.Choices) do if string.find(pMods, self.Choices[i]) then - list[i] = true; - return; - end; - end; + list[i] = true + return + end + end -- if we've reached this point, try to find 1x or 1.0x instead, -- in case the player has defined a speed mod under 1.0x for i = 1,table.getn(self.Choices) do if self.Choices[i] == "1x" or self.Choices[i] == "1.0x" then - list[i] = true; - return; - end; - end; + list[i] = true + return + end + end end, SaveSelections = function(self, list, pn) for i = 1,table.getn(self.Choices) do if list[i] then - local PlayerState = GAMESTATE:GetPlayerState(pn); - PlayerState:SetPlayerOptions("ModsLevel_Preferred",self.Choices[i]); + local PlayerState = GAMESTATE:GetPlayerState(pn) + PlayerState:SetPlayerOptions("ModsLevel_Preferred",self.Choices[i]) return end end end - }; - setmetatable( t, t ); - return t; -end; + } + setmetatable( t, t ) + return t +end --[[ Copyright © 2008-2009 AJ Kelly/KKI Labs. diff --git a/Themes/_fallback/Scripts/03 DateTime.lua b/Themes/_fallback/Scripts/03 DateTime.lua index 218fa30bcc..fd743c327f 100644 --- a/Themes/_fallback/Scripts/03 DateTime.lua +++ b/Themes/_fallback/Scripts/03 DateTime.lua @@ -46,26 +46,25 @@ local dateChars = { --[[ full datetime ]] 'c', -- ISO 8601 date 'r', -- RFC 2822 formatted date - 'U', -- Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) -}; + 'U' -- Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) +} function date(format,...) if ... then -- convert value else - -- convert current time - - end; -end; + -- convert current time + end +end Date = { Today = function() - return string.format("%i%02i%02i", Year(), (MonthOfYear()+1), DayOfMonth()); - end; -}; + return string.format("%i%02i%02i", Year(), (MonthOfYear()+1), DayOfMonth()) + end +} Time = { Now = function() - return string.format( "%02i:%02i:%02i", Hour(), Minute(), Second() ); - end; -}; \ No newline at end of file + return string.format( "%02i:%02i:%02i", Hour(), Minute(), Second() ) + end +} \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 EnvUtils2.lua b/Themes/_fallback/Scripts/03 EnvUtils2.lua index 80235f09a8..790b27e8bc 100644 --- a/Themes/_fallback/Scripts/03 EnvUtils2.lua +++ b/Themes/_fallback/Scripts/03 EnvUtils2.lua @@ -10,7 +10,7 @@ This new version should also work better and be less confusing. --]] -- Env table global -envTable = GAMESTATE:Env(); +envTable = GAMESTATE:Env() -- setenv(name,value) -- Sets aside an entry for /name/ and puts /value/ into it. @@ -18,14 +18,14 @@ envTable = GAMESTATE:Env(); -- If you need to store more than one value, you're welcome to use a -- table as /value/, it should work just fine. function setenv(name,value) - envTable[name] = value; -end; + envTable[name] = value +end -- getenv(name) -- This will return whatever value is at envTable[name]. function getenv(name) - return envTable[name]; -end; + return envTable[name] +end --[[ Copyright © 2008 AJ Kelly/KKI Labs diff --git a/Themes/_fallback/Scripts/03 Gameplay.lua b/Themes/_fallback/Scripts/03 Gameplay.lua index e873f7638f..8ae1453a02 100644 --- a/Themes/_fallback/Scripts/03 Gameplay.lua +++ b/Themes/_fallback/Scripts/03 Gameplay.lua @@ -2,10 +2,12 @@ -- [en] This file is used to store settings that should be different in each -- game mode. +-- shakesoda calls this pump.lua + -- GameCompatibleModes: -- [en] returns possible modes for ScreenSelectPlayMode function GameCompatibleModes() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Modes = { dance = "Single,Double,Solo,Versus,Couple", pump = "Single,Double,HalfDouble,Versus,Couple", @@ -13,20 +15,20 @@ function GameCompatibleModes() kb7 = "KB7", para = "Single", techno = "Single4,Single5,Single8,Double4,Double8", - lights = "Single", -- lights shouldn't be playable - }; - return Modes[sGame]; + lights = "Single" -- lights shouldn't be playable + } + return Modes[sGame] end function SelectProfileKeys() - local game = GAMESTATE:GetCurrentGame():GetName(); - return game == "dance" and "Up,Down,Start,Back,Up2,Down2" or "Up,Down,Start,Back"; -end; + local game = GAMESTATE:GetCurrentGame():GetName() + return game == "dance" and "Up,Down,Start,Back,Up2,Down2" or "Up,Down,Start,Back" +end -- ScoreKeeperClass: -- [en] Determines the correct ScoreKeeper class to use. function ScoreKeeperClass() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local ScoreKeepers = { -- xxx: allow for ScoreKeeperShared when needed dance = "ScoreKeeperNormal", @@ -38,149 +40,159 @@ function ScoreKeeperClass() ez2 = "ScoreKeeperNormal", ds3ddx = "ScoreKeeperNormal", maniax = "ScoreKeeperNormal", - guitar = "ScoreKeeperGuitar", - }; + guitar = "ScoreKeeperGuitar" + } return ScoreKeepers[sGame] -end; +end -- ComboContinue: -- [en] function ComboContinue() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Continue = { dance = GAMESTATE:GetPlayMode() == "PlayMode_Oni" and "TapNoteScore_W2" or "TapNoteScore_W3", pump = "TapNoteScore_W4", beat = "TapNoteScore_W3", kb7 = "TapNoteScore_W3", - para = "TapNoteScore_W4", - }; + para = "TapNoteScore_W4" + } return Continue[sGame] -end; +end function ComboMaintain() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Maintain = { dance = "TapNoteScore_W3", pump = "TapNoteScore_W4", beat = "TapNoteScore_W3", kb7 = "TapNoteScore_W3", - para = "TapNoteScore_W4", - }; + para = "TapNoteScore_W4" + } return Maintain[sGame] -end; +end function ComboPerRow() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() if sGame == "pump" then - return true; + return true elseif GAMESTATE:GetPlayMode() == "PlayMode_Oni" then - return true; - else return false; - end; -end; + return true + else + return false + end +end +-- these need cleanup really. function HitCombo() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Combo = { dance = 2, pump = 4, beat = 2, kb7 = 2, para = 2, - guitar = 2, - }; + guitar = 2 + } return Combo[sGame] -end; +end function MissCombo() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Combo = { dance = 2, pump = 4, beat = 0, kb7 = 0, para = 0, - guitar = 0, - }; + guitar = 0 + } return Combo[sGame] -end; +end -- FailCombo: -- [en] The combo that causes game failure. function FailCombo() - sGame = GAMESTATE:GetCurrentGame():GetName(); + sGame = GAMESTATE:GetCurrentGame():GetName() local Combo = { dance = -1, -- ITG uses 30 pump = 51, -- Pump Pro uses 30, real Pump uses 51 beat = -1, kb7 = -1, para = -1, - guitar = -1, - }; + guitar = -1 + } return Combo[sGame] -end; +end -- todo: use tables for some of these -aj function HoldTiming() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0; - else return PREFSMAN:GetPreference("TimingWindowSecondsHold"); - end; -end; + return 0 + else + return PREFSMAN:GetPreference("TimingWindowSecondsHold") + end +end function ShowHoldJudgments() - return not GAMESTATE:GetCurrentGame():GetName() == "pump"; -end; + return not GAMESTATE:GetCurrentGame():GetName() == "pump" +end function HoldHeadStep() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; + return false + else + return true + end +end function InitialHoldLife() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0.05; - else return 1; - end; -end; + return 0.05 + else + return 1 + end +end function MaxHoldLife() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return 0.05; - else return 1; - end; -end; + return 0.05 + else + return 1 + end +end function ImmediateHoldLetGo() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; + return false + else + return true + end +end function RollBodyIncrementsCombo() return false --[[ if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; --]] -end; + return false + else + return true + end --]] +end function CheckpointsTapsSeparateJudgment() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; + return false + else + return true + end +end function ScoreMissedHoldsAndRolls() if GAMESTATE:GetCurrentGame():GetName() == "pump" then - return false; - else return true; - end; -end; + return false + else + return true + end +end local tNotePositions = { -- StepMania 3.9/4.0 @@ -192,13 +204,14 @@ local tNotePositions = { Lower = { -125, 145, - }, + } } + function GetTapPosition( sType ) - bCategory = (sType == 'Standard') and 1 or 2; + bCategory = (sType == 'Standard') and 1 or 2 -- true: Normal -- false: Lower - bPreference = GetUserPrefB("UserPrefNotePosition") and "Normal" or "Lower"; - tNotePos = tNotePositions[bPreference]; + bPreference = GetUserPrefB("UserPrefNotePosition") and "Normal" or "Lower" + tNotePos = tNotePositions[bPreference] return tNotePos[bCategory] end \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 HSV.lua b/Themes/_fallback/Scripts/03 HSV.lua index f21f70e187..43744bdfe5 100644 --- a/Themes/_fallback/Scripts/03 HSV.lua +++ b/Themes/_fallback/Scripts/03 HSV.lua @@ -19,25 +19,30 @@ Saturation is different too. -- ColorToHSV(c) -- Takes in a normal color("") and returns a table with the HSV values. +function HasAlpha(c) + if c[4] then + return c[4] + else + return 1 + end +end + function ColorToHSV(c) - local r = c[1]; - local g = c[2]; - local b = c[3]; + local r = c[1] + local g = c[2] + local b = c[3] -- alpha requires error checking sometimes. - local a; - if c[4] then a = c[4]; - else a = 1; - end; + local a = HasAlpha(c) - local h = 0; - local s = 0; - local v = 0; + local h = 0 + local s = 0 + local v = 0 - local min = math.min( r, g, b ); - local max = math.max( r, g, b ); - v = max; + local min = math.min( r, g, b ) + local max = math.max( r, g, b ) + v = max - local delta = max - min; + local delta = max - min -- xxx: how do we deal with complete black? if min == 0 and max == 0 then @@ -47,137 +52,137 @@ function ColorToHSV(c) Sat = 0, Value = 0, Alpha = a - }; - end; + } + end if max ~= 0 then - s = delta / max; -- rofl deltamax :| + s = delta / max -- rofl deltamax :| else -- r = g = b = 0; s = 0, v is undefined - s = 0; - h = -1; + s = 0 + h = -1 return { Hue = h, Sat = s, Value = v, Alpha = 1 - }; - end; + } + end if r == max then - h = ( g - b ) / delta; -- yellow/magenta + h = ( g - b ) / delta -- yellow/magenta elseif g == max then - h = 2 + ( b - r ) / delta; -- cyan/yellow + h = 2 + ( b - r ) / delta -- cyan/yellow else - h = 4 + ( r - g ) / delta; -- magenta/cyan - end; + h = 4 + ( r - g ) / delta -- magenta/cyan + end - h = h * 60; -- degrees + h = h * 60 -- degrees if h < 0 then - h = h + 360; - end; + h = h + 360 + end return { Hue = h, Sat = s, Value = v, Alpha = a - }; -end; + } +end -- HSVToColor(hsv) -- Converts a set of HSV values to a color. hsv is a table. -- See also: HSV(h, s, v) function HSVToColor(hsv) - local i; - local f, q, p, t; - local r, g, b; - local h, s, v; + local i + local f, q, p, t + local r, g, b + local h, s, v - local a; + local a - s = hsv.Sat; - v = hsv.Value; + s = hsv.Sat + v = hsv.Value - if hsv.Alpha then a = hsv.Alpha; - else a = 0; - end; + if hsv.Alpha then + a = hsv.Alpha + else + a = 0 + end if s == 0 then - return { v, v, v, a }; - end; + return { v, v, v, a } + end - h = hsv.Hue / 60; + h = hsv.Hue / 60 - i = math.floor(h); - f = h - i; - p = v * (1-s); - q = v * (1-s*f); - t = v * (1-s*(1-f)); + i = math.floor(h) + f = h - i + p = v * (1-s) + q = v * (1-s*f) + t = v * (1-s*(1-f)) if i == 0 then - return { v, t, p, a }; + return { v, t, p, a } elseif i == 1 then - return { q, v, p, a }; + return { q, v, p, a } elseif i == 2 then - return { p, v, t, a }; + return { p, v, t, a } elseif i == 3 then - return { p, q, v, a }; + return { p, q, v, a } elseif i == 4 then - return { t, p, v, a }; + return { t, p, v, a } else - return { v, p, q, a }; - end; -end; + return { v, p, q, a } + end +end -- ColorToHex(c) -- Takes in a normal color("") and returns the hex representation. -- Adapted from code in LuaBit (http://luaforge.net/projects/bit/), -- which is MIT licensed and copyright (C) 2006~2007 hanzhao. function ColorToHex(c) - local r = c[1]; - local g = c[2]; - local b = c[3]; - local a; - if c[4] then a = c[4]; - else a = 1; - end; + local r = c[1] + local g = c[2] + local b = c[3] + local a = HasAlpha(c) local function hex(value) - value = math.ceil(value); + value = math.ceil(value) - local hexVals = {'A', 'B', 'C', 'D', 'E', 'F'} - local out = ""; - local last = 0; + local hexVals = { 'A', 'B', 'C', 'D', 'E', 'F' } + local out = "" + local last = 0 while(value ~= 0) do - last = math.mod(value, 16); + last = math.mod(value, 16) if(last < 10) then - out = tostring(last) .. out; + out = tostring(last) .. out else - out = hexVals[(last-10)+1] .. out; - end; - value = math.floor(value/16); - end; + out = hexVals[(last-10)+1] .. out + end + value = math.floor(value/16) + end if(out == "") then - return "00"; + return "00" end - return string.format( "%02X", tonumber(out,16) ); - end; + + return string.format( "%02X", tonumber(out,16) ) + end - local rX = hex( scale(r, 0, 1, 0, 255) ); - local gX = hex( scale(g, 0, 1, 0, 255) ); - local bX = hex( scale(b, 0, 1, 0, 255) ); - local aX = hex( scale(a, 0, 1, 0, 255) ); + local rX = hex( scale(r, 0, 1, 0, 255) ) + local gX = hex( scale(g, 0, 1, 0, 255) ) + local bX = hex( scale(b, 0, 1, 0, 255) ) + local aX = hex( scale(a, 0, 1, 0, 255) ) - return rX .. gX .. bX .. aX; -end; + return rX .. gX .. bX .. aX +end function HSVToHex(hsv) - return ColorToHex( HSVToColor(hsv) ); -end; + return ColorToHex( HSVToColor(hsv) ) +end --[[ you should mainly use these functions ]] @@ -188,9 +193,9 @@ function HSV(h, s, v) Sat = s, Value = v, Alpha = 1 - }; - return HSVToColor(t); -end; + } + return HSVToColor(t) +end -- here's the proper one function HSVA(h, s, v, a) @@ -199,43 +204,43 @@ function HSVA(h, s, v, a) Sat = s, Value = v, Alpha = a - }; - return HSVToColor(t); -end; + } + return HSVToColor(t) +end function Saturation(color,percent) - local c = ColorToHSV(color); + local c = ColorToHSV(color) -- error checking if percent < 0 then - percent = 0.0; + percent = 0.0 elseif percent > 1 then - percent = 1.0; - end; - c.Sat = percent; - return HSVToColor(c); -end; + percent = 1.0 + end + c.Sat = percent + return HSVToColor(c) +end function Brightness(color,percent) - local c = ColorToHSV(color); + local c = ColorToHSV(color) -- error checking if percent < 0 then - percent = 0.0; + percent = 0.0 elseif percent > 1 then - percent = 1.0; - end; - c.Value = percent; - return HSVToColor(c); -end; + percent = 1.0 + end + c.Value = percent + return HSVToColor(c) +end function Hue(color,newHue) - local c = ColorToHSV(color); + local c = ColorToHSV(color) -- handle wrapping if newHue < 0 then - newHue = 360 + newHue; + newHue = 360 + newHue elseif newHue > 360 then --newHue = math.mod(newHue, 360); -- ?? untested - newHue = newHue - 360; - end; - c.Hue = newHue; - return HSVToColor(c); + newHue = newHue - 360 + end + c.Hue = newHue + return HSVToColor(c) end; \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua index f065071808..2968b5ec31 100644 --- a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua +++ b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua @@ -12,7 +12,7 @@ Blend = { Multiply = 'BlendMode_WeightedMultiply', Invert = 'BlendMode_InvertDest', NoEffect = 'BlendMode_NoEffect' -}; +} -- Health Declarations -- Used primarily for lifebars. @@ -21,37 +21,37 @@ Health = { Alive = 'HealthState_Alive', Danger = 'HealthState_Danger', Dead = 'HealthState_Dead' -}; +} --[[ Actor commands ]] function Actor:CenterX() - self:x(SCREEN_CENTER_X); -end; + self:x(SCREEN_CENTER_X) +end function Actor:CenterY() - self:y(SCREEN_CENTER_Y); -end; + self:y(SCREEN_CENTER_Y) +end -- xy(actorX,actorY) -- Sets the x and y of an actor in one command. function Actor:xy(actorX,actorY) - self:x(actorX); - self:y(actorY); -end; + self:x(actorX) + self:y(actorY) +end -- MaskSource([clearzbuffer]) -- Sets an actor up as the source for a mask. Clears zBuffer by default. -function Actor:MaskSource(_) - self:clearzbuffer(_ or true); - self:zwrite(true); - self:blend('BlendMode_NoEffect'); -end; +function Actor:MaskSource(noclear) + self:clearzbuffer(noclear or true) + self:zwrite(true) + self:blend('BlendMode_NoEffect') +end -- MaskDest() -- Sets an actor up to be masked by anything with MaskSource(). function Actor:MaskDest() - self:ztest(true); -end; + self:ztest(true) +end -- Thump() -- A customized version of pulse that is more appealing for on-beat @@ -59,13 +59,13 @@ end; function Actor:thump(fEffectPeriod) self:pulse() if fEffectPeriod ~= nil then - self:effecttiming(0,0,0.75*fEffectPeriod,0.25*fEffectPeriod); + self:effecttiming(0,0,0.75*fEffectPeriod,0.25*fEffectPeriod) else - self:effecttiming(0,0,0.75,0.25); + self:effecttiming(0,0,0.75,0.25) end -- The default effectmagnitude will make this effect look very bad. - self:effectmagnitude(1,1.125,1); -end; + self:effectmagnitude(1,1.125,1) +end --[[ BitmapText commands ]] @@ -73,22 +73,23 @@ end; -- An alias that turns off texture filtering. -- Named because it works best with pixel fonts. function BitmapText:PixelFont() - self:SetTextureFiltering(false); -end; + self:SetTextureFiltering(false) +end -- Stroke(color) -- Sets the text's stroke color. function BitmapText:Stroke(c) - self:strokecolor( c ); -end; + self:strokecolor( c ) +end -- NoStroke() -- Removes any stroke. function BitmapText:NoStroke() - self:strokecolor( color("0,0,0,0") ); -end; + self:strokecolor( color("0,0,0,0") ) +end -- Set Text With Format (contributed by Daisuke Master) +-- this function is my hero - shake function BitmapText:settextf(...) self:settext(string.format(...)) end @@ -96,8 +97,8 @@ end -- DiffuseAndStroke(diffuse,stroke) -- Set diffuse and stroke at the same time. function BitmapText:DiffuseAndStroke(diffuseC,strokeC) - self:diffuse(diffuseC); - self:strokecolor(strokeC); + self:diffuse(diffuseC) + self:strokecolor(strokeC) end; --[[ end BitmapText commands ]] @@ -106,20 +107,24 @@ end; --[[ helper functions ]] function tobool(v) if type(v) == "string" then - local cmp = string.lower(v); + local cmp = string.lower(v) if cmp == "true" or cmp == "t" then - return true; + return true elseif cmp == "false" or cmp == "f" then - return false; - end; + return false + end elseif type(v) == "number" then - if v == 0 then return false; - else return true; - end; - end; -end; + if v == 0 then + return false + else + return true + end + end +end -function pname(pn) return ToEnumShortString(pn); end; +function pname(pn) + return ToEnumShortString(pn) +end -- from http://ardoris.wordpress.com/2008/11/07/rounding-to-a-certain-number-of-decimal-places-in-lua/ function round(what, precision) diff --git a/Themes/_fallback/Scripts/03 UserPreferences2.lua b/Themes/_fallback/Scripts/03 UserPreferences2.lua index 2397f3dfb9..eed6d16823 100644 --- a/Themes/_fallback/Scripts/03 UserPreferences2.lua +++ b/Themes/_fallback/Scripts/03 UserPreferences2.lua @@ -31,62 +31,62 @@ ThemeInfo is documented at http://kki.ajworld.net/wiki/ThemeInfo.lua After that's set up, read the docs. ]] -local PrefPath = "Data/UserPrefs/".. THEME:GetThemeDisplayName() .."/"; +local PrefPath = "Data/UserPrefs/".. THEME:GetThemeDisplayName() .."/" --[[ begin internal stuff; no need to edit below this line. ]] -- Local internal function to write envs. ___Not for themer use.___ local function WriteEnv(envName,envValue) - return setenv(envName,envValue); -end; + return setenv(envName,envValue) +end function ReadPrefFromFile(name) - local f = RageFileUtil.CreateRageFile(); - local fullFilename = PrefPath..name..".cfg"; - local option; + local f = RageFileUtil.CreateRageFile() + local fullFilename = PrefPath..name..".cfg" + local option if f:Open(fullFilename,1) then - option = tostring( f:Read() ); - WriteEnv(name,option); - f:destroy(); - return option; + option = tostring( f:Read() ) + WriteEnv(name,option) + f:destroy() + return option else - local fError = f:GetError(); - Trace( "[FileUtils] Error reading ".. fullFilename ..": ".. fError ); - f:ClearError(); - f:destroy(); - return nil; - end; -end; + local fError = f:GetError() + Trace( "[FileUtils] Error reading ".. fullFilename ..": ".. fError ) + f:ClearError() + f:destroy() + return nil + end +end function WritePrefToFile(name,value) - local f = RageFileUtil.CreateRageFile(); - local fullFilename = PrefPath..name..".cfg"; + local f = RageFileUtil.CreateRageFile() + local fullFilename = PrefPath..name..".cfg" if f:Open(fullFilename, 2) then - f:Write( tostring(value) ); - WriteEnv(name,value); + f:Write( tostring(value) ) + WriteEnv(name,value) else - local fError = f:GetError(); - Trace( "[FileUtils] Error writing to ".. fullFilename ..": ".. fError ); - f:ClearError(); - f:destroy(); - return false; - end; + local fError = f:GetError() + Trace( "[FileUtils] Error writing to ".. fullFilename ..": ".. fError ) + f:ClearError() + f:destroy() + return false + end - f:destroy(); - return true; -end; + f:destroy() + return true +end --[[ end internal functions; still don't edit below this line ]] function GetUserPref(name) - return ReadPrefFromFile(name); -end; + return ReadPrefFromFile(name) +end function SetUserPref(name,value) - return WritePrefToFile(name,value); -end; + return WritePrefToFile(name,value) +end --[[ type specific, for when you want to be lazy ]] -- XXX: make set funcs, since I hate dealing with colors and I know @@ -95,41 +95,40 @@ end; -- GetUserPrefB: boolean function GetUserPrefB(name) -- this one is a bit trickier. - local pref = ReadPrefFromFile(name); + local pref = ReadPrefFromFile(name) if type(pref) == "string" then - pref = string.lower(pref); + pref = string.lower(pref) if pref == "true" or cmp == "t" then - return true; + return true elseif pref == "false" or cmp == "f" then - return false; + return false else - Trace("Error in GetUserPrefB(".. name ..") converting from string" ); - return false; - end; - + Trace("Error in GetUserPrefB(".. name ..") converting from string" ) + return false + end elseif type(pref) == "number" then -- both 0 and -1 are false; if you want to change this, -- feel free to remove "or pref == -1". if pref == 0 or pref == -1 then - return false; + else - return true; - end; - end; -end; + return true + end + end +end -- GetUserPrefC: color function GetUserPrefC(name) -- XXX: make sure it's grabbing a string that can be turned into a color -- and also possibly handle HSV values too. - return color( ReadPrefFromFile(name) ); -end; + return color( ReadPrefFromFile(name) ) +end -- GetUserPrefN: numbers (integers, floats) function GetUserPrefN(name) - return tonumber( ReadPrefFromFile(name) ); -end; + return tonumber( ReadPrefFromFile(name) ) +end --[[ Copyright © 2008-2009 AJ Kelly/KKI Labs diff --git a/Themes/_fallback/Scripts/04 FileUtils.lua b/Themes/_fallback/Scripts/04 FileUtils.lua index 416cc8fe4c..dbac909328 100644 --- a/Themes/_fallback/Scripts/04 FileUtils.lua +++ b/Themes/_fallback/Scripts/04 FileUtils.lua @@ -7,8 +7,8 @@ File = { f:destroy() return true else - Trace( "[FileUtils] Error writing to ".. path ..": ".. f:GetError() ); - f:ClearError(); + Trace( "[FileUtils] Error writing to ".. path ..": ".. f:GetError() ) + f:ClearError() f:destroy() return false end @@ -21,12 +21,12 @@ File = { f:destroy() return ret else - Trace( "[FileUtils] Error reading from ".. path ..": ".. f:GetError() ); - f:ClearError(); + Trace( "[FileUtils] Error reading from ".. path ..": ".. f:GetError() ) + f:ClearError() f:destroy() return nil end end -}; +} -- this code if public domain and/or has no copyright, depending on your -- country's laws. I wish for you to use this code freely, without restriction. \ No newline at end of file diff --git a/Themes/_fallback/Scripts/04 WidescreenHelpers.lua b/Themes/_fallback/Scripts/04 WidescreenHelpers.lua index 7cecd2784e..87c97bf49f 100644 --- a/Themes/_fallback/Scripts/04 WidescreenHelpers.lua +++ b/Themes/_fallback/Scripts/04 WidescreenHelpers.lua @@ -9,16 +9,18 @@ AspectRatios = { FourThree = 1.33333, --* 640x480 SixteenTen = 1.6, --* 720x480 SixteenNine = 1.77778, --* 853x480 - EightThree = 2.66666, -- 1280x480 -}; + EightThree = 2.66666 -- 1280x480 +} function IsUsingWideScreen() - return GetScreenAspectRatio() >= 1.6; -end; + return GetScreenAspectRatio() >= 1.6 +end -- take and use it as you like, I don't care -aj -- (although I should mention this file was specific to moonlight and was pretty -- bad before some editing. -aj) -- this one is good though: -function WideScale(AR4_3, AR16_9) return scale( SCREEN_WIDTH, 640, 854, AR4_3, AR16_9 ); end \ No newline at end of file +function WideScale(AR4_3, AR16_9) + return scale( SCREEN_WIDTH, 640, 854, AR4_3, AR16_9 ) +end \ No newline at end of file