update scripts as a part of a cleanup

This commit is contained in:
AJ Kelly
2011-10-27 18:56:23 -05:00
parent 5e7b5fc44c
commit 28c1b3e70b
10 changed files with 237 additions and 283 deletions
+167 -12
View File
@@ -181,21 +181,176 @@ function Actor:scale_or_crop_background()
end
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
function Actor:CenterX()
self:x(SCREEN_CENTER_X)
end
function Actor:CenterY()
self:y(SCREEN_CENTER_Y)
end
function Actor:Center()
self:x(SCREEN_CENTER_X)
self:y(SCREEN_CENTER_Y)
self:x(SCREEN_CENTER_X)
self:y(SCREEN_CENTER_Y)
end
function Actor:bezier(...)
local a = {...}
local b = {}
local c = 0
assert((a == 9 or a == 5), "bad number of arguments for Actor:bezier()")
for i=3,c do
b[#b+1] = a[i]
end
self:tween(a[2], "TweenMode_Bezier", b)
end
local a = {...}
local b = {}
local c = 0
assert((a == 9 or a == 5), "bad number of arguments for Actor:bezier()")
for i=3,c do
b[#b+1] = a[i]
end
self:tween(a[2], "TweenMode_Bezier", b)
end
function Actor:Real()
-- scale back down to real pixels.
self:basezoom(GetReal())
-- don't make this ugly
self:SetTextureFiltering(false)
end
-- Scale things back up after they have already been scaled down.
function Actor:RealInverse()
-- scale back up to theme resolution
self:basezoom(GetRealInverse())
self:SetTextureFiltering(true)
end
-- MaskSource([clearzbuffer])
-- Sets an actor up as the source for a mask. Clears zBuffer by default.
function Actor:MaskSource(noclear)
if noclear == true then
self:clearzbuffer(true)
end
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
-- Thump()
-- A customized version of pulse that is more appealing for on-beat
-- effects;
function Actor:thump(fEffectPeriod)
self:pulse()
if fEffectPeriod ~= nil then
self:effecttiming(0,0,0.75*fEffectPeriod,0.25*fEffectPeriod)
else
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
-- Heartbeat()
-- A customized version of pulse that is more appealing for on-beat
-- effects;
function Actor:heartbeat(fEffectPeriod)
self:pulse()
if fEffectPeriod ~= nil then
self:effecttiming(0,0.125*fEffectPeriod,0.125*fEffectPeriod,0.75*fEffectPeriod);
else
self:effecttiming(0,0.125,0.125,0.75);
end
self:effecmagnitude(1,1.125,1)
end
--[[ BitmapText commands ]]
-- PixelFont()
-- An alias that turns off texture filtering.
-- Named because it works best with pixel fonts.
function BitmapText:PixelFont()
self:SetTextureFiltering(false)
end
-- Stroke(color)
-- Sets the text's stroke color.
function BitmapText:Stroke(c)
self:strokecolor( c )
end
-- NoStroke()
-- Removes any stroke.
function BitmapText:NoStroke()
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
-- DiffuseAndStroke(diffuse,stroke)
-- Set diffuse and stroke at the same time.
function BitmapText:DiffuseAndStroke(diffuseC,strokeC)
self:diffuse(diffuseC)
self:strokecolor(strokeC)
end;
--[[ end BitmapText commands ]]
function Actor:LyricCommand(side)
self:settext( Var "LyricText" )
self:draworder(102)
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 lyricColor = Var "LyricColor"
local Factor = 1
if side == "Back" then
Factor = 0.5
elseif side == "Front" then
Factor = 0.9
end
self:diffuse( {
lyricColor[1] * Factor,
lyricColor[2] * Factor,
lyricColor[3] * Factor,
lyricColor[4] * Factor } )
if side == "Front" then
self:cropright(1)
else
self:cropleft(0)
end
self:diffusealpha(0)
self:linear(0.2)
self:diffusealpha(0.75)
self:linear( Var "LyricDuration" * 0.75)
if side == "Front" then
self:cropright(0)
else
self:cropleft(1)
end
self:sleep( Var "LyricDuration" * 0.25 )
self:linear(0.2)
self:diffusealpha(0)
end
-- formerly in 02 HelpDisplay.lua, although nothing uses it:
function HelpDisplay:setfromsongorcourse()
@@ -222,7 +377,7 @@ function ActorSound:playforplayer(pn)
self:play()
end
-- (c) 2006 Glenn Maynard
-- (c) 2006-2011 Glenn Maynard, SSC
-- All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-71
View File
@@ -1,71 +0,0 @@
function Actor:LyricCommand(side)
self:settext( Var "LyricText" )
self:draworder(102)
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 lyricColor = Var "LyricColor"
local Factor = 1
if side == "Back" then
Factor = 0.5
elseif side == "Front" then
Factor = 0.9
end
self:diffuse( {
lyricColor[1] * Factor,
lyricColor[2] * Factor,
lyricColor[3] * Factor,
lyricColor[4] * Factor } )
if side == "Front" then
self:cropright(1)
else
self:cropleft(0)
end
self:diffusealpha(0)
self:linear(0.2)
self:diffusealpha(0.75)
self:linear( Var "LyricDuration" * 0.75)
if side == "Front" then
self:cropright(0)
else
self:cropleft(1)
end
self:sleep( Var "LyricDuration" * 0.25 )
self:linear(0.2)
self:diffusealpha(0)
end
-- (c) 2006 Glenn Maynard
-- All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the
-- "Software"), to deal in the Software without restriction, including
-- without limitation the rights to use, copy, modify, merge, publish,
-- distribute, and/or sell copies of the Software, and to permit persons to
-- whom the Software is furnished to do so, provided that the above
-- copyright notice(s) and this permission notice appear in all copies of
-- the Software and that both the above copyright notice(s) and this
-- permission notice appear in supporting documentation.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
-- THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
-- INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
-- OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-- OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
+62 -1
View File
@@ -182,6 +182,36 @@ function StepsOrTrailToCustomDifficulty(stepsOrTrail)
end
end
function IsArcade()
local sCoinMode = GAMESTATE:GetCoinMode();
local bIsArcade = (sCoinMode ~= 'CoinMode_Home');
return bIsArcade;
end
function IsHome()
local sCoinMode = GAMESTATE:GetCoinMode();
local bIsHome = (sCoinMode == 'CoinMode_Home');
return bIsHome;
end
function IsFreePlay()
return IsArcade() and (GAMESTATE:GetCoinMode() == 'CoinMode_Free') or false
end
function Center1Player()
local styleType = GAMESTATE:GetCurrentStyle():GetStyleType()
-- always center in OnePlayerTwoSides.
if styleType == "StyleType_OnePlayerTwoSides" then
return true
-- only Center1P if Pref enabled and OnePlayerOneSide.
-- (implicitly excludes Rave, Battle, Versus, Routine)
elseif PREFSMAN:GetPreference("Center1Player") then
return styleType == "StyleType_OnePlayerOneSide"
else
return false
end
end
Date = {
Today = function()
return string.format("%i%02i%02i", Year(), (MonthOfYear()+1), DayOfMonth())
@@ -194,7 +224,38 @@ Time = {
end
}
-- (c) 2005 Glenn Maynard, Chris Danford
-- file utilities
File = {
Write = function(path,buf)
local f = RageFileUtil.CreateRageFile()
if f:Open(path, 2) then
f:Write( tostring(buf) )
f:destroy()
return true
else
Trace( "[FileUtils] Error writing to ".. path ..": ".. f:GetError() )
f:ClearError()
f:destroy()
return false
end
end,
Read = function(path)
local f = RageFileUtil.CreateRageFile()
local ret = ""
if f:Open(path, 1) then
ret = tostring( f:Read() )
f:destroy()
return ret
else
Trace( "[FileUtils] Error reading from ".. path ..": ".. f:GetError() )
f:ClearError()
f:destroy()
return nil
end
end
}
-- (c) 2005-2011 Glenn Maynard, Chris Danford, SSC
-- All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a
@@ -185,7 +185,7 @@ local function GetSpeedMods()
local baseFilename = "SpeedMods.txt"
local profileDirs = {
Fallback = "Data/", -- xxx: this seems to cause problems on windows vista/7
--Fallback = "Data/",
Machine = ProfileDir('ProfileSlot_Machine'),
PlayerNumber_P1 = ProfileDir('ProfileSlot_Player1'),
PlayerNumber_P2 = ProfileDir('ProfileSlot_Player2')
@@ -194,7 +194,7 @@ local function GetSpeedMods()
-- figure out how many players we have to deal with.
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)
@@ -210,7 +210,7 @@ local function GetSpeedMods()
end
end
finalMods = fallbackMods
--finalMods = fallbackMods
-- mine for duplicates, first pass (fallback <-> machine)
machineMods = MarkDupes(machineMods,finalMods)
for ply=1,#playerMods do
+2 -11
View File
@@ -1,22 +1,14 @@
--[[
EnvUtils2: Environmental Variable Utilities
Written by AJ Kelly of KKI Labs / Version 2.0
This code is a rewrite of what typically exists in EnvUtils.lua
(as seen in dubaiOne), hereafter referred to as EnvUtils1.
I felt it was time for a simplification of the code.
This new version should also work better and be less confusing.
--]]
-- Env table global
envTable = GAMESTATE:Env()
-- setenv(name,value)
-- Sets aside an entry for /name/ and puts /value/ into it.
-- Unlike EnvUtils1, this is the only setenv function available to you.
-- If you need to store more than one value, you're welcome to use a
-- table as /value/, it should work just fine.
-- Sets aside an entry for <name> and puts <value> into it.
-- Use a table as <value> to store multiple values
function setenv(name,value)
envTable[name] = value
end
@@ -29,7 +21,6 @@ end
--[[
Copyright © 2008 AJ Kelly/KKI Labs
Use freely.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -31,6 +31,7 @@ ThemeInfo is documented at http://kki.ajworld.net/wiki/ThemeInfo.lua
After that's set up, read the docs.
]]
-- xxx: DON'T USE DATA!!
local PrefPath = "Data/GamePrefs/"
--[[ begin internal stuff; no need to edit below this line. ]]
@@ -1,40 +1,4 @@
-- ProductivityHelpers: A set of useful aliases for theming.
--[[ Globals ]]
function IsArcade()
local sCoinMode = GAMESTATE:GetCoinMode();
local bIsArcade = (sCoinMode ~= 'CoinMode_Home');
return bIsArcade;
end
function IsHome()
local sCoinMode = GAMESTATE:GetCoinMode();
local bIsHome = (sCoinMode == 'CoinMode_Home');
return bIsHome;
end
function IsFreePlay()
if IsArcade() then
return (GAMESTATE:GetCoinMode() == 'CoinMode_Free');
else
return false
end
end
function Center1Player()
local styleType = GAMESTATE:GetCurrentStyle():GetStyleType()
-- always center in OnePlayerTwoSides.
if styleType == "StyleType_OnePlayerTwoSides" then
return true
-- only Center1P if Pref enabled and OnePlayerOneSide.
-- (implicitly excludes Rave, Battle, Versus, Routine)
elseif PREFSMAN:GetPreference("Center1Player") then
return styleType == "StyleType_OnePlayerOneSide"
else
return false
end
end
--[[ 3.9 Functions ]]
Game = {
GetStage = function()
@@ -103,118 +67,12 @@ function GetRealInverse()
return res/theme
end
function Actor:Real()
-- scale back down to real pixels.
self:basezoom(GetReal())
-- don't make this ugly
self:SetTextureFiltering(false)
end
-- Scale things back up after they have already been scaled down.
function Actor:RealInverse()
-- scale back up to theme resolution
self:basezoom(GetRealInverse())
self:SetTextureFiltering(true)
end
--[[ Actor commands ]]
function Actor:CenterX()
self:x(SCREEN_CENTER_X)
end
function Actor:CenterY()
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
function PositionPerPlayer(player, p1X, p2X)
return player == PLAYER_1 and p1X or p2X
end
-- MaskSource([clearzbuffer])
-- Sets an actor up as the source for a mask. Clears zBuffer by default.
function Actor:MaskSource(noclear)
if noclear == true then
self:clearzbuffer(true)
end
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
-- Thump()
-- A customized version of pulse that is more appealing for on-beat
-- effects;
function Actor:thump(fEffectPeriod)
self:pulse()
if fEffectPeriod ~= nil then
self:effecttiming(0,0,0.75*fEffectPeriod,0.25*fEffectPeriod)
else
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
-- Heartbeat()
-- A customized version of pulse that is more appealing for on-beat
-- effects;
function Actor:heartbeat(fEffectPeriod)
self:pulse()
if fEffectPeriod ~= nil then
self:effecttiming(0,0.125*fEffectPeriod,0.125*fEffectPeriod,0.75*fEffectPeriod);
else
self:effecttiming(0,0.125,0.125,0.75);
end
self:effecmagnitude(1,1.125,1)
end
--[[ BitmapText commands ]]
-- PixelFont()
-- An alias that turns off texture filtering.
-- Named because it works best with pixel fonts.
function BitmapText:PixelFont()
self:SetTextureFiltering(false)
end
-- Stroke(color)
-- Sets the text's stroke color.
function BitmapText:Stroke(c)
self:strokecolor( c )
end
-- NoStroke()
-- Removes any stroke.
function BitmapText:NoStroke()
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
-- DiffuseAndStroke(diffuse,stroke)
-- Set diffuse and stroke at the same time.
function BitmapText:DiffuseAndStroke(diffuseC,strokeC)
self:diffuse(diffuseC)
self:strokecolor(strokeC)
end;
--[[ end BitmapText commands ]]
--[[ ----------------------------------------------------------------------- ]]
--[[ profile stuff ]]
@@ -31,6 +31,7 @@ ThemeInfo is documented at http://kki.ajworld.net/wiki/ThemeInfo.lua
After that's set up, read the docs.
]]
-- xxx: DON'T WRITE TO DATA!
local PrefPath = "Data/UserPrefs/".. THEME:GetThemeDisplayName() .."/"
--[[ begin internal stuff; no need to edit below this line. ]]
-32
View File
@@ -1,32 +0,0 @@
-- fileutils: quick and dirty, not user prefs oriented file io
File = {
Write = function(path,buf)
local f = RageFileUtil.CreateRageFile()
if f:Open(path, 2) then
f:Write( tostring(buf) )
f:destroy()
return true
else
Trace( "[FileUtils] Error writing to ".. path ..": ".. f:GetError() )
f:ClearError()
f:destroy()
return false
end
end,
Read = function(path)
local f = RageFileUtil.CreateRageFile()
local ret = ""
if f:Open(path, 1) then
ret = tostring( f:Read() )
f:destroy()
return ret
else
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.
@@ -9,16 +9,6 @@ AspectRatios = {
EightThree = 2.66666 -- 1280x480 (two monitors)
}
function IsUsingWideScreen()
return GetScreenAspectRatio() >= AspectRatios.SixteenTen
end
function IsUsingTwoScreens()
return GetScreenAspectRatio() == AspectRatios.EightThree
end
function WideScale(AR4_3, AR16_9)
return scale( SCREEN_WIDTH, 640, 854, AR4_3, AR16_9 )
end
-- take and use it as you like, I don't care -aj
end