diff --git a/.hgignore b/.hgignore index a530b0abb6..61c47b6743 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,10 @@ tests/*.err *.suo *.obj *.app +*.dep +*.idb +*.pdb +*.exp .hg .hgignore .hgtags @@ -16,17 +20,29 @@ tests/*.err .DS_Store Thumbs.db *.pbxuser +*.user *.mode1v3 *.exe *.vdi PBProject/build Xcode/build +src/build-* +src/Release-* +src/libtomcrypt/build-* +src/libtomcrypt/Release-* +src/libtommath/build-* +src/libtommath/Release-* ver.cpp lib*_link.a Data/UserPrefs PBProject/Hardware.plist Themes/pump Themes/optical-release +src/version.bin +src/verstub.cpp +nsis_strings_temp.inc +Data/SpeedMods.txt syntax: regexp .*\#.*\#$ +glob:Cache/Banners/AdditionalSongs_Airspace Preview_Derailed_Derailed bn.png diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index 11b1874a5c..4c66657a84 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -1,7 +1,7 @@ sm-ssc Changelog ________________________________________________________________________________ -The sm-ssc changelog mainly deals with source code-related changes, as theme -changes happen at a rapid pace. +The sm-ssc changelog mostly deals with source code-related changes, +as theme changes happen at a rapid pace. Changes are grouped by date. Not all changes are documented, for various reasons. @@ -9,6 +9,89 @@ Not all changes are documented, for various reasons. supported but exist anyways.) _____________________________________________________________________________ +================================================================================ +sm-ssc v1.2 | 201012xx +-------------------------------------------------------------------------------- + +20101218 +-------- +* [MusicWheelItem] Add OverPart. [freem] +* [Profile] SetCharacter(sCharID) Lua binding added. [freem] +* [GameState] GetCharacter(PlayerNumber) and SetCharacter(PlayerNumber,sCharID) + Lua bindings added. [freem] + +20101217 +-------- +* [Sprite] Added SetAllStateDelays(fDelay) Lua binding. [freem] +* [MusicWheelItem] Added metric commands to NormalPart/ColorPart. [freem] + +20101215 +-------- +* Transplanted file download code from SM4 into sm-ssc. + sm-ssc can now handle the stepmania:// url protocol. [Chris Danford, freem] + +20101214 +-------- +* [RollingNumbers] Added Load(sMetricsGroup) Lua binding. [freem] +* Modifications to pump mode spacing. [Daisuke Master] +* Add eval song data for songs with no banner. [Midiman] + +20101213 +-------- +* [EditMenu] Enable the EditMenu to be themed more extensively. [freem] + Splits out the rows into Label and Value. + +20101212 +-------- +* [MusicWheelItem] Gave NormalPart/ColorPart names, so metrics can be used to + manipulate them. [freem] +* [MusicWheelItem] add Color param to SetMessage. [freem] +* Added --with-sse2 configure flag for SSE2 heuristic optimizations. [vyhd] +* Added 03 IniFile to start building new userprefs/themeprefs API. [vyhd] +* [EditMenu] Converted old non-specific metrics to more specific metrics. [freem] + {Metric Changes} + SongBannerWidth,SongBannerHeight -> SongBannerOnCommand + GroupBannerWidth,GroupBannerHeight -> GroupBannerOnCommand + RowLabelsX -> Label#X + RowLabelOnCommand -> Label#OnCommand + RowValue#X -> Value#X + RowValueOnCommand -> Row#OnCommand + {Metric Additions} + SongBannerChangeCommand/GroupBannerChangeCommand - runs when song/group + banner is changed. + Label#GainFocus/LoseFocusCommand and Value#GainFocus/LoseFocusCommand - runs + when the Label and Value gain/lose focus. + +20101128 +-------- +* Increased default scrolling speed. Modifies how the speed mods work. [shakesoda] + +================================================================================ +sm-ssc v1.1 | 20101120 +-------------------------------------------------------------------------------- + +20100929 +-------- +* Fix issues with RequireStepOnHoldHeads not working properly if the W5 + window is zero. [FSX] + +20100925 +-------- +* Add SetScore Lua binding to PlayerStageStats. [FSX] +* Don't increase combo on AvoidMine if AvoidMineIncrementsCombo is false. [FSX] +* Change build.sh to use ffmpeg 0.6 under Linux. [FSX] + +20100913 +-------- +* Attempt to fix issues with full combos occuring when checkpoints + have been missed. [FSX] +* Fix NotesLoaderKSF. [Daisuke Master] + +20100912 +-------- +* Add a hack allowing all courses to play, regardless of missing noteskins [wolfman2000] +* Restore ITG behavior, allow survivals to be won. [wolfman2000] + ================================================================================ sm-ssc v1.0 "final" | 20100910 -------------------------------------------------------------------------------- diff --git a/Docs/credits.txt b/Docs/credits.txt index 7402af5a9c..34f00fff58 100644 --- a/Docs/credits.txt +++ b/Docs/credits.txt @@ -6,8 +6,10 @@ sm-ssc credits (in no particular order) ==the spinal shark collective== AJ Kelly * Main programming - * UserPreferences and some other scripts - * small theme edits here and there + * UserPreferences and some other Lua scripts + * Some small theme edits here and there + * Noteskins (retro, retrobar*) + * Windows project file maintainer Midiman * Did most of the work on _fallback and default themes @@ -16,8 +18,35 @@ Midiman shakesoda * Programming - * Noteskins (kb7 default) + * Noteskins (delta, gamma, port of orbital to kb7) * Theme edits + * Mac OS X primary maintainer + +==sm-ssc Team== +(in no particular order) + +Aldo_MX + * Code (Pump it Up delays, among others), ideas, and support. + +cerbo + * [SongManager] SetPreferredSongs() and SetPreferredCourses() Lua bindings + +Daisuke Master + * Programming + * Pump/simple and Pump/complex noteskins + * /Docs/Themerdocs/Noteskin elements Reference.txt + * Taking advantage of sm-ssc's new features :) + +FSX + * Various fixes. (see Changelog_sm-ssc.txt for more details) + +Nicole Reid (okeeblow) + * Tested building sm-ssc on FreeBSD, provided fixes. + +Wolfman + * [Player] PercentUntilColorCombo metric + * Mac OS X maintainer + * Various fixes/changes. (see Changelog_sm-ssc.txt for more details) ==other contributors== (in no particular order, aside from having SM team at the top) @@ -26,21 +55,6 @@ StepMania Team * Keeping StepMania 5 alive with changes, and providing a nice codebase for us to work with. -Aldo_MX - * Code (Pump it Up delays, among others), ideas, and support. - -Nicole Reid (okeeblow) - * Tested building sm-ssc on FreeBSD, provided fixes. - -Wolfman - * [Player] PercentUntilColorCombo metric - -Daisuke Master - * Programming - * Pump/simple and Pump/complex noteskins - * /Docs/Themerdocs/Noteskin elements Reference.txt - * Taking advantage of sm-ssc's new features :) - Kaox * Pump/default noteskin @@ -74,11 +88,6 @@ galopin * Pump it Up Exceed PlayStation 2 USB dance mat support patch (stepmania-devs mailing list 20091213 11:27 -0800 [Pacific Standard Time]) -FSX - * [Player] ScoreMissedHoldsAndRolls metric - * [ScoreKeeperNormal] Patch for fixing "the" combo bug (untested) - (http://www.pastie.org/868201.txt) - Henke37 * [MovieTexture_FFMpeg] Stutter fix (http://www.pasteall.org/11353/diff) @@ -97,9 +106,6 @@ juanelote * [SongManager] GetSongGroupByIndex function * [MusicWheel] JumpToNextGroup/JumpToPrevGroup logic modifications -cerbo - * [SongManager] SetPreferredSongs() and SetPreferredCourses() Lua bindings - ==the beta testers== [SSC Beta Testing Team] KeithD diff --git a/NoteSkins/dance/midi-note/metrics.ini b/NoteSkins/dance/midi-note/metrics.ini index b946fe4351..01e819ab51 100644 --- a/NoteSkins/dance/midi-note/metrics.ini +++ b/NoteSkins/dance/midi-note/metrics.ini @@ -62,8 +62,8 @@ LetGoCommand=blend,'BlendMode_Add'; HeldCommand=blend,'BlendMode_Add';diffuse,1.0,1.0,0.3,0.875;zoom,1;linear,0.06;zoom,1.1;linear,0.06;diffusealpha,0 [HoldGhostArrow] -HoldingOnCommand=hidden,0 -HoldingOffCommand=hidden,1 +HoldingOnCommand=visible,true +HoldingOffCommand=visible,false [ReceptorArrow] W3Command=stoptweening;zoom,0.85;linear,0.12;zoom,1 diff --git a/NoteSkins/dance/midi-vivid/metrics.ini b/NoteSkins/dance/midi-vivid/metrics.ini index 546925f391..048ebc42b4 100644 --- a/NoteSkins/dance/midi-vivid/metrics.ini +++ b/NoteSkins/dance/midi-vivid/metrics.ini @@ -65,8 +65,8 @@ LetGoCommand=blend,'BlendMode_Add'; HeldCommand=blend,'BlendMode_Add';diffuse,1.0,1.0,0.3,0.875;zoom,1;linear,0.06;zoom,1.1;linear,0.06;diffusealpha,0 [HoldGhostArrow] -HoldingOnCommand=hidden,0 -HoldingOffCommand=hidden,1 +HoldingOnCommand=visible,true +HoldingOffCommand=visible,false [ReceptorArrow] W3Command=stoptweening;zoom,1.15;linear,0.12;zoom,1 diff --git a/NoteSkins/kb7/orbital/Noteskin.lua b/NoteSkins/kb7/orbital/Noteskin.lua index 5bc5858515..cc47a8f0ed 100644 --- a/NoteSkins/kb7/orbital/Noteskin.lua +++ b/NoteSkins/kb7/orbital/Noteskin.lua @@ -9,12 +9,12 @@ Noteskin.ElementRedirs = { -- button redirs (since this is a bar noteskin, it's all the same) Noteskin.ButtonRedirs = { -- dance - Left = "Bar"; - UpLeft = "Bar"; - Up = "Bar"; - Down = "Bar"; - UpRight = "Bar"; - Right = "Bar"; + Left = "Red"; + UpLeft = "Red"; + Up = "Red"; + Down = "Red"; + UpRight = "Red"; + Right = "Red"; -- kb7 Key1 = "Red"; Key2 = "Red"; diff --git a/Themes/_fallback/Fonts/ScreenInstallOverlay status.redir b/Themes/_fallback/Fonts/ScreenInstallOverlay status.redir new file mode 100644 index 0000000000..5c6053f7f1 --- /dev/null +++ b/Themes/_fallback/Fonts/ScreenInstallOverlay status.redir @@ -0,0 +1 @@ +Common Normal \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Course OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Course OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Course OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Mode OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Mode OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Mode OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Portal OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Portal OverPart.redir new file mode 100644 index 0000000000..c94ae9b2f3 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Portal OverPart.redir @@ -0,0 +1 @@ +MusicWheelItem Roulette NormalPart \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Random OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Random OverPart.redir new file mode 100644 index 0000000000..c94ae9b2f3 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Random OverPart.redir @@ -0,0 +1 @@ +MusicWheelItem Roulette NormalPart \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Roulette OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Roulette OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Roulette OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem SectionCollapsed OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem SectionCollapsed OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem SectionCollapsed OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem SectionExpanded OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem SectionExpanded OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem SectionExpanded OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Song OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Song OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Song OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Graphics/MusicWheelItem Sort OverPart.redir b/Themes/_fallback/Graphics/MusicWheelItem Sort OverPart.redir new file mode 100644 index 0000000000..04b2ead777 --- /dev/null +++ b/Themes/_fallback/Graphics/MusicWheelItem Sort OverPart.redir @@ -0,0 +1 @@ +_blank \ No newline at end of file diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index b06c3d07ef..b7ea3a02cc 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -51,12 +51,12 @@ Nightmare=Nightmare HalfDouble=Half-Double [CourseDifficulty] -Beginner=BEGINNER -Challenge=CHALLENGE -Hard=DIFFICULT -Easy=EASY -Edit=EDIT -Medium=REGULAR +Beginner=Novice +Challenge=Expert +Hard=Hard +Easy=Easy +Edit=Edit +Medium=Medium [CourseEntryType] Best=Players' Best @@ -291,7 +291,7 @@ Not Supported=Mode not supported while networked. 192nd=192nd [OptionExplanations] -Accel=Accel +Accel=Accelerate, Decelerate or otherwise adjust the arrow speed. AllowExtraStage=When enabled (and Event Mode isn't on), allows the player to earn extra stages after completing certain requirements. AllowW1=Enable or disable fantastic judgement. NEVER - never show Fantastic, COURSES ONLY - only during nonstop/oni modes, ALWAYS - all modes of play. Announcer=Choose from this list of installed announcer packs. @@ -557,8 +557,8 @@ Boost=Boost Both=Both Brake=Brake Bumpy=Bumpy -C200=C200 -C400=C400 +C150=C150 +C300=C300 CPU-Controlled=CPU-Controlled Centered=Centered Choose=Choose @@ -692,6 +692,7 @@ Silent=Silent Skip=Skip Skippy=Skippy Slow=Slow +SN2=Supernova 2 SongAttacks=Song Attacks Song BGAnimation=Song BGAnimation Song Bitmap=Song Bitmap diff --git a/Themes/_fallback/Scripts/03 CustomSpeedMods.lua b/Themes/_fallback/Scripts/03 CustomSpeedMods.lua index 2b7db89960..3b0a905e6f 100644 --- a/Themes/_fallback/Scripts/03 CustomSpeedMods.lua +++ b/Themes/_fallback/Scripts/03 CustomSpeedMods.lua @@ -68,7 +68,7 @@ local function ParseSpeedModFile(path) 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" + local fallbackString = "0.5x,0.75x,1x,1.75x,2x,2.25x,2.5x,C150,C300" Trace("[CustomSpeedMods]: Could not read SpeedMods; writing fallback to "..path) file:Open(path, 2) file:Write(fallbackString) diff --git a/Themes/_fallback/Scripts/03 GamePreferences.lua b/Themes/_fallback/Scripts/03 GamePreferences.lua new file mode 100644 index 0000000000..20464feb7f --- /dev/null +++ b/Themes/_fallback/Scripts/03 GamePreferences.lua @@ -0,0 +1,147 @@ +-- GamePreferences: Clone of AJ's User Preferences "Module" +-- Written by AJ Kelly of KKI Labs / Version 2.11-ssc +-- (modified slightly for Cerulean Skies 2's disregard of the name of the +-- themeinfo variable lol :p) + +--[[ +the first released version was broken. +this version aims to be simpler, and therefore work. + +[changelog] + +v2.11-ssc + Remove EnvUtils references; we have it in sm-ssc. + +v2.1-ssc + sm-ssc version of UserPrefs. We can now assume players have certain + functionality, like RageFile:GetError(). + +v2.1 + Added type specific GetUserPref functions. + +[usage] +First, edit PrefPath to match your theme. +If you use ThemeInfo, then you shouldn't have to edit this. + +If you're not using ThemeInfo, then you can replace + +".. themeInfo.Name .." with the theme's folder name. + +ThemeInfo is documented at http://kki.ajworld.net/wiki/ThemeInfo.lua + +After that's set up, read the docs. +]] +local PrefPath = "Data/GamePrefs/" + +--[[ 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 + +function ReadGamePrefFromFile(name) + 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 + else + local fError = f:GetError() + Trace( "[FileUtils] Error reading ".. fullFilename ..": ".. fError ) + f:ClearError() + f:destroy() + return nil + end +end + +function WriteGamePrefToFile(name,value) + local f = RageFileUtil.CreateRageFile() + local fullFilename = PrefPath..name..".cfg" + + if f:Open(fullFilename, 2) then + 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 + + f:destroy() + return true +end + +--[[ end internal functions; still don't edit below this line ]] + +function GetGamePref(name) + return ReadGamePrefFromFile(name) +end + +function SetGamePref(name,value) + return WriteGamePrefToFile(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 +-- other themers would too. + +-- GetUserPrefB: boolean +function GetGamePrefB(name) + -- this one is a bit trickier. + local pref = ReadGamePrefFromFile(name) + + if type(pref) == "string" then + pref = string.lower(pref) + if pref == "true" or cmp == "t" then + return true + elseif pref == "false" or cmp == "f" then + return false + else + 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 + + else + return true + end + end +end + +-- GetUserPrefC: color +function GetGamePrefC(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( ReadGamePrefFromFile(name) ) +end + +-- GetUserPrefN: numbers (integers, floats) +function GetGamePrefN(name) + return tonumber( ReadGamePrefFromFile(name) ) +end + +--[[ +Copyright © 2008-2009 AJ Kelly/KKI Labs +All rights reserved. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +]] \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 IniFile.lua b/Themes/_fallback/Scripts/03 IniFile.lua new file mode 100644 index 0000000000..2bad1403db --- /dev/null +++ b/Themes/_fallback/Scripts/03 IniFile.lua @@ -0,0 +1,119 @@ +--[[ +IniFile: basically a Lua rewrite of SM's IniFile class that serves as the +basis for the sm-ssc UserPrefs and ThemePrefs configuration systems. +Note that this is a namespace, not a class per se. +--]] + +-- TODO: move this into a more general section +-- func takes a key and a value +function foreach_ordered( tbl, func ) + local keys = { } + for k,_ in pairs(tbl) do keys[#keys+1] = k end + + table.sort( keys ) + + -- iterate in sorted order + for _,key in ipairs(keys) do func( key, tbl[key]) end +end + +-- redeclared here for my sanity's sake +-- TODO: declare these as global variables +local RageFile = +{ + READ = 1, + WRITE = 2, + STREAMED = 4, + SLOW_FLUSH = 8 +} + +-- IniFile namespace +IniFile = +{ + StrToKeyVal = function( str ) + local _, _, key, value = str:find( "(.+)=(.*)" ) + + -- key is always a string, but value may be num, bool, or nil. + -- do a few quick checks to see which one it is. + + -- if it's a nil, convert it to an empty string and return + if value == nil then value = ""; return key, value; end + + -- if it's a number, convert it in place and return + if tonumber(value) ~= nil then value = tonumber(value); return key, value; end + + -- not a number, so let's try a boolean value + if value == "true" then value = true; + elseif value == "false" then value = false; + end + + return key, value + end, + + ReadFile = function( file_path ) + Trace( "IniFile.ReadFile( " .. file_path .. " )" ) + local file = RageFileUtil.CreateRageFile() + + if not file:Open(file_path, RageFile.READ) then + Warn( string.format("ReadFile(%s): %s",file_path,file:GetError()) ) + file:destroy() + return { } -- return a blank table + end + + local tbl = { } + local current = tbl + + while not file:AtEOF() do + local str = file:GetLine() + + -- is this a section? + local _, _, sec = str:find( "%[(.+)%]" ) + + -- if so, set focus there; otherwise, try to + -- read a key/value pair (ignore blank lines) + if sec then + -- if this section doesn't exist, create it + tbl[sec] = tbl[sec] and tbl[sec] or { } + current = tbl[sec] + Warn( "Switching section to " .. sec ) + else + local k, v = IniFile.StrToKeyVal( str ) + if k and v then current[k] = v end + end + end + + file:Close() + file:destroy() + + return tbl + end, + + WriteFile = function( file_path, tbl ) + Trace( "IniFile.WriteFile( " .. file_path .. " )" ) + local file = RageFileUtil.CreateRageFile() + + if not file:Open(file_path, RageFile.WRITE) then + Warn( string.format("WriteFile(%s): %s",file_path.file:GetError()) ) + file:destroy() + return false + end + + -- declare functions so we can write with foreach_ordered + local function put_pair( k, v ) + file:PutLine( string.format("%s=%s", k, tostring(v)) ) + end + + local function put_section( section, pair ) + file:PutLine( "[" .. section .. "]" ) + foreach_ordered( pair, put_pair ) + file:PutLine("") -- put a blank line between sections + end + + -- each base key is a section and its value is a + -- table of key-value pairs under that section. + foreach_ordered( tbl, put_section ) + + file:Close() + file:destroy() + return true + end +}; diff --git a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua index 1f168df8e5..800303f672 100644 --- a/Themes/_fallback/Scripts/03 ProductivityHelpers.lua +++ b/Themes/_fallback/Scripts/03 ProductivityHelpers.lua @@ -63,7 +63,12 @@ Condition = { return GAMESTATE:PlayerIsUsingModifier( pnPlayer, sModifier ); end, } - +--[[ 3.9 Functions ]] +Game = { + GetStage = function() + + end, +} --[[ Aliases ]] -- Blend Modes @@ -236,5 +241,12 @@ function pname(pn) return ToEnumShortString(pn) end +function math.round(num, pre) + if pre and pre < 0 then pre = 0 end + local mult = 10^(pre or 0) + if num >= 0 then return math.floor(num*mult+.5)/mult + else return math.ceil(num*mult-.5)/mult end +end + --[[ end helper functions ]] --- this code is in the public domain. \ No newline at end of file +-- this code is in the public domain. diff --git a/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua b/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua new file mode 100644 index 0000000000..69a2c161b7 --- /dev/null +++ b/Themes/_fallback/Scripts/03 ThemeAndGamePrefs.lua @@ -0,0 +1,502 @@ +-- sm-ssc Default Theme Preferences Handler +function InitGamePrefs() + local Prefs = + { + { "AutoSetStyle", false }, + { "NotePosition", true }, + { "ComboOnRolls", false }, + { "ComboUnderField", true }, + { "AdjustSpeed", false }, + }; + + for idx,pref in ipairs(Prefs) do + if GetGamePrefB( pref[1] ) == nil then + SetGamePref( pref[1], pref[2] ); + end; + end; +end +function InitUserPrefs() + if GetUserPrefB("UserPrefShowLotsaOptions") == nil then + SetUserPref("UserPrefShowLotsaOptions", true); + end; + + local Prefs = + { + { "UserPrefGameplayShowStepsDisplay", true }, + { "UserPrefGameplayShowScore", false}, +--[[ { "ProTimingP1", false}, + { "ProTimingP2", false}, +--]] + }; + + local BPrefs = + { + { "UserPrefShowLotsaOptions", true}, + { "UserPrefLongFail", false}, + { "UserPrefProtimingP1", false}, + { "UserPrefProtimingP2", false}, + { "FlashyCombos", false}, + }; + + for idx,pref in ipairs(Prefs) do + if GetUserPref( pref[1] ) == nil then + SetUserPref( pref[1], pref[2] ); + end; + end; + + -- making sure I don't screw up anything yet... + for idx,pref in ipairs(BPrefs) do + if GetUserPrefB( pref[1] ) == nil then + SetUserPref( pref[1], pref[2] ); + end; + end; + +end; +--[[ theme option rows ]] +-- screen cover +function GetProTiming(pn) + local pname = ToEnumShortString(pn); + if GetUserPref("ProTiming"..pname) then + return GetUserPrefB("ProTiming"..pname); + else + SetUserPref("ProTiming"..pname,false); + return false; + end; +end; +function OptionRowProTiming() + local t = { + Name = "ProTiming"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = false; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + local bShow; + if GetUserPrefB("UserPrefProtiming" .. ToEnumShortString(pn) ) then + bShow = GetUserPrefB("UserPrefProtiming" .. ToEnumShortString(pn) ); + if bShow then + list[2] = true; + else + list[1] = true; + end + else + list[1] = true; + end; +--[[ local pname = ToEnumShortString(pn); + + if getenv("ProTiming"..pname) == true then + list[2] = true; + else + list[1] = true; + end; --]] + end; + SaveSelections = function(self, list, pn) + local bSave; + if list[2] then + bSave = true; + else + bSave = false; + end; + SetUserPref("UserPrefProtiming" .. ToEnumShortString(pn),bSave); +--[[ local val; + if list[2] then + val = true; + else + val = false; + end; + local pname = ToEnumShortString(pn); + setenv("ProTiming"..pname, val); --]] + end; + }; + setmetatable( t, t ); + return t; +end; + +function UserPrefGameplayShowScore() + local t = { + Name = "UserPrefGameplayShowScore"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefGameplayShowScore") ~= nil then + if GetUserPrefB("UserPrefGameplayShowScore") then + list[2] = true; + else + list[1] = true; + end; + else + WritePrefToFile("UserPrefGameplayShowScore",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefGameplayShowScore",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end + +function UserPrefGameplayShowStepsDisplay() + local t = { + Name = "UserPrefGameplayShowStepsDisplay"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefGameplayShowStepsDisplay") ~= nil then + if GetUserPrefB("UserPrefGameplayShowStepsDisplay") then + list[2] = true; + else + list[1] = true; + end; + else + WritePrefToFile("UserPrefGameplayShowStepsDisplay",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefGameplayShowStepsDisplay",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end + +function UserPrefShowLotsaOptions() + local t = { + Name = "UserPrefShowLotsaOptions"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Many','Few' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefShowLotsaOptions") ~= nil then + if GetUserPrefB("UserPrefShowLotsaOptions") then + list[1] = true; + else + list[2] = true; + end; + else + WritePrefToFile("UserPrefShowLotsaOptions",false); + list[2] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[1] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefShowLotsaOptions",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end + +function GetDefaultOptionLines() + local LineSets = { + "1,8,14,2,3,4,5,6,R,7,9,10,11,12,13,15,16,17,18", -- All + "1,8,14,2,7,13,16,17,18", -- DDR Essentials ( no turns, fx ) + }; + local function IsExtra() + if GAMESTATE:IsExtraStage() or GAMESTATE:IsExtraStage2() then + return true + else + return false + end + end + if not IsExtra() then + if GetUserPrefB("UserPrefShowLotsaOptions") then + return GetUserPrefB("UserPrefShowLotsaOptions") and LineSets[1] or LineSets[2]; + else + return LineSets[2]; -- Just make sure! + end + else + return "1,8,14,2,7,13,16,17,18" -- "failsafe" list + end +end; +function UserPrefLongFail() + local t = { + Name = "UserPrefLongFail"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Short','Long' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefLongFail") ~= nil then + if GetUserPrefB("UserPrefLongFail") then + list[2] = true; + else + list[1] = true; + end; + else + WritePrefToFile("UserPrefLongFail",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefLongFail",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +function UserPrefFlashyCombo() + local t = { + Name = "UserPrefFlashyCombo"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefFlashyCombo") ~= nil then + if GetUserPrefB("UserPrefFlashyCombo") then + list[2] = true; + else + list[1] = true; + end; + else + WritePrefToFile("UserPrefFlashyCombo",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefFlashyCombo",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +--[[ end themeoption rows ]] + +--[[ game option rows ]] +function GamePrefComboOnRolls() + local t = { + Name = "GamePrefComboOnRolls"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("ComboOnRolls") ~= nil then + if GetGamePrefB("ComboOnRolls") then + list[2] = true; + else + list[1] = true; + end; + else + WriteGamePrefToFile("ComboOnRolls",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WriteGamePrefToFile("ComboOnRolls",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +function GamePrefComboUnderField() + local t = { + Name = "GamePrefComboUnderField"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("ComboUnderField") ~= nil then + if GetGamePrefB("ComboUnderField") then + list[2] = true; + else + list[1] = true; + end; + else + WriteGamePrefToFile("ComboUnderField",true); + list[2] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WriteGamePrefToFile("ComboUnderField",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end + +function GetDefaultArrowSpacing() + local rates = { + 64, -- Default + 80, -- Pro + 128, -- New + }; + return GetGamePrefB("AdjustSpeed") and rates[3] or rates[1]; +end; +function GamePrefAdjustSpeed() + local t = { + Name = "GamePrefAdjustSpeed"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Normal','Fast' }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("AdjustSpeed") ~= nil then + if GetGamePrefB("AdjustSpeed") then + list[2] = true; + else + list[1] = true; + end; + else + WriteGamePrefToFile("AdjustSpeed",true); + list[2] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WriteGamePrefToFile("AdjustSpeed",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +function GamePrefAutoSetStyle() + local t = { + Name = "GamePrefAutoSetStyle"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Off','On' }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("AutoSetStyle") ~= nil then + if GetGamePrefB("AutoSetStyle") then + list[2] = true; + else + list[1] = true; + end; + else + WriteGamePrefToFile("AutoSetStyle",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WriteGamePrefToFile("AutoSetStyle",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +function GamePrefNotePosition() + local t = { + Name = "GamePrefNotePosition"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Normal','Lower' }; + LoadSelections = function(self, list, pn) + if ReadGamePrefFromFile("NotePosition") ~= nil then + if GetGamePrefB("NotePosition") then + list[1] = true; + else + list[2] = true; + end; + else + WriteGamePrefToFile("NotePosition",false); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[1] then + val = true; + else + val = false; + end; + WriteGamePrefToFile("NotePosition",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end diff --git a/Themes/_fallback/Scripts/03 ThemeLibrary.lua b/Themes/_fallback/Scripts/03 ThemeLibrary.lua new file mode 100644 index 0000000000..c1974c4479 --- /dev/null +++ b/Themes/_fallback/Scripts/03 ThemeLibrary.lua @@ -0,0 +1,42 @@ +-- theme library: juicy library that returns lua objects on demand. + +Library = { + GrooveRadar = function(self) + local function radarSet(self,player) + local selection = nil; + if GAMESTATE:IsCourseMode() then + if GAMESTATE:GetCurrentCourse() then + selection = GAMESTATE:GetCurrentTrail(player); + end; + else + if GAMESTATE:GetCurrentSong() then + selection = GAMESTATE:GetCurrentSteps(player); + end; + end; + if selection then + self:SetFromRadarValues(player, selection:GetRadarValues(player)); + else + self:SetEmpty(player); + end; + end + -- + local t = Def.ActorFrame { + Name="Radar"; + Def.GrooveRadar { + OnCommand=cmd(zoom,0;sleep,0.583;decelerate,0.150;zoom,1); + OffCommand=cmd(sleep,0.183;decelerate,0.167;zoom,0); + CurrentSongChangedMessageCommand=function(self) + for pn in ivalues(GAMESTATE:GetHumanPlayers()) do + radarSet(self, pn); + end; + end; + CurrentStepsP1ChangedMessageCommand=function(self) radarSet(self, PLAYER_1); end; + CurrentStepsP2ChangedMessageCommand=function(self) radarSet(self, PLAYER_2); end; + CurrentTrailP1ChangedMessageCommand=function(self) radarSet(self, PLAYER_1); end; + CurrentTrailP2ChangedMessageCommand=function(self) radarSet(self, PLAYER_2); end; + }; + }; + + return t; + end; +} \ No newline at end of file diff --git a/Themes/_fallback/Scripts/03 ThemePrefs.lua b/Themes/_fallback/Scripts/03 ThemePrefs.lua new file mode 100644 index 0000000000..0bf146e460 --- /dev/null +++ b/Themes/_fallback/Scripts/03 ThemePrefs.lua @@ -0,0 +1,134 @@ +--[[ +ThemePrefs: handles the underlying structure for ThemePrefs, so any themes +built off of this can simply declare their prefs and default values, and +access them through this system. + +v0.7: Dec. 15, 2010. Initial version. +--]] + +-- If we don't have IniFile, we can't read to or write from disk +if not IniFile then + Warn( "ThemePrefs: IniFile missing. Can't read/write from disk :(" ) +end + +function PrintTable( tbl ) + Trace( "Printing table" ) + for k,v in pairs(tbl) do + Trace( ("[%s] -> %s"):format(tostring(k),tostring(v)) ) + end +end + +local ThemePrefsPath = "Save/ThemePrefs.ini"; +local FallbackTheme = "_fallback"; + +-- This will be set on load. +local PrefsTable = nil; + +-- Gets the name of the current theme using themeInfo +-- if available and the ThemeManager name otherwise. +local function GetThemeName() + return themeInfo and themeInfo.Name or THEME:GetThemeDisplayName() +end + +-- Given a preference name, returns the table it's in. Checks the current +-- theme first, then _fallback, then all other sections, in that order. +local function ResolveTable( pref ) + -- check the section for this theme + local name = GetThemeName() + local val = PrefsTable[name][pref] + + if val ~= nil then + Trace( ("ResolveTable(%s): found in %s"):format(pref,name) ) + return PrefsTable[name] + end + + -- not in the current theme; check the fallback if it exists + if PrefsTable[FallbackTheme] then + val = PrefsTable[FallbackTheme][pref] + if val ~= nil then + Trace( ("ResolveTable(%s): found in fallback"):format(pref) ) + return PrefsTable[FallbackTheme] + end + end + + -- not there either. check every section. + -- XXX: we should do this less redundantly. + for section, _ in pairs(PrefsTable) do + val = PrefsTable[section][pref] + if val ~= nil then + Trace( ("ResolveTable(%s): found in section %s"):format(pref,section) ) + return PrefsTable[section] end + end + + -- not found at all + Trace( ("ResolveTable(%s): pref not found"):format(pref) ) + return nil +end + +ThemePrefs = +{ + NeedsSaved = false, + + -- Loads preferences from Save/ThemePrefs.ini, then adds theme + -- preferences (and default values if applicable) to PrefsTable. + -- Only read from disk once, when _fallback calls this; we just + -- need the base set once to add prefs onto. + Init = function( prefs, bLoadFromDisk ) + Trace( ("ThemePrefs.Init(prefs, %s)"):format(tostring(bLoadFromDisk)) ) + if bLoadFromDisk then + Trace( "ThemePrefs.Init: loading from disk" ) + if not ThemePrefs.Load() then return false end + end + + Trace( "ThemePrefs.Init: not loading from disk" ) + + -- create the section if it doesn't exist + local name = GetThemeName() + PrefsTable[name] = PrefsTable[name] and PrefsTable[name] or { } + + Trace( "Using section " .. name ) + + -- if the key doesn't exist, add it with our default value + for k, tbl in pairs(prefs) do + if not PrefsTable[name][k] then + Trace( k .. " doesn't exist, creating" ) + PrefsTable[name][k] = tbl.Default + end + end + + PrintTable( PrefsTable[name] ) + end, + + Load = function() + if not IniFile then return false end + PrefsTable = IniFile.ReadFile( ThemePrefsPath ) + return true + end, + + Save = function() + Trace( "ThemePrefs.Save" ) + if not IniFile then return false end + if not NeedsSaved then return end + NeedsSaved = false + IniFile.WriteFile( ThemePrefsPath, PrefsTable ) + end, + + Get = function( name ) + Trace( ("ThemePrefs.Get(%s)"):format(name) ) + local tbl = ResolveTable(name) + if tbl then return tbl[name] end + Warn( ("GetThemePref: unknown preference \"%s\""):format(name) ) + return nil + end, + + Set = function( name, value ) + Trace( ("ThemePrefs.Set(%s, %s)"):format(name, tostring(value)) ) + local tbl = ResolveTable(name) + if tbl then tbl[name] = value; NeedsSaved = true; return end + Warn( ("SetThemePref: unknown preference \"%s\""):format(name) ) + end, +}; + +-- global aliases +GetThemePref = ThemePrefs.Get +SetThemePref = ThemePrefs.Set diff --git a/Themes/_fallback/Scripts/03 ThemePrefsRows.lua b/Themes/_fallback/Scripts/03 ThemePrefsRows.lua new file mode 100644 index 0000000000..75abf05af8 --- /dev/null +++ b/Themes/_fallback/Scripts/03 ThemePrefsRows.lua @@ -0,0 +1,125 @@ +--[[ +ThemePrefsRows: you give it the choices, values, and params, and it'll +generate the rest; quirky behavior to be outlined below. Documentation +will be provided once this system is stabilized. + +v0.5: Dec. 15, 2010. Initial version. Not very well tested. +--]] + +-- unless overridden, these parameters will be used for the OptionsRow +local DefaultParams = +{ + LayoutType = "ShowAllInRow", + SelectType = "SelectOne", + OneChoiceForAllPlayers = true, + ExportOnChange = false, + EnabledForPlayers = nil, + ReloadRowMessages = nil, + + -- takes a function(self, list, pn); + -- if not used, we use the default + LoadSelections = nil, + SaveSelections = nil, +} + +local function DefaultLoadSelections( pref, default, choices, values ) + return function(self, list, pn) + local val = ThemePrefs.Get( pref ) + + -- if our current value is here, set focus to that + for i=1, #choices do + if values[i] == val then list[i] = true return end + end + + -- try the default value + for i=1, #choices do + if values[i] == default then list[i] = true return end + end + + -- set to the first value and throw a warning + Warn( ("LoadSelections: preference \"%s\"'s default not in Values"):format(pref) ) + list[1] = true + end +end + +local function DefaultSaveSelections( pref, choices, values ) + local msg = "ThemePrefChanged" + local params = { Name = pref } + + return function(self, list, pn) + for i=1, #choices do + if list[i] then ThemePrefs.Set( pref, values[i] ) break end + MESSAGEMAN:Broadcast( msg, params ) + end + end +end + + +local function CreateThemePrefRow( pref, tbl ) + Trace( "CreateThemePrefRow( " .. pref .. " )" ) + + -- can't make an option handler without options + if not tbl.Choices then return nil end + + local Choices = tbl.Choices + local Values = tbl.Values and tbl.Values or Choices + local Params = tbl.Params and tbl.Params or { } + + -- set the name and choices here; we'll do the rest below + local Handler = { Name = pref, Choices = Choices } + + -- add all the keys in DefaultParams, get the value from + -- Params if it exists and DefaultParams otherwise + -- (note that we explicitly check for nil, due to bools.) + for k, _ in pairs(DefaultParams) do + Handler[k] = Params[k] ~= nil and Params[k] or DefaultParams[k] + end + + -- if we don't have LoadSelections and SaveSelections, make them + if not Handler.LoadSelections then + Handler.LoadSelections = DefaultLoadSelections( pref, tbl.Default, Choices, Values ) + end + + if not Handler.SaveSelections then + Handler.SaveSelections = DefaultSaveSelections( pref, Choices, Values ) + end + + return Handler +end + +-- All OptionsRows for preferences are stuck in this table, accessible +-- through GetRow('name') in the namespace or ThemePrefRow('name') in +-- the global namespace. (I like to keep pollution to a minimum.) +local Rows = { } + +ThemePrefsRows = +{ + IsInitted = false, + + Init = function( prefs ) + for pref, tbl in pairs(prefs) do + Rows[pref] = CreateThemePrefRow( pref, tbl ) + end + end, + + GetRow = function( pref ) + Trace( ("GetRow(%s), type %s"):format(pref, type(Rows[pref])) ) + return Rows[pref] + end, + +} + +-- Global namespace alias +ThemePrefRow = ThemePrefsRows.GetRow + +-- UGLY: declare this here, even though it's in the previous namespace, +-- so we can have one call to initialize both systems (ThemePrefsRow is +-- declared after ThemePrefs, so it can't actually be in that file...) + +ThemePrefs.InitAll = function( prefs ) + Trace( "ThemePrefs.InitAll( prefs )" ) + + -- HACK: for now, don't worry about extraneous file I/O + ThemePrefs.Init( prefs, true ) + ThemePrefsRows.Init( prefs ) +end diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index c622a29145..87ccb3e72c 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -25,7 +25,8 @@ ScreenHeight=480 # Allows you to pick all available game modes for your gametype: for example, # inserting enough coins for 1p would let you choose between solo, single # and double before each game -AutoSetStyle=true +# AutoSetStyle=true +AutoSetStyle=GetGamePrefB("AutoSetStyle") # Default modifiers and noteskin. DefaultModifiers="default;1.5x;" DefaultNoteSkinName="default" @@ -44,9 +45,11 @@ FirstAttractScreen="ScreenDemonstration" # First screen that pops up when you start the game. ScreenInit in particular # shows the theme information before going to the title screen. InitialScreen="ScreenInit" +# Music selection screen used after downloading files. +SelectMusicScreen="ScreenSelectMusic" # Screens that show over everything else. you shouldn't worry bout this, since # it wont matter much. -OverlayScreens="ScreenSystemLayer,ScreenSyncOverlay,ScreenStatsOverlay,ScreenDebugOverlay,ScreenConsoleOverlay" +OverlayScreens="ScreenSystemLayer,ScreenSyncOverlay,ScreenStatsOverlay,ScreenDebugOverlay,ScreenConsoleOverlay,ScreenInstallOverlay" # Legacy metric: Percentage Scoring shows this many decimals ( 00.00% ). PercentScoreDecimalPlaces=2 @@ -124,7 +127,7 @@ FrameWidthEffectsMinMultiplier=0.5 FrameWidthEffectsMaxMultiplier=1.2 FrameWidthLockEffectsToOverlapping=false FrameWidthLockEffectsTweenPixels=25 -ArrowSpacing=64 +ArrowSpacing=128 DrawHiddenNotesAfterReceptor=true [Background] @@ -920,7 +923,8 @@ RequireStepOnHoldHeads=HoldHeadStep() RequireStepOnMines=false InitialHoldLife=InitialHoldLife() MaxHoldLife=MaxHoldLife() -RollBodyIncrementsCombo=RollBodyIncrementsCombo() +# RollBodyIncrementsCombo=RollBodyIncrementsCombo() +RollBodyIncrementsCombo=GetGamePrefB("UserPrefComboOnRolls") ScoreMissedHoldsAndRolls=ScoreMissedHoldsAndRolls() PercentUntilColorCombo=0.25 @@ -1256,6 +1260,7 @@ CreditsP2PlayerJoinedMessageCommand=playcommand,"UpdateText"; CreditsP2ScreenChangedMessageCommand=playcommand,"UpdateVisible";queuecommand,"On" CreditsP2OnCommand=horizalign,right;vertalign,bottom;zoom,0.675;shadowlength,1; CreditsP2OffCommand= + [ScreenConsoleOverlay] Class="ScreenSystemLayer" Fallback="ScreenSystemLayer" @@ -1265,6 +1270,15 @@ CreditsP1X=-9999 CreditsP2X=-9999 CreditsP1Y=-9999 CreditsP2Y=-9999 + +[ScreenInstallOverlay] +Class="ScreenInstallOverlay" +Fallback="Screen" + +StatusX=SCREEN_LEFT+40 +StatusY=SCREEN_BOTTOM-32 +StatusOnCommand=align,0,1 + [ScreenSyncOverlay] Class="ScreenSyncOverlay" Fallback="Screen" @@ -2027,12 +2041,12 @@ Speed,2="mod,0.50x;name,x0.50" Speed,3="mod,0.75x;name,x0.75" Speed,4="mod,1x;name,x1" Speed,5="mod,1.5x;name,x1.5" -Speed,6="mod,2x;name,x2" -Speed,7="mod,3x;name,x3" -Speed,8="mod,4x;name,x4" -Speed,9="mod,8x;name,x8" -Speed,10="mod,C200;name,C200" -Speed,11="mod,C400;name,C400" +Speed,6="mod,2x;name,x1.75" +Speed,7="mod,3x;name,x2" +Speed,8="mod,4x;name,x2.25" +Speed,9="mod,8x;name,x2.5" +Speed,10="mod,C150;name,C150" +Speed,11="mod,C300;name,C300" Speed,12="mod,1x,200% randomspeed;name,Random" Accel="5;selectmultiple" @@ -2276,13 +2290,12 @@ BatLives,7="mod,7 lives;name,7" BatLives,8="mod,8 lives;name,8" BatLives,9="mod,9 lives;name,9" BatLives,10="mod,10 lives;name,10" -Fail="5;together" +Fail="4;together" FailDefault="mod,faildefault" -Fail,1="mod,faildefault;name,Default" -Fail,2="mod,failimmediate;name,Immediate" -Fail,3="mod,failimmediatecontinue;name,ImmediateContinue" -Fail,4="mod,failatend;name,FailAtEnd" -Fail,5="mod,failoff;name,Off" +Fail,1="mod,failimmediate;name,Immediate" +Fail,2="mod,failimmediatecontinue;name,ImmediateContinue" +Fail,3="mod,failatend;name,FailAtEnd" +Fail,4="mod,failoff;name,Off" Assist="4;together" AssistDefault="" Assist,1="mod,no clap,no metronome;name,Off" @@ -3335,37 +3348,30 @@ Line4="gamecommand;screen,ScreenOptionsManageCourses;name,Edit Courses" [EditMenu] EditMode="EditMode_Full" -TextBannerType="TextBannerEditMode" ShowGroups=true + Arrows1X=SCREEN_CENTER_X-130 Arrows2X=SCREEN_CENTER_X+270 ArrowsEnabledCommand=diffuse,color("1,1,1,1");shadowlengthy,1;shadowcolor,color("#002740"); ArrowsDisabledCommand=diffuse,color("0.45,0.45,0.45,1");shadowlengthy,1;shadowcolor,color("#002740"); -SongBannerX=SCREEN_CENTER_X+170 -SongBannerY=SCREEN_CENTER_Y-90 -SongBannerWidth=128 -SongBannerHeight=40 -SongTextBannerX=SCREEN_CENTER_X-64 -SongTextBannerY=SCREEN_CENTER_Y-90 + GroupBannerX=SCREEN_CENTER_X+170 GroupBannerY=SCREEN_CENTER_Y-140 -GroupBannerWidth=128 -GroupBannerHeight=40 +GroupBannerOnCommand=scaletoclipped,128,40 + +SongBannerX=SCREEN_CENTER_X+170 +SongBannerY=SCREEN_CENTER_Y-90 +SongBannerOnCommand=scaletoclipped,128,40 + +TextBannerType="TextBannerEditMode" +SongTextBannerX=SCREEN_CENTER_X-64 +SongTextBannerY=SCREEN_CENTER_Y-90 + StepsDisplayX=SCREEN_CENTER_X+170 StepsDisplayY=SCREEN_CENTER_Y-0 StepsDisplaySourceX=SCREEN_CENTER_X+170 StepsDisplaySourceY=SCREEN_CENTER_Y+80 -RowLabelsX=SCREEN_CENTER_X-250 -RowLabelOnCommand=shadowlength,1;zoom,0.75 -RowValue1X=SCREEN_CENTER_X -RowValue2X=SCREEN_CENTER_X+60 -RowValue3X=SCREEN_CENTER_X+60 -RowValue4X=SCREEN_CENTER_X -RowValue5X=SCREEN_CENTER_X+60 -RowValue6X=SCREEN_CENTER_X -RowValue7X=SCREEN_CENTER_X+60 -RowValueOnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 Row1Y=SCREEN_CENTER_Y-140 Row2Y=SCREEN_CENTER_Y-90 Row3Y=SCREEN_CENTER_Y-40 @@ -3374,6 +3380,64 @@ Row5Y=SCREEN_CENTER_Y+40 Row6Y=SCREEN_CENTER_Y+80 Row7Y=SCREEN_CENTER_Y+120 +Label1X=SCREEN_CENTER_X-250 +Label1Y=THEME:GetMetric("EditMode","Row1Y") +Label1OnCommand=shadowlength,1;zoom,0.75 +Label1OffCommand= +Label2X=SCREEN_CENTER_X-250 +Label2Y=THEME:GetMetric("EditMode","Row2Y") +Label2OnCommand=shadowlength,1;zoom,0.75 +Label2OffCommand= +Label3X=SCREEN_CENTER_X-250 +Label3Y=THEME:GetMetric("EditMode","Row3Y") +Label3OnCommand=shadowlength,1;zoom,0.75 +Label3OffCommand= +Label4X=SCREEN_CENTER_X-250 +Label4Y=THEME:GetMetric("EditMode","Row4Y") +Label4OnCommand=shadowlength,1;zoom,0.75 +Label4OffCommand= +Label5X=SCREEN_CENTER_X-250 +Label5Y=THEME:GetMetric("EditMode","Row5Y") +Label5OnCommand=shadowlength,1;zoom,0.75 +Label5OffCommand= +Label6X=SCREEN_CENTER_X-250 +Label6Y=THEME:GetMetric("EditMode","Row6Y") +Label6OnCommand=shadowlength,1;zoom,0.75 +Label6OffCommand= +Label7X=SCREEN_CENTER_X-250 +Label7Y=THEME:GetMetric("EditMode","Row7Y") +Label7OnCommand=shadowlength,1;zoom,0.75 +Label7OffCommand= + +Value1X=SCREEN_CENTER_X +Value1Y=THEME:GetMetric("EditMode","Row1Y") +Value1OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value1OffCommand= +Value2X=SCREEN_CENTER_X+60 +Value2Y=THEME:GetMetric("EditMode","Row2Y") +Value2OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value2OffCommand= +Value3X=SCREEN_CENTER_X+60 +Value3Y=THEME:GetMetric("EditMode","Row3Y") +Value3OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value3OffCommand= +Value4X=SCREEN_CENTER_X +Value4Y=THEME:GetMetric("EditMode","Row4Y") +Value4OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value4OffCommand= +Value5X=SCREEN_CENTER_X+60 +Value5Y=THEME:GetMetric("EditMode","Row5Y") +Value5OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value5OffCommand= +Value6X=SCREEN_CENTER_X +Value6Y=THEME:GetMetric("EditMode","Row6Y") +Value6OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value6OffCommand= +Value7X=SCREEN_CENTER_X+60 +Value7Y=THEME:GetMetric("EditMode","Row7Y") +Value7OnCommand=shadowlength,1;zoom,0.75;maxwidth,SCREEN_CENTER_X*0.65 +Value7OffCommand= + [TextBannerEditMode] Fallback="TextBanner" @@ -3654,15 +3718,15 @@ ChatOutputOffCommand=diffusealpha,1;linear,0.5;diffusealpha,0 UsersX=SCREEN_CENTER_X-265 UsersY=SCREEN_CENTER_Y+172 -UsersDX=40 -UsersAY=16 +UserSpacingX=64 +UserLine2Y=16 UsersOnCommand=draworder,2;zoom,1 UsersOffCommand=linear,0.5;zoom,0 -Users0Command=draworder,2;diffuse,1.0,0.4,0.4,1.0 -Users1Command=draworder,2;diffuse,1.0,1.0,1.0,1.0 -Users2Command=draworder,2;diffuse,0.5,0.5,1.0,1.0 -Users3Command=draworder,2;diffuse,0.5,1.0,0.5,1.0 -Users4Command=draworder,2;diffuse,1.0,0.5,0.5,1.0 +Users0Command=draworder,2;diffuse,color("1.0,0.4,0.4,1.0") +Users1Command=draworder,2;diffuse,color("1.0,1.0,1.0,1.0") +Users2Command=draworder,2;diffuse,color("0.5,0.5,1.0,1.0") +Users3Command=draworder,2;diffuse,color("0.5,1.0,0.5,1.0") +Users4Command=draworder,2;diffuse,color("1.0,0.5,0.5,1.0") [ScreenNetSelectMusic] Class="ScreenNetSelectMusic" diff --git a/Themes/default/BGAnimations/ScreenEvaluation decorations/default.lua b/Themes/default/BGAnimations/ScreenEvaluation decorations/default.lua index ab7e0fe387..571849adc4 100644 --- a/Themes/default/BGAnimations/ScreenEvaluation decorations/default.lua +++ b/Themes/default/BGAnimations/ScreenEvaluation decorations/default.lua @@ -154,6 +154,72 @@ for pn in ivalues(PlayerNumber) do }; end +t[#t+1] = StandardDecorationFromFileOptional("SongInformation","SongInformation") .. { + BeginCommand=function(self) + local SongOrCourse; + if GAMESTATE:GetCurrentSong() then + SongOrCourse = GAMESTATE:GetCurrentSong(); + elseif GAMESTATE:GetCurrentCourse() then + SongOrCourse = GAMESTATE:GetCurrentCourse(); + else + return + end + + if SongOrCourse:HasBanner() then + self:visible(false); + else + self:visible(true); + end + end; + SetCommand=function(self) + local c = self:GetChildren(); + local SongOrCourse; + if GAMESTATE:GetCurrentSong() then + SongOrCourse = GAMESTATE:GetCurrentSong(); + + c.TextTitle:settext( SongOrCourse:GetDisplayMainTitle() or nil ); + c.TextSubtitle:settext( SongOrCourse:GetDisplaySubTitle() or nil ); + c.TextArtist:settext( SongOrCourse:GetDisplayArtist() or nil ); + + if SongOrCourse:GetDisplaySubTitle() == "" then + c.TextTitle:visible(true); + c.TextTitle:y(-16.5/2); + c.Subtitle:visible(false); + c.Subtitle:y(0); + c.TextArtist:visible(true); + c.TextArtist:y(18/2); + else + c.TextTitle:visible(true); + c.TextTitle:y(-16.5); + c.Subtitle:visible(true); + c.Subtitle:y(0); + c.TextArtist:visible(true); + c.TextArtist:y(18); + end +-- self:playcommand("Tick"); + elseif GAMESTATE:GetCurrentCourse() then + SongOrCourse = GAMESTATE:GetCurrentCourse(); + + c.TextTitle:settext( SongOrCourse:GetDisplayMainTitle() or nil ); + c.TextSubtitle:settext( SongOrCourse:GetDisplaySubTitle() or nil ); + c.TextArtist:settext( SongOrCourse:GetDisplayArtist() or nil ); + +-- self:playcommand("Tick"); + else + SongOrCourse = nil; + + c.TextTitle:settext(""); + c.TextSubtitle:settext(""); + c.TextArtist:settext(""); + + self:playcommand("Hide") + end + end; +-- OnCommand=cmd(playcommand,"Set"); + CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); + CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"); + DisplayLanguageChangedMessageCommand=cmd(playcommand,"Set"); +}; t[#t+1] = StandardDecorationFromFileOptional("LifeDifficulty","LifeDifficulty"); t[#t+1] = StandardDecorationFromFileOptional("TimingDifficulty","TimingDifficulty"); t[#t+1] = StandardDecorationFromFileOptional("GameType","GameType"); diff --git a/Themes/default/BGAnimations/ScreenGameplay danger all/default.lua b/Themes/default/BGAnimations/ScreenGameplay danger all/default.lua new file mode 100644 index 0000000000..f69c902ce0 --- /dev/null +++ b/Themes/default/BGAnimations/ScreenGameplay danger all/default.lua @@ -0,0 +1,6 @@ +return Def.ActorFrame { + Def.Quad{ + InitCommand=cmd(FullScreen;diffuse,color("1,0,0,0");blend,Blend.Multiply); + OnCommand=cmd(smooth,1;diffuse,color("0.75,0,0,0.75");decelerate,2;diffuse,color("0,0,0,1")); + }; +}; \ No newline at end of file diff --git a/Themes/default/BGAnimations/ScreenGameplay danger p1/BGAnimation.ini b/Themes/default/BGAnimations/ScreenGameplay danger p1/BGAnimation.ini new file mode 100644 index 0000000000..3f9cc440c9 --- /dev/null +++ b/Themes/default/BGAnimations/ScreenGameplay danger p1/BGAnimation.ini @@ -0,0 +1 @@ +[BGAnimation] diff --git a/Themes/default/BGAnimations/ScreenGameplay danger p2/BGAnimation.ini b/Themes/default/BGAnimations/ScreenGameplay danger p2/BGAnimation.ini new file mode 100644 index 0000000000..3f9cc440c9 --- /dev/null +++ b/Themes/default/BGAnimations/ScreenGameplay danger p2/BGAnimation.ini @@ -0,0 +1 @@ +[BGAnimation] diff --git a/Themes/default/BGAnimations/ScreenGameplay dead p1/BGAnimation.ini b/Themes/default/BGAnimations/ScreenGameplay dead p1/BGAnimation.ini new file mode 100644 index 0000000000..3f9cc440c9 --- /dev/null +++ b/Themes/default/BGAnimations/ScreenGameplay dead p1/BGAnimation.ini @@ -0,0 +1 @@ +[BGAnimation] diff --git a/Themes/default/BGAnimations/ScreenGameplay dead p2/BGAnimation.ini b/Themes/default/BGAnimations/ScreenGameplay dead p2/BGAnimation.ini new file mode 100644 index 0000000000..3f9cc440c9 --- /dev/null +++ b/Themes/default/BGAnimations/ScreenGameplay dead p2/BGAnimation.ini @@ -0,0 +1 @@ +[BGAnimation] diff --git a/Themes/default/BGAnimations/ScreenGameplay overlay.lua b/Themes/default/BGAnimations/ScreenGameplay overlay.lua index 35cb2aebc6..7056d62c0a 100644 --- a/Themes/default/BGAnimations/ScreenGameplay overlay.lua +++ b/Themes/default/BGAnimations/ScreenGameplay overlay.lua @@ -5,7 +5,7 @@ local function UpdateTime(self) local vStats = STATSMAN:GetCurStageStats():GetPlayerStageStats( pn ); local vTime; local obj = self:GetChild( string.format("RemainingTime" .. PlayerNumberToString(pn) ) ); - if vStats then + if vStats and obj then vTime = vStats:GetLifeRemainingSeconds() obj:settext( SecondsToMMSSMsMs( vTime ) ); end; @@ -37,4 +37,4 @@ if GAMESTATE:GetCurrentCourse() then end; end; --]] t.InitCommand=cmd(SetUpdateFunction,UpdateTime); -return t \ No newline at end of file +return t diff --git a/Themes/default/BGAnimations/ScreenSelectMusic decorations/default.lua b/Themes/default/BGAnimations/ScreenSelectMusic decorations/default.lua index d24bea4de3..cd35ac278c 100644 --- a/Themes/default/BGAnimations/ScreenSelectMusic decorations/default.lua +++ b/Themes/default/BGAnimations/ScreenSelectMusic decorations/default.lua @@ -111,6 +111,10 @@ for pn in ivalues(PlayerNumber) do end t[#t+1] = StandardDecorationFromFileOptional("BannerFrame","BannerFrame"); +t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayFrameP1","PaneDisplayFrame"); +t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayFrameP2","PaneDisplayFrame"); +t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayTextP1","PaneDisplayTextP1"); +t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayTextP2","PaneDisplayTextP2"); t[#t+1] = StandardDecorationFromFileOptional("DifficultyList","DifficultyList"); t[#t+1] = StandardDecorationFromFileOptional("CourseContentsList","CourseContentsList"); t[#t+1] = StandardDecorationFromFileOptional("BPMDisplay","BPMDisplay"); diff --git a/Themes/default/Graphics/PaneDisplay text.lua b/Themes/default/Graphics/PaneDisplay text.lua new file mode 100644 index 0000000000..e0277a18df --- /dev/null +++ b/Themes/default/Graphics/PaneDisplay text.lua @@ -0,0 +1,152 @@ +local iPN = ...; +assert(iPN,"[Graphics/PaneDisplay text.lua] No PlayerNumber Provided."); + +local t = Def.ActorFrame {}; +local function GetRadarData( pnPlayer, rcRadarCategory ) + local tRadarValues; + local StepsOrTrail; + local fDesiredValue = 0; + if GAMESTATE:GetCurrentSteps( pnPlayer ) then + StepsOrTrail = GAMESTATE:GetCurrentSteps( pnPlayer ); + fDesiredValue = StepsOrTrail:GetRadarValues( pnPlayer ):GetValue( rcRadarCategory ); + elseif GAMESTATE:GetCurrentTrail( pnPlayer ) then + StepsOrTrail = GAMESTATE:GetCurrentTrail( pnPlayer ); + fDesiredValue = StepsOrTrail:GetRadarValues( pnPlayer ):GetValue( rcRadarCategory ); + else + StepsOrTrail = nil; + end; + return fDesiredValue; +end; + +local function CreatePaneDisplayItem( _pnPlayer, _sLabel, _rcRadarCategory ) + return Def.ActorFrame { + LoadFont("Common Normal") .. { + Text=_sLabel; + InitCommand=cmd(horizalign,left); + OnCommand=cmd(zoom,0.5;diffuse,color("0.9,0.9,0.9");shadowlength,1); + }; + LoadFont("Common Normal") .. { + Text="000"; + InitCommand=cmd(x,32+8+4;horizalign,left); + OnCommand=cmd(zoom,0.5;shadowlength,1); + CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"); + SetCommand=function(self) + local song = GAMESTATE:GetCurrentSong() + local course = GAMESTATE:GetCurrentCourse() + if not song and not course then + self:settext("000") + else + self:settextf("%03i", GetRadarData( _pnPlayer, _rcRadarCategory ) ); + end + end; + }; + }; +end; + +local function CreatePaneDisplayGraph( _pnPlayer, _sLabel, _rcRadarCategory ) + return Def.ActorFrame { + LoadFont("Common Normal") .. { + Text=_sLabel; + InitCommand=cmd(horizalign,left); + OnCommand=cmd(zoom,0.5;shadowlength,1); + }; + Def.Quad { + InitCommand=cmd(x,12;zoomto,50,10;horizalign,left); + OnCommand=cmd(diffuse,Color("Black");shadowlength,1;diffusealpha,0.5); + }; + Def.Quad { + InitCommand=cmd(x,12;zoomto,50,10;horizalign,left); + OnCommand=cmd(shadowlength,0;diffuse,Color("Green");diffusebottomedge,ColorLightTone(Color("Green"))); + CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"); + SetCommand=function(self) + local song = GAMESTATE:GetCurrentSong() + local course = GAMESTATE:GetCurrentCourse() + if not song and not course then + self:stoptweening(); + self:decelerate(0.2); + self:zoomtowidth(0); + else + self:stoptweening(); + self:decelerate(0.2); + self:zoomtowidth( clamp(GetRadarData( _pnPlayer, _rcRadarCategory ) * 50,0,50) ); + end + end; + }; + LoadFont("Common Normal") .. { + InitCommand=cmd(x,40;zoom,0.5;); + OnCommand=cmd(shadowlength,1;); + CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentStepsP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP1ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentTrailP2ChangedMessageCommand=cmd(playcommand,"Set"); + CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"); + SetCommand=function(self) + local song = GAMESTATE:GetCurrentSong() + local course = GAMESTATE:GetCurrentCourse() + if not song and not course then + self:settext("") + else + self:settextf("%i%%", GetRadarData( _pnPlayer, _rcRadarCategory ) * 100 ); + end + end; + }; + }; +end; + +--[[ Numbers ]] +t[#t+1] = Def.ActorFrame { + -- Left + CreatePaneDisplayItem( iPN, "TAPS", 'RadarCategory_TapsAndHolds' ) .. { + InitCommand=cmd(x,-128+16+8;y,-14); + }; + CreatePaneDisplayItem( iPN, "JUMPS", 'RadarCategory_Jumps' ) .. { + InitCommand=cmd(x,-128+16+8;y,-14+16); + }; + CreatePaneDisplayItem( iPN, "HOLDS", 'RadarCategory_Holds' ) .. { + InitCommand=cmd(x,-128+16+8;y,-14+16*2); + }; + CreatePaneDisplayItem( iPN, "MINES", 'RadarCategory_Mines' ) .. { + InitCommand=cmd(x,-128+16+8;y,-14+16*3); + }; + -- Center + CreatePaneDisplayItem( iPN, "MINES", 'RadarCategory_Mines' ) .. { + InitCommand=cmd(x,-128+16+8+74;y,-14); + }; + CreatePaneDisplayItem( iPN, "HANDS", 'RadarCategory_Hands' ) .. { + InitCommand=cmd(x,-128+16+8+74;y,-14+16); + }; + CreatePaneDisplayItem( iPN, "ROLLS", 'RadarCategory_Rolls' ) .. { + InitCommand=cmd(x,-128+16+8+74;y,-14+16*2); + }; + CreatePaneDisplayItem( iPN, "LIFTS", 'RadarCategory_Lifts' ) .. { + InitCommand=cmd(x,-128+16+8+74;y,-14+16*3); + }; + -- Right + CreatePaneDisplayGraph( iPN, "S", 'RadarCategory_Stream' ) .. { + InitCommand=cmd(x,-128+16+8+74*2;y,-14); + }; + CreatePaneDisplayGraph( iPN, "V", 'RadarCategory_Voltage' ) .. { + InitCommand=cmd(x,-128+16+8+74*2;y,-14+12); + }; + CreatePaneDisplayGraph( iPN, "A", 'RadarCategory_Air' ) .. { + InitCommand=cmd(x,-128+16+8+74*2;y,-14+12*2); + }; + CreatePaneDisplayGraph( iPN, "F", 'RadarCategory_Freeze' ) .. { + InitCommand=cmd(x,-128+16+8+74*2;y,-14+12*3); + }; + CreatePaneDisplayGraph( iPN, "C", 'RadarCategory_Chaos' ) .. { + InitCommand=cmd(x,-128+16+8+74*2;y,-14+12*4); + }; +}; +return t; \ No newline at end of file diff --git a/Themes/default/Graphics/ScreenSelectMusic CourseType.lua b/Themes/default/Graphics/ScreenSelectMusic CourseType.lua new file mode 100644 index 0000000000..93e17dacca --- /dev/null +++ b/Themes/default/Graphics/ScreenSelectMusic CourseType.lua @@ -0,0 +1,2 @@ +return LoadFont("Common Normal") .. { +}; \ No newline at end of file diff --git a/Themes/default/Graphics/ScreenSelectMusic DifficultyList.lua b/Themes/default/Graphics/ScreenSelectMusic DifficultyList.lua index ba6c875e5f..84eaac70f5 100644 --- a/Themes/default/Graphics/ScreenSelectMusic DifficultyList.lua +++ b/Themes/default/Graphics/ScreenSelectMusic DifficultyList.lua @@ -16,7 +16,7 @@ return Def.ActorFrame { OnCommand=cmd(diffuse,Color("Black");diffusealpha,0;linear,0.35;diffusealpha,0.5); }; Def.Quad { - InitCommand=cmd(y,24*(GetUserPrefB("UserPrefAutoSetStyle") and 8 or 5)-10;zoomto,164,2;fadeleft,8/164;faderight,8/164); + InitCommand=cmd(y,24*(5)-10;zoomto,164,2;fadeleft,8/164;faderight,8/164); OnCommand=cmd(diffuse,Color("Black");diffusealpha,0;linear,0.35;diffusealpha,0.5); }; Def.StepsDisplayList { diff --git a/Themes/default/Graphics/ScreenSelectMusic PaneDisplayFrame.png b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayFrame.png new file mode 100644 index 0000000000..e2e7f90497 Binary files /dev/null and b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayFrame.png differ diff --git a/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP1.lua b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP1.lua new file mode 100644 index 0000000000..8ca7f6ac39 --- /dev/null +++ b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP1.lua @@ -0,0 +1 @@ +return LoadActor(THEME:GetPathG("PaneDisplay","Text"),PLAYER_1); \ No newline at end of file diff --git a/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP2.lua b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP2.lua new file mode 100644 index 0000000000..e85dd5eedd --- /dev/null +++ b/Themes/default/Graphics/ScreenSelectMusic PaneDisplayTextP2.lua @@ -0,0 +1 @@ +return LoadActor(THEME:GetPathG("PaneDisplay","Text"),PLAYER_2); \ No newline at end of file diff --git a/Themes/default/Languages/en.ini b/Themes/default/Languages/en.ini index bcfd9d57d1..1ec0d82f11 100644 --- a/Themes/default/Languages/en.ini +++ b/Themes/default/Languages/en.ini @@ -59,25 +59,29 @@ HelpText=&BACK; Exit &START; Move On &MENULEFT;+&MENURIGHT; or &SELECT; Snapshot LifeDifficulty=Life Difficulty: %s TimingDifficulty=Timing Difficulty: %s [OptionTitles] -UserPrefNotePosition=Note Positions +GamePrefAutoSetStyle=Auto Set Style +GamePrefNotePosition=Note Positions +GamePrefComboOnRolls=Rolls Increment Combo +GamePrefComboUnderField=Combo Under Field +GamePrefAdjustSpeed=Adjust Speed + UserPrefGameplayShowScore=Show Score UserPrefGameplayShowStepsDisplay=Show Steps UserPrefShowLotsaOptions=Options Density -UserPrefAutoSetStyle=Auto Set Style UserPrefLongFail=Fail Length -UserPrefComboOnRolls=Rolls Increment Combo UserPrefFlashyCombo=Flashy Combo -UserPrefComboUnderField=Combo Under Field [OptionExplanations] -UserPrefNotePosition=Determines where the arrow receptors are placed in gameplay. +GamePrefAutoSetStyle=Allow the game to list all one player and two player modes at once instead of one style only. This might require a restart of StepMania\n( or alternatively hit F2! ) +GamePrefNotePosition=Determines where the arrow receptors are placed in gameplay. +GamePrefComboOnRolls=Choose if rolls should increment the combo or not. +GamePrefComboUnderField=Determine if the combo should display under the notes or not. +GamePrefAdjustSpeed=Adjust the default scale for speed modifiers. Normal corresponds to the original StepMania 3.9 speed, Fast is twice that rate. + UserPrefGameplayShowScore=Show or Hide the score display in gameplay. UserPrefGameplayShowStepsDisplay=Show or Hide the step information display in gameplay. UserPrefShowLotsaOptions=Choose how many lines/rows of options to choose from. &oq;Few&cq; keeps the list to a minimum. &oq;Many&cq; adds various show-off mods. -UserPrefAutoSetStyle=Allow the game to list all one player and two player modes at once instead of one style only. This might require a restart of StepMania\n( or alternatively hit F2! ) UserPrefLongFail=Choose between the original sm-ssc fail (Long) or the new sm-ssc fail (Short). -UserPrefComboOnRolls=Choose if rolls should increment the combo or not. UserPrefFlashyCombo=Determine if combo flashes should be shown or not. -UserPrefComboUnderField=Determine if the combo should display under the notes or not. [StepsListDisplayRow StepsType] Dance_Single=4 Dance_Double=8 diff --git a/Themes/default/Scripts/03 ThemePrefs.lua b/Themes/default/Scripts/03 ThemePrefs.lua index 343f910238..a5889c1d24 100644 --- a/Themes/default/Scripts/03 ThemePrefs.lua +++ b/Themes/default/Scripts/03 ThemePrefs.lua @@ -1,5 +1,19 @@ -- sm-ssc Default Theme Preferences Handler +-- Example usage of new system (not really implemented yet) + +local Prefs = +{ + AutoSetStyle = + { + Default = false, + Choices = { "ON", "OFF" }, + Values = { true, false } + }, +}; + +ThemePrefs.InitAll( Prefs ) + function InitUserPrefs() if GetUserPref("UserPrefGameplayShowStepsDisplay") == nil then SetUserPref("UserPrefGameplayShowStepsDisplay", true); @@ -34,6 +48,9 @@ function InitUserPrefs() if GetUserPrefB("UserPrefComboUnderField") == nil then SetUserPref("UserPrefComboUnderField", true); end; + if GetUserPrefB("UserPrefAdjustSpeed") == nil then + SetUserPref("UserPrefAdjustSpeed", false); + end; --[[ if GetUserPref("ProTimingP1") == nil then SetUserPref("ProTimingP1", false); end; @@ -452,4 +469,49 @@ function UserPrefComboUnderField() setmetatable( t, t ); return t; end ---[[ end option rows ]] \ No newline at end of file + +function GetDefaultArrowSpacing() + local rates = { + 64, -- Default + 80, -- Pro + 128, -- New + }; + return GetUserPrefB("UserPrefAdjustSpeed") and rates[3] or rates[1]; +end; + +function UserPrefAdjustSpeed() + local t = { + Name = "UserPrefAdjustSpeed"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = { 'Slow','Fast' }; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefAdjustSpeed") ~= nil then + if GetUserPrefB("UserPrefAdjustSpeed") then + list[2] = true; + else + list[1] = true; + end; + else + WritePrefToFile("UserPrefAdjustSpeed",true); + list[2] = true; + end; + end; + SaveSelections = function(self, list, pn) + local val; + if list[2] then + val = true; + else + val = false; + end; + WritePrefToFile("UserPrefAdjustSpeed",val); + MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } ); + THEME:ReloadMetrics(); + end; + }; + setmetatable( t, t ); + return t; +end +--[[ end option rows ]] diff --git a/Themes/default/metrics.ini b/Themes/default/metrics.ini index d9ece03880..7b9a1b9238 100644 --- a/Themes/default/metrics.ini +++ b/Themes/default/metrics.ini @@ -5,17 +5,17 @@ FallbackTheme=_fallback FirstAttractScreen="" InitialScreen="ScreenInit" -AutoSetStyle=GetUserPrefB("UserPrefAutoSetStyle") +# AutoSetStyle=GetUserPrefB("UserPrefAutoSetStyle") [BitmapText] NumRainbowColors=1 RainbowColor1=Color("Black"); [BPMDisplay] -SetNoBpmCommand=stoptweening;linear,0.2;diffuse,Color("White");diffusebottomedge,BoostColor(Color("White"),0.875); -SetNormalCommand=stoptweening;linear,0.2;diffuse,Color("White");diffusebottomedge,BoostColor(Color("White"),0.875); -SetChangeCommand=stoptweening;linear,0.2;diffuse,Color("Orange");diffusetopedge,BoostColor(Color("Orange"),1.5); -SetRandomCommand=stoptweening;linear,0.2;diffuse,Color("Blue");diffusetopedge,BoostColor(Color("Blue"),1.5); -SetExtraCommand=stoptweening;linear,0.2;diffuse,Color("Red");diffusebottomedge,BoostColor(Color("Red"),0.5); +SetNoBpmCommand=stoptweening;maxwidth,128;linear,0.2;diffuse,Color("White");diffusebottomedge,BoostColor(Color("White"),0.875); +SetNormalCommand=stoptweening;maxwidth,128;linear,0.2;diffuse,Color("White");diffusebottomedge,BoostColor(Color("White"),0.875); +SetChangeCommand=stoptweening;maxwidth,128;linear,0.2;diffuse,Color("Orange");diffusetopedge,BoostColor(Color("Orange"),1.5); +SetRandomCommand=stoptweening;maxwidth,128;linear,0.2;diffuse,Color("Blue");diffusetopedge,BoostColor(Color("Blue"),1.5); +SetExtraCommand=stoptweening;maxwidth,128;linear,0.2;diffuse,Color("Red");diffusebottomedge,BoostColor(Color("Red"),0.5); Cycle=true NoBpmText="000" RandomCycleSpeed=0.2 -- smaller numbers mean the bpm cycles faster @@ -83,16 +83,17 @@ HoldJudgmentHeldCommand=finishtweening;shadowlength,0;diffusealpha,1;zoom,1.25;l [Judgment] # New # JudgmentOnCommand= - # !!! # - JudgmentW1Command=finishtweening;shadowlength,0;y,0;diffusealpha,1;zoom,1.3;linear,0.05;zoom,1;sleep,0.8;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0;glowblink;effectperiod,0.05;effectcolor1,1,1,1,0;effectcolor2,1,1,1,0.8 JudgmentW2Command=finishtweening;y,0;shadowlength,0;diffusealpha,1;zoom,1.3;linear,0.05;zoom,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0 JudgmentW3Command=finishtweening;y,0;shadowlength,0;diffusealpha,1;zoom,1.2;linear,0.05;zoom,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0; JudgmentW4Command=finishtweening;y,0;shadowlength,0;diffusealpha,1;zoom,1.1;linear,0.05;zoom,1;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0; JudgmentW5Command=finishtweening;y,0;shadowlength,0;diffusealpha,1;zoom,1.0;vibrate;effectmagnitude,1,2,2;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0 JudgmentMissCommand=finishtweening;y,0;shadowlength,0;diffusealpha,1;zoom,1;y,-20;linear,0.8;y,20;sleep,0.5;linear,0.1;zoomy,0.5;zoomx,2;diffusealpha,0 - +# Late/Early +OffsetOnCommand= +OffsetLateCommand= +OffsetEarlyCommand= [LifeMeterBar] OverOnCommand=diffuse,Color("Orange");diffuserightedge,BoostColor(Color("Orange"),1.5) @@ -316,9 +317,12 @@ ProtimingMissCommand=finishtweening;diffusealpha,1;zoom,1.15;glow,GameColor.Judg # AveragePulseCommand=finishtweening;diffusealpha,1;zoom,0.75*1.25;decelerate,0.05;zoom,0.75;sleep,2;linear,0.5;diffusealpha,0; [Player] -ReceptorArrowsYStandard=GetTapPosition('Standard') -ReceptorArrowsYReverse=GetTapPosition('Reverse') -RollBodyIncrementsCombo=GetUserPrefB("UserPrefComboOnRolls") +# ReceptorArrowsYStandard=GetTapPosition('Standard') +# ReceptorArrowsYReverse=GetTapPosition('Reverse') +# RollBodyIncrementsCombo=GetUserPrefB("UserPrefComboOnRolls") + +[ArrowEffects] +ArrowSpacing=GetDefaultArrowSpacing() [ScoreDisplayNormal] FrameX= @@ -506,12 +510,12 @@ MeterSetCommand=%function(self,param) \ self:stopeffect(); \ end; \ end; \ - (cmd(finishtweening;zoomx,1.5;diffusealpha,0;smooth,0.125;zoom,1;diffusealpha,1))(self); \ end; # ShowDescription=true DescriptionX=-20-32 -DescriptionY=GetUserPrefB("UserPrefAutoSetStyle") and -5 or 0 +DescriptionY=GetGamePrefB("AutoSetStyle") and -5 or 0 +# DescriptionY=GetUserPrefB("UserPrefAutoSetStyle") and -5 or 0 DescriptionOnCommand=shadowlength,1;uppercase,true;zoom,0.75;maxwidth,128+8 DescriptionSetCommand=%function(self,param) \ if self:GetText() == "" then \ @@ -521,7 +525,6 @@ DescriptionSetCommand=%function(self,param) \ self:diffuse(CustomDifficultyToColor(param.CustomDifficulty)); \ self:shadowcolor(CustomDifficultyToDarkColor(param.CustomDifficulty)); \ end; \ - (cmd(finishtweening;diffusealpha,0;addx,-4;smooth,0.125;addx,4;diffusealpha,1))(self); \ end; # ShowAutogen=false @@ -530,7 +533,8 @@ AutogenY=0 AutogenOnCommand= AutogenSetCommand=%function(self,param) if param.Difficulty then self:diffuse(CustomDifficultyToLightColor(param.Difficulty)); self:strokecolor(CustomDifficultyToDarkColor(param.Difficulty)); end end # -ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") +ShowStepsType=GetGamePrefB("AutoSetStyle") +# ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") StepsTypeX=-20-32 StepsTypeY=7 StepsTypeOnCommand=zoom,0.45 @@ -580,7 +584,8 @@ end; # ShowDescription=true DescriptionX=-20 -DescriptionY=GetUserPrefB("UserPrefAutoSetStyle") and -5 or 0 +DescriptionY=GetGamePrefB("AutoSetStyle") and -5 or 0 +# DescriptionY=GetUserPrefB("UserPrefAutoSetStyle") and -5 or 0 DescriptionOnCommand=shadowlength,1;uppercase,true;zoom,0.75;maxwidth,128+8 DescriptionSetCommand=%function(self,param) \ if self:GetText() == "" then \ @@ -599,7 +604,8 @@ AutogenY=0 AutogenOnCommand= AutogenSetCommand=%function(self,param) if param.Difficulty then self:diffuse(CustomDifficultyToLightColor(param.Difficulty)); self:strokecolor(CustomDifficultyToDarkColor(param.Difficulty)); end end # -ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") +ShowStepsType=GetGamePrefB("AutoSetStyle") +# ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") StepsTypeX=-20 StepsTypeY=7 StepsTypeOnCommand=zoom,0.45 @@ -610,7 +616,7 @@ Fallback="StepsDisplay" [StepsDisplayListRow] # CapitalizeDifficultyNames=false -NumShownItems=GetUserPrefB("UserPrefAutoSetStyle") and 8 or 5 +NumShownItems=5 ItemsSpacingY=24 MoveCommand=decelerate,0.3 # @@ -652,7 +658,8 @@ MeterSetCommand=%function(self,param) \ end; # ShowDescription=true -DescriptionX=GetUserPrefB("UserPrefAutoSetStyle") and (-64-8+20) or (-64-8) +DescriptionX=GetGamePrefB("AutoSetStyle") and (-64-8+20) or (-64-8) +# DescriptionX=GetUserPrefB("UserPrefAutoSetStyle") and (-64-8+20) or (-64-8) DescriptionY=0 DescriptionOnCommand=shadowlength,1;horizalign,left;zoom,0.65;maxwidth,128+8-20;uppercase,true; DescriptionOffCommand= @@ -673,7 +680,8 @@ AutogenY=0 AutogenOnCommand=blend,Blend.Add;diffuseshift;effectcolor1,color("#FFCC00FF");effectcolor2,color("#FFCC0088"); AutogenSetCommand= # -ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") +ShowStepsType=GetGamePrefB("AutoSetStyle") +# ShowStepsType=GetUserPrefB("UserPrefAutoSetStyle") StepsTypeX=-64-8 StepsTypeY=0 StepsTypeOnCommand= @@ -819,25 +827,25 @@ ItemsLongRowSharedX=SCREEN_CENTER_X [ScreenOptionsTheme] Fallback="ScreenOptionsServiceChild" -LineNames="gNotePos,gAuto,gScore,gSDisp,gOpts,gLongFail,gComboUnderField,FlashyCombo" +LineNames="gNotePos,gAuto,gScore,gSDisp,gOpts,gLongFail,gComboUnderField,FlashyCombo,AdjustSpeed" #,gAuto -LinegNotePos="lua,UserPrefNotePosition()" +LinegNotePos="lua,GamePrefNotePosition()" LinegScore="lua,UserPrefGameplayShowScore()" LinegSDisp="lua,UserPrefGameplayShowStepsDisplay()" LinegOpts="lua,UserPrefShowLotsaOptions()" -LinegAuto="lua,UserPrefAutoSetStyle()" +LinegAuto="lua,GamePrefAutoSetStyle()" LinegLongFail="lua,UserPrefLongFail()" -LinegComboUnderField="lua,UserPrefComboUnderField()" +LinegComboUnderField="lua,GamePrefComboUnderField()" LineFlashyCombo="lua,UserPrefFlashyCombo()" - +LineAdjustSpeed="lua,GamePrefAdjustSpeed()" [ScreenOptionsSystemDirection] LineNames="1,2,3,4,5,6,7,8,9,FlashyCombo,RollCombo,10,11,12,13,14,15,16,LF,17,18,19,20,21,22" LineLF="lua,UserPrefLongFail()" -LineRollCombo="lua,UserPrefComboOnRolls()" +LineRollCombo="lua,GamePrefComboOnRolls()" LineFlashyCombo="lua,UserPrefFlashyCombo()" [ScreenOptionsAdvanced] LineNames="2,3,4,8,11,13,14,15,16,28,29,30,RollCombo" -LineRollCombo="lua,UserPrefComboOnRolls()" +LineRollCombo="lua,GamePrefComboOnRolls()" [ScreenOptionsService] ShowHeader=false @@ -1157,7 +1165,8 @@ StageDisplayY=SCREEN_TOP+160-96+4 StageDisplayOnCommand=draworder,105;fov,90;zoom,0.75;zoomy,0;sleep,0.35;smooth,0.35;zoomy,0.75 StageDisplayOffCommand=linear,0.25;zoomy,0; # -ShowDifficultyDisplay=not GetUserPrefB("UserPrefAutoSetStyle") and not GAMESTATE:IsCourseMode() +ShowDifficultyDisplay=not GetGamePrefB("AutoSetStyle") and not GAMESTATE:IsCourseMode() +# ShowDifficultyDisplay=not GetUserPrefB("UserPrefAutoSetStyle") and not GAMESTATE:IsCourseMode() DifficultyDisplayX=SCREEN_CENTER_X-160+64 DifficultyDisplayY=SCREEN_TOP+160-96+4 DifficultyDisplayOnCommand=draworder,105;fov,90;zoom,1;zoomy,0;sleep,0.35;smooth,0.35;zoomy,1 @@ -1177,7 +1186,7 @@ BannerFrameOffCommand=bouncebegin,0.15;zoomx,0; ShowBPMDisplay=true BPMDisplayX=SCREEN_CENTER_X-160-90+2 BPMDisplayY=SCREEN_TOP+160+(36/2)+8 -BPMDisplayOnCommand=finishtweening;horizalign,left;strokecolor,Color("Outline");maxwidth,128;addx,320;zoomx,0;decelerate,0.35;addx,-320;zoomx,1 +BPMDisplayOnCommand=finishtweening;maxwidth,128;horizalign,left;strokecolor,Color("Outline");addx,320;zoomx,0;decelerate,0.35;addx,-320;zoomx,1 BPMDisplayOffCommand=bouncebegin,0.15;zoomx,0; # ShowBPMLabel=true @@ -1198,6 +1207,30 @@ DifficultyListTweenOffCommand=stoptweening;bouncebegin,0.135;zoomx,0 # DifficultyListSelectMenuOpenedMessageCommand=stoptweening;decelerate,0.125;zoom,0.5; # DifficultyListSelectMenuClosedMessageCommand=stoptweening;accelerate,0.0725;zoom,1; # +ShowPaneDisplayFrameP1=true +PaneDisplayFrameP1X=SCREEN_CENTER_X-160 +PaneDisplayFrameP1Y=SCREEN_BOTTOM-112-2 +PaneDisplayFrameP1OnCommand=player,PLAYER_1;diffuse,Color("Orange");zoomy,0;sleep,0.5;decelerate,0.25;zoomy,1 +PaneDisplayFrameP1OffCommand=bouncebegin,0.15;zoomx,0; +# +ShowPaneDisplayTextP1=true +PaneDisplayTextP1X=SCREEN_CENTER_X-160 +PaneDisplayTextP1Y=SCREEN_BOTTOM-122-2 +PaneDisplayTextP1OnCommand=player,PLAYER_1;zoomy,0;sleep,0.5;decelerate,0.25;zoomy,1 +PaneDisplayTextP1OffCommand=bouncebegin,0.15;zoomx,0; +# +ShowPaneDisplayFrameP2=true +PaneDisplayFrameP2X=SCREEN_CENTER_X+160 +PaneDisplayFrameP2Y=SCREEN_BOTTOM-112-2 +PaneDisplayFrameP2OnCommand=player,PLAYER_2;diffuse,Color("Orange");zoomy,0;sleep,0.5;decelerate,0.25;zoomy,1 +PaneDisplayFrameP2OffCommand=bouncebegin,0.15;zoomx,0; +# +ShowPaneDisplayTextP2=true +PaneDisplayTextP2X=SCREEN_CENTER_X+160 +PaneDisplayTextP2Y=SCREEN_BOTTOM-122-2 +PaneDisplayTextP2OnCommand=player,PLAYER_2;zoomy,0;sleep,0.5;decelerate,0.25;zoomy,1 +PaneDisplayTextP2OffCommand=bouncebegin,0.15;zoomx,0; +# ShowCourseContentsList=false CourseContentsListX=SCREEN_CENTER_X-160 CourseContentsListY=SCREEN_TOP+216+6 @@ -1234,7 +1267,7 @@ CDTitleX=SCREEN_CENTER_X-160+90 CDTitleY=SCREEN_TOP+160+(36/2)+8 CDTitleFrontCommand=diffuse,color('0.5,0.5,0.5,1');cullmode,'CullMode_Front' CDTitleBackCommand=cullmode,'CullMode_Back' -CDTitleOnCommand=draworder,106;zoom,0.75;diffusealpha,1;zoom,0;bounceend,0.35;zoom,0.75;spin;effectmagnitude,0,180,0; +CDTitleOnCommand=draworder,106;shadowlength,1;zoom,0.75;diffusealpha,1;zoom,0;bounceend,0.35;zoom,0.75;spin;effectmagnitude,0,180,0; CDTitleOffCommand=bouncebegin,0.15;zoomx,0; # ScoreFrameP1X= @@ -1274,16 +1307,16 @@ StepsDisplayP2OnCommand=visible,THEME:GetMetric(Var "LoadingScreen","ShowStepsDi StepsDisplayP2OffCommand=bouncebegin,0.15;zoomx,0; # StepsDisplayP2CurrentStepsP2ChangedMessageCommand=stoptweening;zoom,1.2;decelerate,0.1;zoom,1 # -ShowPercentScoreP1=GAMESTATE:IsHumanPlayer(PLAYER_1) +ShowPercentScoreP1=true PercentScoreP1X=SCREEN_CENTER_X-80-1 PercentScoreP1Y=SCREEN_BOTTOM-60 -PercentScoreP1OnCommand=visible,THEME:GetMetric(Var "LoadingScreen","ShowPercentScoreP1");addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y +PercentScoreP1OnCommand=player,PLAYER_1;addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y PercentScoreP1OffCommand=bouncebegin,0.15;zoomx,0; # -ShowPercentScoreP2=GAMESTATE:IsHumanPlayer(PLAYER_2) +ShowPercentScoreP2=true PercentScoreP2X=SCREEN_CENTER_X+240-1 PercentScoreP2Y=SCREEN_BOTTOM-60 -PercentScoreP2OnCommand=visible,THEME:GetMetric(Var "LoadingScreen","ShowPercentScoreP2");addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y +PercentScoreP2OnCommand=player,PLAYER_2;addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y PercentScoreP2OffCommand=bouncebegin,0.15;zoomx,0; [ScreenSelectCourse] #~ ScreenInitCommand=%function(self) \ @@ -1299,6 +1332,11 @@ ShowNumCourseSongs=true # UsePlayerSelectMenu=false SelectMenuAvailable=false +# +ShowPaneDisplayFrameP1=false +ShowPaneDisplayTextP1=false +ShowPaneDisplayFrameP2=false +ShowPaneDisplayTextP2=false [ScreenNetSelectMusic] StepsDisplayP1X=SCREEN_CENTER_X-240 StepsDisplayP1Y=SCREEN_CENTER_Y+185 @@ -1695,11 +1733,11 @@ ScoreLabelOffCommand= # ScoreNumberP1X=SCREEN_CENTER_X-160 ScoreNumberP1Y=SCREEN_TOP+320 -ScoreNumberP1OnCommand=visible,not PREFSMAN:GetPreference("PercentageScoring");diffuse,PlayerColor(PLAYER_1);diffusetopedge,BoostColor(PlayerColor(PLAYER_1),1.5);strokecolor,ColorDarkTone( PlayerColor(PLAYER_1) );shadowlength,1;zoom,0.775 +ScoreNumberP1OnCommand=diffuse,PlayerColor(PLAYER_1);diffusetopedge,BoostColor(PlayerColor(PLAYER_1),1.5);strokecolor,ColorDarkTone( PlayerColor(PLAYER_1) );shadowlength,1;zoom,0.775 ScoreNumberP1OffCommand= ScoreNumberP2X=SCREEN_CENTER_X+160 ScoreNumberP2Y=SCREEN_TOP+320 -ScoreNumberP2OnCommand=visible,not PREFSMAN:GetPreference("PercentageScoring");diffuse,PlayerColor(PLAYER_2);diffusetopedge,BoostColor(PlayerColor(PLAYER_2),1.5);strokecolor,ColorDarkTone( PlayerColor(PLAYER_2) );shadowlength,1;zoom,0.775 +ScoreNumberP2OnCommand=diffuse,PlayerColor(PLAYER_2);diffusetopedge,BoostColor(PlayerColor(PLAYER_2),1.5);strokecolor,ColorDarkTone( PlayerColor(PLAYER_2) );shadowlength,1;zoom,0.775 ScoreNumberP2OffCommand= # PercentFrameP1X=SCREEN_CENTER_X-160 @@ -1714,12 +1752,12 @@ PercentFrameP2OffCommand= # PercentP1X=SCREEN_CENTER_X-160 PercentP1Y=SCREEN_TOP+320 -PercentP1OnCommand=visible,PREFSMAN:GetPreference("PercentageScoring"); +PercentP1OnCommand=visible,false PercentP1OffCommand= # PercentP2X=SCREEN_CENTER_X-160 PercentP2Y=SCREEN_TOP+320 -PercentP2OnCommand=visible,PREFSMAN:GetPreference("PercentageScoring"); +PercentP2OnCommand=visible,false PercentP2OffCommand= # LargeBannerX=SCREEN_CENTER_X @@ -1751,12 +1789,12 @@ GradeP2OffCommand= # PlayerOptionsP1X=SCREEN_CENTER_X-160 PlayerOptionsP1Y=SCREEN_TOP+352 -PlayerOptionsP1OnCommand=zoom,0.5 +PlayerOptionsP1OnCommand=zoom,0.5;shadowlength,1 PlayerOptionsP1OffCommand= ## PlayerOptionsP2X=SCREEN_CENTER_X+160 PlayerOptionsP2Y=SCREEN_TOP+352 -PlayerOptionsP2OnCommand=zoom,0.5 +PlayerOptionsP2OnCommand=zoom,0.5;shadowlength,1 PlayerOptionsP2OffCommand= # SongOptionsX=SCREEN_CENTER_X @@ -1858,20 +1896,26 @@ PercentScoreP2OffCommand=bouncebegin,0.15;zoomx,0; ShowGameType=true GameTypeX=SCREEN_CENTER_X GameTypeY=SCREEN_BOTTOM-48 -GameTypeOnCommand=addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y;zoom,0.5;shadowlength,1;shadowcolor,color("#22222266") +GameTypeOnCommand=addy,SCREEN_CENTER_Y;decelerate,0.35;addy,-SCREEN_CENTER_Y;zoom,0.675;shadowlength,1;shadowcolor,color("#22222266") GameTypeOffCommand=bouncebegin,0.15;addy,SCREEN_CENTER_Y; # +ShowTimingDifficulty=true +TimingDifficultyX=SCREEN_CENTER_X +TimingDifficultyY=SCREEN_TOP+16 +TimingDifficultyOnCommand=zoom,0.675;draworder,105 +TimingDifficultyOffCommand= +# ShowLifeDifficulty=true LifeDifficultyX=SCREEN_CENTER_X LifeDifficultyY=SCREEN_TOP+32 -LifeDifficultyOnCommand=zoom,0.5;draworder,105 -LifeDifficultyOffCommand=linear,0.5;cropright,1 +LifeDifficultyOnCommand=zoom,0.675;draworder,105 +LifeDifficultyOffCommand= # -ShowTimingDifficulty=true -TimingDifficultyX=SCREEN_CENTER_X -TimingDifficultyY=SCREEN_TOP+20 -TimingDifficultyOnCommand=zoom,0.5;draworder,105 -TimingDifficultyOffCommand=linear,0.5;cropright,1 +ShowSongInformation=true +SongInformationX=SCREEN_CENTER_X +SongInformationY=SCREEN_TOP+100 +SongInformationOnCommand=playcommand,"Set";draworder,105 +SongInformationOffCommand= [ScreenEvaluationNormal] Fallback="ScreenEvaluation" # diff --git a/Themes/default/~res/Common fallback banners.psd b/Themes/default/~res/Common fallback banners.psd new file mode 100644 index 0000000000..5a994d2824 Binary files /dev/null and b/Themes/default/~res/Common fallback banners.psd differ diff --git a/Themes/default/~res/Judgments.psd b/Themes/default/~res/Judgments.psd new file mode 100644 index 0000000000..e982f9be71 Binary files /dev/null and b/Themes/default/~res/Judgments.psd differ diff --git a/Themes/default/~res/PaneDisplay frame.psd b/Themes/default/~res/PaneDisplay frame.psd new file mode 100644 index 0000000000..048b2dfcd7 Binary files /dev/null and b/Themes/default/~res/PaneDisplay frame.psd differ diff --git a/Themes/default/~res/ScreenGameplay ready.psd b/Themes/default/~res/ScreenGameplay ready.psd new file mode 100644 index 0000000000..f1a2725bc6 Binary files /dev/null and b/Themes/default/~res/ScreenGameplay ready.psd differ diff --git a/Utils/build.sh b/Utils/build.sh old mode 100644 new mode 100755 index b173051111..f896306a91 --- a/Utils/build.sh +++ b/Utils/build.sh @@ -64,7 +64,7 @@ usage () { } version () { - echo 'build.sh (StepMania) 2.61' + echo 'build.sh (StepMania) 2.61a' echo 'Copyright (C) 2006-2009 Steve Checkoway' echo 'StepMania is Copyright (C) 2001-2009 Chris Danford et al.' echo 'sm-ssc is Copyright (C) 2009-2010 the spinal shark collective' @@ -111,7 +111,7 @@ if [ ! -d $ffmpeg ]; then if which bzip2 &>/dev/null; then zipcommand=jxf ffmarc=ffmpeg-$version.tar.bz2 - elif which gzip &>/dev/null + elif which gzip &>/dev/null; then zipcommand=zxf ffmarc=ffmpeg-$version.tar.gz else @@ -132,7 +132,7 @@ if [ ! -d $ffmpeg ]; then fi if [ -n "$s_download" ]; then exit 0; fi -args='--disable-shared --enable-static --disable-debug --disable-vhook +args='--disable-shared --enable-static --disable-debug --enable-memalign-hack --disable-network --enable-small --disable-encoders --disable-ffmpeg --disable-ffserver --disable-ffplay --disable-muxers --enable-demuxer=avi diff --git a/autogen.sh b/autogen.sh old mode 100644 new mode 100755 diff --git a/configure.ac b/configure.ac index 48ccc38a44..2fb749062c 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,17 @@ AC_C_BIGENDIAN( AC_DEFINE(ENDIAN_LITTLE, 1, [Little endian]), AC_MSG_ERROR([Can't determine endianness]) ) +# If we're compiling with the SSE2 build flag, add that flag to CFLAGS and CXXFLAGS. +# (Handwritten SSE/SSE2 code isn't in the binary, but GCC's heuristics optimize enough +# vector arithmetic in Rage that this produces a noticeable speedup on SSE2 processors.) + +AC_ARG_WITH(sse2, AC_HELP_STRING([--with-sse2], [Enable SSE2 optimization]), with_sse2=$withval, with_sse2=no) + +if test "$with_sse2" = "yes"; then + CFLAGS="$CFLAGS -msse2" + CXXFLAGS="$CXXFLAGS -msse2" +fi + AC_ARG_WITH(prof, AS_HELP_STRING([--with-prof],[Enable profiling]), with_prof=$withval, with_prof=no) if test "$with_prof" = "yes"; then test "$DEFAULT_CFLAGS" = "yes" && CFLAGS="$CFLAGS -pg" diff --git a/sm-ssc.nsi b/sm-ssc.nsi index 32a25f5716..fcf4aadd2a 100644 --- a/sm-ssc.nsi +++ b/sm-ssc.nsi @@ -227,6 +227,13 @@ Section "Main Section" SecMain WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Classes\.smzip" "" "smzipfile" !endif +!ifdef ASSOCIATE_SMURL + WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Classes\stepmania" "" "StepMania protocol handler" + WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Classes\stepmania" "URL Protocol" "" + WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Classes\stepmania\DefaultIcon" "" "$INSTDIR\Program\StepMania.exe" + WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Classes\stepmania\shell\open\command" "" '"$INSTDIR\Program\StepMania.exe" "%1"' +!endif + !ifdef INSTALL_NON_PCK_FILES CreateDirectory "$INSTDIR\Announcers" SetOutPath "$INSTDIR\Announcers" @@ -389,6 +396,9 @@ Section "Main Section" SecMain !ifdef ASSOCIATE_SMZIP Call RefreshShellIcons !endif +!ifdef ASSOCIATE_SMURL + Call RefreshShellIcons +!endif !ifdef INSTALL_PROGRAM_LIBRARIES ; microsoft! ; xxx: how many of these do we really need? @@ -674,6 +684,10 @@ Section "Uninstall" DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Classes\.smzip" !endif +!ifdef ASSOCIATE_SMURL + DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Classes\stepmania" +!endif + !ifdef INSTALL_NON_PCK_FILES Delete "$INSTDIR\Announcers\instructions.txt" RMDir "$INSTDIR\Announcers" @@ -765,6 +779,9 @@ Section "Uninstall" !ifdef ASSOCIATE_SMZIP Call un.RefreshShellIcons !endif +!ifdef ASSOCIATE_SMURL + Call un.RefreshShellIcons +!endif !ifdef INSTALL_PROGRAM_LIBRARIES Delete "$INSTDIR\Program\mfc71.dll" Delete "$INSTDIR\Program\msvcr71.dll" diff --git a/src/CommandLineActions.cpp b/src/CommandLineActions.cpp index 9a95a8a84e..e073afb7df 100644 --- a/src/CommandLineActions.cpp +++ b/src/CommandLineActions.cpp @@ -12,6 +12,11 @@ #include "arch/Dialog/Dialog.h" #include "RageFileManager.h" #include "SpecialFiles.h" +#include "FileDownload.h" +#include "arch/LoadingWindow/LoadingWindow.h" +#include "Preference.h" +#include "JsonUtil.h" +#include "ScreenInstallOverlay.h" // only used for Version() #if defined(_WINDOWS) @@ -21,154 +26,52 @@ const RString INSTALLER_LANGUAGES_DIR = "Themes/_Installer/Languages/"; -static const RString TEMP_ZIP_MOUNT_POINT = "/@temp-zip/"; +vector CommandLineActions::ToProcess; -static bool IsPackageFile( RString sFile ) -{ - RString sOsDir, sFilename, sExt; - splitpath( sFile, sOsDir, sFilename, sExt ); - - return sExt.EqualsNoCase(".smzip") || sExt.EqualsNoCase(".zip"); -} - -static void GetPackageFilesToInstall( vector &vs ) -{ - int argc; - char **argv; - GetCommandLineArguments( argc, argv ); - - for( int i = 1; i vs; - GetPackageFilesToInstall( vs ); - return !vs.empty(); -} - - -struct FileCopyResult -{ - FileCopyResult( RString _sFile, RString _sComment ) : sFile(_sFile), sComment(_sComment) {} - RString sFile, sComment; -}; - -void CommandLineActions::Install() -{ - vector vSucceeded; - vector vFailed; - - vector vs; - GetPackageFilesToInstall( vs ); - FOREACH_CONST( RString, vs, s ) - { - if( !IsPackageFile(*s) ) - { - vFailed.push_back( FileCopyResult(*s,"wrong file extension") ); - continue; - } - - RString sOsDir, sFilename, sExt; - splitpath( *s, sOsDir, sFilename, sExt ); - - FILEMAN->Mount( "dir", sOsDir, TEMP_ZIP_MOUNT_POINT ); - - // TODO: Validate that this zip contains files for this version of StepMania - - bool bFileExists = DoesFileExist( SpecialFiles::USER_PACKAGES_DIR + sFilename + sExt ); - if( FileCopy( TEMP_ZIP_MOUNT_POINT + sFilename + sExt, SpecialFiles::USER_PACKAGES_DIR + sFilename + sExt ) ) - vSucceeded.push_back( FileCopyResult(*s,bFileExists ? "overwrote existing file" : "") ); - else - vFailed.push_back( FileCopyResult(*s,ssprintf("error copying file to '%s'",sOsDir.c_str())) ); - - FILEMAN->Unmount( "dir", sOsDir, TEMP_ZIP_MOUNT_POINT ); - } - if( vSucceeded.empty() && vFailed.empty() ) - { - Dialog::OK( "Install: no files specified" ); - return; - } - - - RString sMessage; - for( int i=0; i<2; i++ ) - { - const vector &v = (i==0) ? vSucceeded : vFailed; - if( !v.empty() ) - { - sMessage += (i==0) ? "Install succeeded for:\n" : "Install failed for:\n"; - FOREACH_CONST( FileCopyResult, v, iter ) - { - sMessage += " - " + iter->sFile; - if( !iter->sComment.empty() ) - sMessage += " : " + iter->sComment; - sMessage += "\n"; - } - sMessage += "\n"; - } - } - Dialog::OK( sMessage ); -} - -void CommandLineActions::Nsis() +static void Nsis() { RageFile out; - if( !out.Open( "nsis_strings_temp.inc", RageFile::WRITE ) ) - RageException::Throw( "Error opening file for write." ); + if(!out.Open("nsis_strings_temp.inc", RageFile::WRITE)) + RageException::Throw("Error opening file for write."); vector vs; - GetDirListing( INSTALLER_LANGUAGES_DIR + "*.ini", vs, false, false ); - FOREACH_CONST( RString, vs, s ) + GetDirListing(INSTALLER_LANGUAGES_DIR + "*.ini", vs, false, false); + FOREACH_CONST(RString, vs, s) { RString sThrowAway, sLangCode; - splitpath( *s, sThrowAway, sLangCode, sThrowAway ); - const LanguageInfo *pLI = GetLanguageInfo( sLangCode ); + splitpath(*s, sThrowAway, sLangCode, sThrowAway); + const LanguageInfo *pLI = GetLanguageInfo(sLangCode); RString sLangNameUpper = pLI->szEnglishName; sLangNameUpper.MakeUpper(); IniFile ini; - if( !ini.ReadFile( INSTALLER_LANGUAGES_DIR + *s ) ) - RageException::Throw( "Error opening file for read." ); - FOREACH_CONST_Child( &ini, child ) + if(!ini.ReadFile(INSTALLER_LANGUAGES_DIR + *s)) + RageException::Throw("Error opening file for read."); + FOREACH_CONST_Child(&ini, child) { - FOREACH_CONST_Attr( child, attr ) + FOREACH_CONST_Attr(child, attr) { RString sName = attr->first; RString sValue = attr->second->GetValue(); - sValue.Replace( "\\n", "$\\n" ); - RString sLine = ssprintf( "LangString %s ${LANG_%s} \"%s\"", sName.c_str(), sLangNameUpper.c_str(), sValue.c_str() ); - out.PutLine( sLine ); + sValue.Replace("\\n", "$\\n"); + RString sLine = ssprintf("LangString %s ${LANG_%s} \"%s\"", sName.c_str(), sLangNameUpper.c_str(), sValue.c_str()); + out.PutLine(sLine); } } } } - -void CommandLineActions::LuaInformation() +static void LuaInformation() { XNode *pNode = LuaHelpers::GetLuaInformation(); - pNode->AppendAttr( "xmlns", "http://www.stepmania.com" ); - pNode->AppendAttr( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - pNode->AppendAttr( "xsi:schemaLocation", "http://www.stepmania.com Lua.xsd" ); + pNode->AppendAttr("xmlns", "http://www.stepmania.com"); + pNode->AppendAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + pNode->AppendAttr("xsi:schemaLocation", "http://www.stepmania.com Lua.xsd"); - pNode->AppendChild( "Version", PRODUCT_ID_VER ); - pNode->AppendChild( "Date", DateTime::GetNowDate().GetString() ); + pNode->AppendChild("Version", PRODUCT_ID_VER); + pNode->AppendChild("Date", DateTime::GetNowDate().GetString()); - XmlFileUtil::SaveToFile( pNode, "Lua.xml", "Lua.xsl" ); + XmlFileUtil::SaveToFile(pNode, "Lua.xml", "Lua.xsl"); delete pNode; } @@ -179,26 +82,53 @@ extern const char *const version_date; extern const char *const version_time; #endif -void CommandLineActions::Version() +static void Version() { /* HACK: This is only needed on Windows. Mac and Linux print out version information on the command line regardless of any preferences (tested by shakesoda on Mac). -aj */ - #if defined(WIN32) && !defined(_XBOX) - RString sProductID = ssprintf( "%s", PRODUCT_ID_VER ); + #if defined(WIN32) + RString sProductID = ssprintf("%s", PRODUCT_ID_VER); RString sVersion = "(sm-ssc was built without HAVE_VERSION_INFO)"; #if defined(HAVE_VERSION_INFO) - sVersion = ssprintf( "build %lu\nCompile Date: %s @ %s", version_num, version_date, version_time ); + sVersion = ssprintf("build %lu\nCompile Date: %s @ %s", version_num, version_date, version_time); #endif // HAVE_VERSION_INFO AllocConsole(); - freopen( "CONOUT$","wb", stdout ); - freopen( "CONOUT$","wb", stderr ); + freopen("CONOUT$","wb", stdout); + freopen("CONOUT$","wb", stderr); - fprintf(stdout, "Version Information:\n%s %s\n", sProductID.c_str(), sVersion.c_str() ); - fprintf(stdout, "Press any key to exit." ); + fprintf(stdout, "Version Information:\n%s %s\n", sProductID.c_str(), sVersion.c_str()); + fprintf(stdout, "Press any key to exit."); _getch(); - #endif // WIN32 && !_XBOX + #endif // WIN32 +} + +void CommandLineActions::Handle(LoadingWindow* pLW) +{ + CommandLineArgs args; + for(int i=0; i argv; + }; + // a list of command line arguemnts to process while the game is running. + // These args could have come from this process or passed to this process + // from another process. + extern vector ToProcess; } #endif diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index 77a1c77651..df779a3dbd 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -14,7 +14,6 @@ #include "UnlockManager.h" #include "SongUtil.h" - static const char *EditMenuRowNames[] = { "Group", "Song", @@ -38,10 +37,8 @@ XToLocalizedString( EditMenuAction ); StringToX( EditMenuAction ); static RString ARROWS_X_NAME( size_t i ) { return ssprintf("Arrows%dX",int(i+1)); } -static RString ROW_VALUE_X_NAME( size_t i ) { return ssprintf("RowValue%dX",int(i+1)); } static RString ROW_Y_NAME( size_t i ) { return ssprintf("Row%dY",int(i+1)); } - void EditMenu::StripLockedStepsAndDifficulty( vector &v ) { const Song *pSong = GetSelectedSong(); @@ -110,14 +107,6 @@ void EditMenu::Load( const RString &sType ) ARROWS_X.Load(sType,ARROWS_X_NAME,NUM_ARROWS); ARROWS_ENABLED_COMMAND.Load(sType,"ArrowsEnabledCommand"); ARROWS_DISABLED_COMMAND.Load(sType,"ArrowsDisabledCommand"); - SONG_BANNER_WIDTH.Load(sType,"SongBannerWidth"); - SONG_BANNER_HEIGHT.Load(sType,"SongBannerHeight"); - GROUP_BANNER_WIDTH.Load(sType,"GroupBannerWidth"); - GROUP_BANNER_HEIGHT.Load(sType,"GroupBannerHeight"); - ROW_LABELS_X.Load(sType,"RowLabelsX"); - ROW_LABEL_ON_COMMAND.Load(sType,"RowLabelOnCommand"); - ROW_VALUE_X.Load(sType,ROW_VALUE_X_NAME,NUM_EditMenuRow); - ROW_VALUE_ON_COMMAND.Load(sType,"RowValueOnCommand"); ROW_Y.Load(sType,ROW_Y_NAME,NUM_EditMenuRow); EDIT_MODE.Load(sType,"EditMode"); TEXT_BANNER_TYPE.Load( m_sName, "TextBannerType" ); @@ -133,39 +122,39 @@ void EditMenu::Load( const RString &sType ) ZERO( m_iSelection ); - FOREACH_EditMenuRow( r ) { + m_textLabel[r].SetName(ssprintf("Label%i",r+1)); m_textLabel[r].LoadFromFont( THEME->GetPathF(sType,"title") ); - m_textLabel[r].SetXY( ROW_LABELS_X, ROW_Y.GetValue(r) ); m_textLabel[r].SetText( EditMenuRowToLocalizedString(r) ); - m_textLabel[r].RunCommands( ROW_LABEL_ON_COMMAND ); - m_textLabel[r].SetHorizAlign( align_left ); + ActorUtil::LoadAllCommandsAndSetXY( m_textLabel[r], sType ); + //m_textLabel[r].SetHorizAlign( align_left ); this->AddChild( &m_textLabel[r] ); + m_textValue[r].SetName(ssprintf("Value%i",r+1)); m_textValue[r].LoadFromFont( THEME->GetPathF(sType,"value") ); - m_textValue[r].SetXY( ROW_VALUE_X.GetValue(r), ROW_Y.GetValue(r) ); m_textValue[r].SetText( "blah" ); - m_textValue[r].RunCommands( ROW_VALUE_ON_COMMAND ); + ActorUtil::LoadAllCommandsAndSetXY( m_textValue[r], sType ); this->AddChild( &m_textValue[r] ); } m_textLabel[ROW_GROUP].SetVisible( SHOW_GROUPS.GetValue() ); m_textValue[ROW_GROUP].SetVisible( SHOW_GROUPS.GetValue() ); - - /* Load low-res banners, if needed. */ + // Load low-res banners, if needed. BANNERCACHE->Demand(); if( SHOW_GROUPS.GetValue() ) { m_GroupBanner.SetName( "GroupBanner" ); ActorUtil::SetXY( m_GroupBanner, sType ); + ActorUtil::LoadAllCommands( m_GroupBanner, sType ); this->AddChild( &m_GroupBanner ); } m_SongBanner.SetName( "SongBanner" ); ActorUtil::SetXY( m_SongBanner, sType ); + ActorUtil::LoadAllCommands( m_SongBanner, sType ); this->AddChild( &m_SongBanner ); m_SongTextBanner.SetName( "SongTextBanner" ); @@ -173,12 +162,12 @@ void EditMenu::Load( const RString &sType ) ActorUtil::SetXY( m_SongTextBanner, sType ); ActorUtil::LoadAllCommands( m_SongTextBanner, sType ); this->AddChild( &m_SongTextBanner ); - + m_StepsDisplay.SetName( "StepsDisplay" ); m_StepsDisplay.Load( "StepsDisplayEdit", NULL ); ActorUtil::SetXY( m_StepsDisplay, sType ); this->AddChild( &m_StepsDisplay ); - + m_StepsDisplaySource.SetName( "StepsDisplaySource" ); m_StepsDisplaySource.Load( "StepsDisplayEdit", NULL ); ActorUtil::SetXY( m_StepsDisplaySource, sType ); @@ -187,13 +176,10 @@ void EditMenu::Load( const RString &sType ) m_soundChangeRow.Load( THEME->GetPathS(sType,"row"), true ); m_soundChangeValue.Load( THEME->GetPathS(sType,"value"), true ); - // // fill in data structures - // GetGroupsToShow( m_sGroups ); m_StepsTypes = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue(); - RefreshAll(); } @@ -253,7 +239,7 @@ bool EditMenu::CanGoDown() bool EditMenu::CanGoLeft() { if( m_SelectedRow == ROW_SONG || m_SelectedRow == ROW_GROUP ) - return true; /* wraps */ + return true; // wraps return m_iSelection[m_SelectedRow] != 0; } @@ -261,12 +247,12 @@ int EditMenu::GetRowSize( EditMenuRow er ) const { switch( er ) { - case ROW_GROUP: return m_sGroups.size(); + case ROW_GROUP: return m_sGroups.size(); case ROW_SONG: return m_pSongs.size(); - case ROW_STEPS_TYPE: return m_StepsTypes.size(); - case ROW_STEPS: return m_vpSteps.size(); + case ROW_STEPS_TYPE: return m_StepsTypes.size(); + case ROW_STEPS: return m_vpSteps.size(); case ROW_SOURCE_STEPS_TYPE: return m_StepsTypes.size(); - case ROW_SOURCE_STEPS: return m_vpSourceSteps.size(); + case ROW_SOURCE_STEPS: return m_vpSourceSteps.size(); case ROW_ACTION: return m_Actions.size(); default: FAIL_M( ssprintf("%i", er) ); } @@ -276,7 +262,7 @@ int EditMenu::GetRowSize( EditMenuRow er ) const bool EditMenu::CanGoRight() { if( m_SelectedRow == ROW_SONG || m_SelectedRow == ROW_GROUP ) - return true; /* wraps */ + return true; // wraps return m_iSelection[m_SelectedRow] != GetRowSize(m_SelectedRow)-1; } @@ -344,9 +330,13 @@ void EditMenu::Right() } } - void EditMenu::ChangeToRow( EditMenuRow newRow ) { + m_textLabel[newRow].PlayCommand("GainFocus"); + m_textValue[newRow].PlayCommand("GainFocus"); + m_textLabel[m_SelectedRow].PlayCommand("LoseFocus"); + m_textValue[m_SelectedRow].PlayCommand("LoseFocus"); + m_SelectedRow = newRow; for( int i=0; i<2; i++ ) @@ -374,7 +364,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) if( SHOW_GROUPS.GetValue() ) { m_GroupBanner.LoadFromSongGroup( GetSelectedGroup() ); - m_GroupBanner.ScaleToClipped( GROUP_BANNER_WIDTH, GROUP_BANNER_HEIGHT ); + m_GroupBanner.PlayCommand("Changed"); } m_pSongs.clear(); GetSongsToShowForGroup( GetSelectedGroup(), m_pSongs ); @@ -383,7 +373,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) case ROW_SONG: m_textValue[ROW_SONG].SetText( "" ); m_SongBanner.LoadFromSong( GetSelectedSong() ); - m_SongBanner.ScaleToClipped( SONG_BANNER_WIDTH, SONG_BANNER_HEIGHT ); + m_SongBanner.PlayCommand("Changed"); m_SongTextBanner.SetFromSong( GetSelectedSong() ); // fall through @@ -461,7 +451,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } } StripLockedStepsAndDifficulty( m_vpSteps ); - + FOREACH( StepsAndDifficulty, m_vpSteps, s ) { if( s->dc == dcOld ) @@ -572,7 +562,6 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } } - /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/src/EditMenu.h b/src/EditMenu.h index b816250a9e..0d03ef1e04 100644 --- a/src/EditMenu.h +++ b/src/EditMenu.h @@ -97,7 +97,6 @@ private: StepsDisplay m_StepsDisplay; StepsDisplay m_StepsDisplaySource; - struct StepsAndDifficulty { StepsAndDifficulty( Steps *s, Difficulty d ) { pSteps = s; dc = d; } @@ -122,16 +121,6 @@ private: ThemeMetric1D ARROWS_X; ThemeMetric ARROWS_ENABLED_COMMAND; ThemeMetric ARROWS_DISABLED_COMMAND; - // todo: remove these next 4 metrics in favor of commands -aj - ThemeMetric SONG_BANNER_WIDTH; - ThemeMetric SONG_BANNER_HEIGHT; - ThemeMetric GROUP_BANNER_WIDTH; - ThemeMetric GROUP_BANNER_HEIGHT; - // - ThemeMetric ROW_LABELS_X; - ThemeMetric ROW_LABEL_ON_COMMAND; - ThemeMetric1D ROW_VALUE_X; - ThemeMetric ROW_VALUE_ON_COMMAND; ThemeMetric1D ROW_Y; public: ThemeMetric EDIT_MODE; diff --git a/src/FileDownload.cpp b/src/FileDownload.cpp index 852f76d32b..a9a9678f4a 100644 --- a/src/FileDownload.cpp +++ b/src/FileDownload.cpp @@ -6,8 +6,10 @@ #include "RageFileManager.h" #include "SpecialFiles.h" #include "RageLog.h" +#include "Preference.h" +#include "Foreach.h" -FileDownload::FileDownload() +FileTransfer::FileTransfer() { m_iPackagesPos = 0; m_iLinksPos = 0; @@ -21,31 +23,28 @@ FileDownload::FileDownload() UpdateProgress(); // Workaround: For some reason, the first download sometimes corrupts; - // by opening and closing the RageFile, this problem does not occur. + // by opening and closing the RageFile, this problem does not occur. // Go figure? - // XXX: This is a really dirty work around! Why does RageFile do this? - - // It's always some strange number of bytes at the end of the - // file when it corrupts. - m_fOutputFile.Open( "Packages/dummy.txt", RageFile::WRITE ); + // It's always some strange number of bytes at the end of the file when it corrupts. + m_fOutputFile.Open("Packages/dummy.txt", RageFile::WRITE); m_fOutputFile.Close(); } -FileDownload::~FileDownload() +FileTransfer::~FileTransfer() { m_fOutputFile.Close(); } -RString FileDownload::Update( float fDeltaTime ) +RString FileTransfer::Update( float fDeltaTime ) { HTTPUpdate(); m_fLastUpdate += fDeltaTime; - if ( m_fLastUpdate >= 1.0 ) + if (m_fLastUpdate >= 1.0) { - if ( m_bIsDownloading && m_bGotHeader ) - m_sStatus = ssprintf( "DL @ %d KB/s", int((m_iDownloaded-m_bytesLastUpdate)/1024) ); + if (m_bIsDownloading && m_bGotHeader) + m_sStatus = ssprintf("DL @ %d KB/s", int((m_iDownloaded-m_bytesLastUpdate)/1024)); m_bytesLastUpdate = m_iDownloaded; UpdateProgress(); @@ -55,7 +54,7 @@ RString FileDownload::Update( float fDeltaTime ) return m_sStatus; } -void FileDownload::UpdateProgress() +void FileTransfer::UpdateProgress() { float DownloadedRatio; @@ -65,7 +64,7 @@ void FileDownload::UpdateProgress() DownloadedRatio = float(m_iDownloaded) / float(m_iTotalBytes); } -void FileDownload::CancelDownload( ) +void FileTransfer::Cancel() { m_wSocket.close(); m_bIsDownloading = false; @@ -74,10 +73,22 @@ void FileDownload::CancelDownload( ) m_fOutputFile.Close(); m_sStatus = "Failed."; m_sBUFFER = ""; - FILEMAN->Remove( "Packages/" + m_sEndName ); + FILEMAN->Remove("Packages/" + m_sEndName); } -void FileDownload::StartDownload( const RString &sURL, const RString &sDestFile ) +void FileTransfer::StartDownload( const RString &sURL, const RString &sDestFile ) +{ + StartTransfer( download, sURL, "", sDestFile ); +} + +void FileTransfer::StartUpload( const RString &sURL, const RString &sSrcFile, const RString &sDestFile ) +{ + StartTransfer( upload, sURL, sSrcFile, sDestFile ); +} + +extern Preference g_sCookie; + +void FileTransfer::StartTransfer( TransferType type, const RString &sURL, const RString &sSrcFile, const RString &sDestFile ) { RString Proto; RString Server; @@ -87,16 +98,12 @@ void FileDownload::StartDownload( const RString &sURL, const RString &sDestFile if( !ParseHTTPAddress( sURL, Proto, Server, Port, sAddress ) ) { m_sStatus = "Invalid URL."; + m_bFinished = true; UpdateProgress(); return; } - //Determine if this is a website, or a package? - //Criteria: does it end with *zip? - if( sAddress.Right(3).CompareNoCase("zip") == 0 ) - m_bIsPackage=true; - else - m_bIsPackage = false; + m_bSavingFile = sDestFile != ""; m_sBaseAddress = "http://" + Server; if( Port != 80 ) @@ -113,24 +120,15 @@ void FileDownload::StartDownload( const RString &sURL, const RString &sDestFile m_sEndName = ""; } - //Open the file... + // Open the file... - //First find out if a file by this name already exists - //if so, then we gotta ditch out. - //XXX: This should be fixed by a prompt or something? + // First find out if a file by this name already exists if so, then we gotta + // ditch out. + // XXX: This should be fixed by a prompt or something? - //if we are not talking about a file, let's not worry - if( m_sEndName != "" && m_bIsPackage ) + // if we are not talking about a file, let's not worry + if( m_sEndName != "" && m_bSavingFile ) { - vector AddTo; - GetDirListing( "Packages/"+m_sEndName, AddTo, false, false ); - if ( AddTo.size() > 0 ) - { - m_sStatus = "File Already Exists"; - UpdateProgress(); - return; - } - if( !m_fOutputFile.Open( sDestFile, RageFile::WRITE | RageFile::STREAMED ) ) { m_sStatus = m_fOutputFile.GetError(); @@ -138,7 +136,7 @@ void FileDownload::StartDownload( const RString &sURL, const RString &sDestFile return; } } - //Continue... + // Continue... sAddress = URLEncode( sAddress ); @@ -157,15 +155,64 @@ void FileDownload::StartDownload( const RString &sURL, const RString &sDestFile return; } - //Produce HTTP header + // Produce HTTP header + RString sAction; + switch( type ) + { + case upload: sAction = "POST"; break; + case download: sAction = "GET"; break; + } - RString Header=""; + vector vsHeaders; + vsHeaders.push_back( sAction+" "+sAddress+" HTTP/1.0" ); + vsHeaders.push_back( "Host: " + Server ); + vsHeaders.push_back( "Cookie: " + g_sCookie.Get() ); + vsHeaders.push_back( "Connection: closed" ); + string sBoundary = "--ZzAaB03x"; + vsHeaders.push_back( "Content-Type: multipart/form-data; boundary=" + sBoundary ); + RString sRequestPayload; + if( type == upload ) + { + RageFile f; + if( !f.Open( sSrcFile ) ) + FAIL_M( f.GetError() ); + sRequestPayload.reserve( f.GetFileSize() ); + int iBytesRead = f.Read( sRequestPayload ); + if( iBytesRead == -1 ) + FAIL_M( f.GetError() ); - Header = "GET "+sAddress+" HTTP/1.0\r\n"; - Header+= "Host: " + Server + "\r\n"; - Header+= "Connection: closed\r\n\r\n"; + sRequestPayload = "--" + sBoundary + "\r\n" + + "Content-Disposition: form-data; name=\"name\"\r\n" + + "\r\n" + + "Chris\r\n" + + "--" + sBoundary + "\r\n" + + "Content-Disposition: form-data; name=\"userfile\"; filename=\"" + Basename(sSrcFile) + "\"\r\n" + + "Content-Type: application/zip\r\n" + + "\r\n" + + sRequestPayload + "\r\n" + + "--" + sBoundary + "--"; + } + /* + if( sRequestPayload.size() > 0 ) + { + sHeader += "Content-Type: application/octet-stream\r\n"; + sHeader += "Content-Length: multipart/form-data; boundary=" + sBoundary + "\r\n"; + //sHeader += "Content-Length: " + ssprintf("%d",sRequestPayload.size()) + "\r\n"; + } + */ + + vsHeaders.push_back( "Content-Length: " + ssprintf("%d",sRequestPayload.size()) ); + + RString sHeader; + FOREACH_CONST( RString, vsHeaders, h ) + sHeader += *h + "\r\n"; + sHeader += "\r\n"; + + m_wSocket.SendData( sHeader.c_str(), sHeader.length() ); + m_wSocket.SendData( "\r\n" ); + + m_wSocket.SendData( sRequestPayload.GetBuffer(), sRequestPayload.size() ); - m_wSocket.SendData( Header.c_str(), Header.length() ); m_sStatus = "Header Sent."; m_wSocket.blocking = false; m_bIsDownloading = true; @@ -187,14 +234,13 @@ static size_t FindEndOfHeaders( const RString &buf ) return string::npos; } -void FileDownload::HTTPUpdate() +void FileTransfer::HTTPUpdate() { if( !m_bIsDownloading ) return; int BytesGot=0; - //Keep this as a code block - //as there may be need to "if" it out some time. + // Keep this as a code block, as there may be need to "if" it out some time. /* If you need a conditional for a large block of code, stick it in * a function and return. */ while(1) @@ -211,7 +257,7 @@ void FileDownload::HTTPUpdate() if( !m_bGotHeader ) { m_sStatus = "Waiting for header."; - //We don't know if we are using unix-style or dos-style + // We don't know if we are using unix-style or dos-style size_t iHeaderEnd = FindEndOfHeaders( m_sBUFFER ); if( iHeaderEnd == m_sBUFFER.npos ) return; @@ -235,20 +281,20 @@ void FileDownload::HTTPUpdate() if( i != string::npos ) m_iTotalBytes = atoi(m_sBUFFER.substr(i+16,j-i).c_str()); else - m_iTotalBytes = -1; //We don't know, so go until disconnect + m_iTotalBytes = -1; // We don't know, so go until disconnect m_bGotHeader = true; m_sBUFFER.erase( 0, iHeaderEnd ); } - if( m_bIsPackage ) + if( m_bSavingFile ) { m_iDownloaded += m_sBUFFER.length(); m_fOutputFile.Write( m_sBUFFER ); - // HACK: We're ending up with incomplete files after close() if we don't flush here. Why? + // HACK: We're ending up with incomplete files after close() if we don't flush here. Why? m_fOutputFile.Flush(); - + m_sBUFFER = ""; } else @@ -260,8 +306,8 @@ void FileDownload::HTTPUpdate() //We have the full doc. (And we knew how big it was) ( m_iTotalBytes == -1 && ( m_wSocket.state == EzSockets::skERROR || m_wSocket.state == EzSockets::skDISCONNECTED ) ) ) - //We didn't know how big it was, and were disconnected - //So that means we have it all. + // We didn't know how big it was, and were disconnected + // So that means we have it all. { m_wSocket.close(); m_bIsDownloading = false; @@ -275,7 +321,7 @@ void FileDownload::HTTPUpdate() } else { - if( m_bIsPackage && m_iResponseCode < 300 ) + if( m_bSavingFile && m_iResponseCode < 300 ) { RString sZipFile = m_fOutputFile.GetRealPath(); m_fOutputFile.Close(); @@ -286,7 +332,7 @@ void FileDownload::HTTPUpdate() } } -bool FileDownload::ParseHTTPAddress( const RString &URL, RString &sProto, RString &sServer, int &iPort, RString &sAddress ) +bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RString &sServer, int &iPort, RString &sAddress ) { // [PROTO://]SERVER[:PORT][/URL] @@ -316,9 +362,16 @@ bool FileDownload::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin return true; } -bool FileDownload::IsFinished() +void FileTransfer::Finish() { - return m_bFinished; + while( true ) + { + float fSleepSeconds = 0.1f; + this->Update( fSleepSeconds ); + usleep( int( fSleepSeconds * 1000000.0 ) ); + if( this->IsFinished() ) + break; + } } #endif diff --git a/src/FileDownload.h b/src/FileDownload.h index ad026309cc..71147bd565 100644 --- a/src/FileDownload.h +++ b/src/FileDownload.h @@ -1,33 +1,40 @@ -/* FileDownload - Downloads a file from the Internet. */ -#ifndef ScreenPackages_H -#define ScreenPackages_H +#ifndef FileTransfer_H +#define FileTransfer_H #if !defined(WITHOUT_NETWORKING) -#include "EzSockets.h" +#include "ezsockets.h" #include "RageFile.h" -class FileDownload +class FileTransfer { public: - FileDownload(); - ~FileDownload(); + FileTransfer(); + ~FileTransfer(); - void StartDownload( const RString &sURL, const RString &sDestFile ); - void CancelDownload( ); + void StartDownload(const RString &sURL, const RString &sDestFile); + void StartUpload(const RString &sURL, const RString &sSrcFile, const RString &sDestFile); + + void Cancel(); RString Update(float fDeltaTime); - bool IsFinished(); + bool IsFinished() const { return m_bFinished; } + void Finish(); + int GetResponseCode() const { return m_iResponseCode; } + RString GetResponse() const { return m_sBUFFER; } + RString GetStatus() const { return m_sStatus; } private: + enum TransferType { download, upload }; + void StartTransfer(TransferType type, const RString &sURL, const RString &sSrcFile, const RString &sDestFile); int m_iPackagesPos; int m_iLinksPos; int m_iDLorLST; // HTTP portion - void HTTPUpdate( ); + void HTTPUpdate(); // True if proper string, false if improper - bool ParseHTTPAddress( const RString & URL, RString & Proto, RString & Server, int & Port, RString & Addy ); + bool ParseHTTPAddress(const RString & URL, RString & Proto, RString & Server, int & Port, RString & Addy); void UpdateProgress(); @@ -43,10 +50,10 @@ private: RageFile m_fOutputFile; RString m_sEndName; - bool m_bIsPackage; + bool m_bSavingFile; RString m_sBaseAddress; - // HTTP Header information response + // HTTP Header information responce long m_iTotalBytes; long m_iDownloaded; diff --git a/src/FontCharmaps.cpp b/src/FontCharmaps.cpp index 413aca508c..84e59a580a 100644 --- a/src/FontCharmaps.cpp +++ b/src/FontCharmaps.cpp @@ -195,7 +195,7 @@ static const wchar_t map_korean_jamo[] = 0 }; -/* 5x3 Numbers. "0123456789%. :x" */ +/* 5x3 Numbers. "01234 56789 %. :x" */ static const wchar_t map_numbers[] = { 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, diff --git a/src/GameManager.cpp b/src/GameManager.cpp index fd31199740..29d229df79 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -645,20 +645,20 @@ static const Style g_Style_Pump_HalfDouble = 6, // m_iColsPerPlayer { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; { // PLAYER_1 - { TRACK_1, -PUMP_COL_SPACING*2.5f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*1.5f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*0.5f-5, NULL }, - { TRACK_4, +PUMP_COL_SPACING*0.5f+5, NULL }, - { TRACK_5, +PUMP_COL_SPACING*1.5f+5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*2.5f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*2.5f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*1.5f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*0.5f-4, NULL }, + { TRACK_4, +PUMP_COL_SPACING*0.5f+4, NULL }, + { TRACK_5, +PUMP_COL_SPACING*1.5f+4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*2.5f+4, NULL }, }, { // PLAYER_2 - { TRACK_1, -PUMP_COL_SPACING*2.5f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*1.5f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*0.5f-5, NULL }, - { TRACK_4, +PUMP_COL_SPACING*0.5f+5, NULL }, - { TRACK_5, +PUMP_COL_SPACING*1.5f+5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*2.5f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*2.5f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*1.5f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*0.5f-4, NULL }, + { TRACK_4, +PUMP_COL_SPACING*0.5f+4, NULL }, + { TRACK_5, +PUMP_COL_SPACING*1.5f+4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*2.5f+4, NULL }, }, }, { // m_iInputColumn[NUM_GameController][NUM_GameButton] @@ -685,28 +685,28 @@ static const Style g_Style_Pump_Double = 10, // m_iColsPerPlayer { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; { // PLAYER_1 - { TRACK_1, -PUMP_COL_SPACING*4.5f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*3.5f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*2.5f-5, NULL }, - { TRACK_4, -PUMP_COL_SPACING*1.5f-5, NULL }, - { TRACK_5, -PUMP_COL_SPACING*0.5f-5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*0.5f+5, NULL }, - { TRACK_7, +PUMP_COL_SPACING*1.5f+5, NULL }, - { TRACK_8, +PUMP_COL_SPACING*2.5f+5, NULL }, - { TRACK_9, +PUMP_COL_SPACING*3.5f+5, NULL }, - { TRACK_10, +PUMP_COL_SPACING*4.5f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*4.5f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*3.5f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*2.5f-4, NULL }, + { TRACK_4, -PUMP_COL_SPACING*1.5f-4, NULL }, + { TRACK_5, -PUMP_COL_SPACING*0.5f-4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*0.5f+4, NULL }, + { TRACK_7, +PUMP_COL_SPACING*1.5f+4, NULL }, + { TRACK_8, +PUMP_COL_SPACING*2.5f+4, NULL }, + { TRACK_9, +PUMP_COL_SPACING*3.5f+4, NULL }, + { TRACK_10, +PUMP_COL_SPACING*4.5f+4, NULL }, }, { // PLAYER_2 - { TRACK_1, -PUMP_COL_SPACING*4.5f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*3.5f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*2.5f-5, NULL }, - { TRACK_4, -PUMP_COL_SPACING*1.5f-5, NULL }, - { TRACK_5, -PUMP_COL_SPACING*0.5f-5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*0.5f+5, NULL }, - { TRACK_7, +PUMP_COL_SPACING*1.5f+5, NULL }, - { TRACK_8, +PUMP_COL_SPACING*2.5f+5, NULL }, - { TRACK_9, +PUMP_COL_SPACING*3.5f+5, NULL }, - { TRACK_10, +PUMP_COL_SPACING*4.5f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*4.5f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*3.5f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*2.5f-4, NULL }, + { TRACK_4, -PUMP_COL_SPACING*1.5f-4, NULL }, + { TRACK_5, -PUMP_COL_SPACING*0.5f-4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*0.5f+4, NULL }, + { TRACK_7, +PUMP_COL_SPACING*1.5f+4, NULL }, + { TRACK_8, +PUMP_COL_SPACING*2.5f+4, NULL }, + { TRACK_9, +PUMP_COL_SPACING*3.5f+4, NULL }, + { TRACK_10, +PUMP_COL_SPACING*4.5f+4, NULL }, }, }, { // m_iInputColumn[NUM_GameController][NUM_GameButton] @@ -771,16 +771,16 @@ static const Style g_Style_Pump_Couple_Edit = 10, // m_iColsPerPlayer { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; { // PLAYER_1 - { TRACK_1, -PUMP_COL_SPACING*5.0f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*4.0f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*3.0f-5, NULL }, - { TRACK_4, -PUMP_COL_SPACING*2.0f-5, NULL }, - { TRACK_5, -PUMP_COL_SPACING*1.0f-5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*1.0f+5, NULL }, - { TRACK_7, +PUMP_COL_SPACING*2.0f+5, NULL }, - { TRACK_8, +PUMP_COL_SPACING*3.0f+5, NULL }, - { TRACK_9, +PUMP_COL_SPACING*4.0f+5, NULL }, - { TRACK_10, +PUMP_COL_SPACING*5.0f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*5.0f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*4.0f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*3.0f-4, NULL }, + { TRACK_4, -PUMP_COL_SPACING*2.0f-4, NULL }, + { TRACK_5, -PUMP_COL_SPACING*1.0f-4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*1.0f+4, NULL }, + { TRACK_7, +PUMP_COL_SPACING*2.0f+4, NULL }, + { TRACK_8, +PUMP_COL_SPACING*3.0f+4, NULL }, + { TRACK_9, +PUMP_COL_SPACING*4.0f+4, NULL }, + { TRACK_10, +PUMP_COL_SPACING*5.0f+4, NULL }, }, { // PLAYER_2 { TRACK_1, -PUMP_COL_SPACING*2.0f, NULL }, @@ -814,28 +814,28 @@ static const Style g_Style_Pump_Routine = 10, // m_iColsPerPlayer { // m_ColumnInfo[NUM_PLAYERS][MAX_COLS_PER_PLAYER]; { // PLAYER_1 - { TRACK_1, -PUMP_COL_SPACING*4.6f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*3.6f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*2.6f-5, NULL }, - { TRACK_4, -PUMP_COL_SPACING*1.6f-5, NULL }, - { TRACK_5, -PUMP_COL_SPACING*0.6f-5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*0.6f+5, NULL }, - { TRACK_7, +PUMP_COL_SPACING*1.6f+5, NULL }, - { TRACK_8, +PUMP_COL_SPACING*2.6f+5, NULL }, - { TRACK_9, +PUMP_COL_SPACING*3.6f+5, NULL }, - { TRACK_10, +PUMP_COL_SPACING*4.6f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*4.6f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*3.6f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*2.6f-4, NULL }, + { TRACK_4, -PUMP_COL_SPACING*1.6f-4, NULL }, + { TRACK_5, -PUMP_COL_SPACING*0.6f-4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*0.6f+4, NULL }, + { TRACK_7, +PUMP_COL_SPACING*1.6f+4, NULL }, + { TRACK_8, +PUMP_COL_SPACING*2.6f+4, NULL }, + { TRACK_9, +PUMP_COL_SPACING*3.6f+4, NULL }, + { TRACK_10, +PUMP_COL_SPACING*4.6f+4, NULL }, }, { // PLAYER_2 - { TRACK_1, -PUMP_COL_SPACING*4.6f-5, NULL }, - { TRACK_2, -PUMP_COL_SPACING*3.6f-5, NULL }, - { TRACK_3, -PUMP_COL_SPACING*2.6f-5, NULL }, - { TRACK_4, -PUMP_COL_SPACING*1.6f-5, NULL }, - { TRACK_5, -PUMP_COL_SPACING*0.6f-5, NULL }, - { TRACK_6, +PUMP_COL_SPACING*0.6f+5, NULL }, - { TRACK_7, +PUMP_COL_SPACING*1.6f+5, NULL }, - { TRACK_8, +PUMP_COL_SPACING*2.6f+5, NULL }, - { TRACK_9, +PUMP_COL_SPACING*3.6f+5, NULL }, - { TRACK_10, +PUMP_COL_SPACING*4.6f+5, NULL }, + { TRACK_1, -PUMP_COL_SPACING*4.6f-4, NULL }, + { TRACK_2, -PUMP_COL_SPACING*3.6f-4, NULL }, + { TRACK_3, -PUMP_COL_SPACING*2.6f-4, NULL }, + { TRACK_4, -PUMP_COL_SPACING*1.6f-4, NULL }, + { TRACK_5, -PUMP_COL_SPACING*0.6f-4, NULL }, + { TRACK_6, +PUMP_COL_SPACING*0.6f+4, NULL }, + { TRACK_7, +PUMP_COL_SPACING*1.6f+4, NULL }, + { TRACK_8, +PUMP_COL_SPACING*2.6f+4, NULL }, + { TRACK_9, +PUMP_COL_SPACING*3.6f+4, NULL }, + { TRACK_10, +PUMP_COL_SPACING*4.6f+4, NULL }, }, }, { // m_iInputColumn[NUM_GameController][NUM_GameButton] diff --git a/src/GameState.cpp b/src/GameState.cpp index 7e89e385f3..8194bbbeed 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -2448,6 +2448,13 @@ public: DEFINE_METHOD( GetCurMusicSeconds, m_fMusicSeconds ) DEFINE_METHOD( GetWorkoutGoalComplete, m_bWorkoutGoalComplete ) + static int GetCharacter( T* p, lua_State *L ) { p->m_pCurCharacters[Enum::Check(L, 1)]->PushSelf(L); return 1; } + static int SetCharacter( T* p, lua_State *L ){ + Character* c = CHARMAN->GetCharacterFromID(SArg(2)); + if (c) + p->m_pCurCharacters[Enum::Check(L, 1)] = c; + return 0; + } LunaGameState() { @@ -2543,6 +2550,8 @@ public: ADD_METHOD( UnjoinPlayer ); ADD_METHOD( GetSongPercent ); ADD_METHOD( GetCurMusicSeconds ); + ADD_METHOD( GetCharacter ); + ADD_METHOD( SetCharacter ); } }; diff --git a/src/JsonUtil.cpp b/src/JsonUtil.cpp new file mode 100644 index 0000000000..e8001aa22c --- /dev/null +++ b/src/JsonUtil.cpp @@ -0,0 +1,102 @@ +#include "global.h" +#include "JsonUtil.h" +#include "RageFile.h" +#include "RageUtil.h" +#include "RageLog.h" +#include "arch/Dialog/Dialog.h" +#include "jsoncpp/include/json/reader.h" +#include "jsoncpp/include/json/writer.h" + +bool JsonUtil::LoadFromString(Json::Value &root, RString sData, RString &sErrorOut) +{ + Json::Reader reader; + bool parsingSuccessful = reader.parse(sData, root); + if (!parsingSuccessful) + { + RString err = reader.getFormatedErrorMessages(); + sErrorOut = ssprintf("JSON: LoadFromFileShowErrors failed: %s", err.c_str()); + LOG->Warn(sErrorOut); + return false; + } + return true; +} + +bool JsonUtil::LoadFromFileShowErrors(Json::Value &root, RageFileBasic &f) +{ + // Optimization opportunity: read this streaming instead of at once + RString sData; + f.Read(sData, f.GetFileSize()); + return LoadFromStringShowErrors(root, sData); +} + +bool JsonUtil::LoadFromFileShowErrors(Json::Value &root, const RString &sFile) +{ + RageFile f; + if(!f.Open(sFile, RageFile::READ)) + { + LOG->Warn("Couldn't open %s for reading: %s", sFile.c_str(), f.GetError().c_str()); + return false; + } + + return LoadFromFileShowErrors(root, f); +} + +bool JsonUtil::LoadFromStringShowErrors(Json::Value &root, RString sData) +{ + RString sError; + if(!LoadFromString(root, sData, sError)) + { + Dialog::OK(sError, "JSON_PARSE_ERROR"); + return false; + } + return true; +} + +bool JsonUtil::WriteFile(const Json::Value &root, const RString &sFile, bool bMinified) +{ + std::string s; + if(!bMinified) + { + Json::StyledWriter writer; + s = writer.write(root); + } + else + { + Json::FastWriter writer; + s = writer.write(root); + } + + RageFile f; + if(!f.Open(sFile, RageFile::WRITE)) + { + LOG->Warn("Couldn't open %s for reading: %s", sFile.c_str(), f.GetError().c_str()); + return false; + } + f.Write(s); + return true; +} + +/* + * (c) 2001-2004 Chris Danford + * 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. + */ diff --git a/src/JsonUtil.h b/src/JsonUtil.h new file mode 100644 index 0000000000..26ab10e6f4 --- /dev/null +++ b/src/JsonUtil.h @@ -0,0 +1,100 @@ +/* JsonUtil - Utilities for handling JSON data. */ + +#ifndef JsonUtil_H +#define JsonUtil_H + +class RageFileBasic; +#include "jsoncpp/include/json/value.h" + +namespace JsonUtil +{ + bool LoadFromString( Json::Value &root, RString sData, RString &sErrorOut ); + bool LoadFromStringShowErrors(Json::Value &root, const RString sData); + bool LoadFromFileShowErrors(Json::Value &root, const RString &sFile); + bool LoadFromFileShowErrors(Json::Value &root, RageFileBasic &f); + + bool WriteFile(const Json::Value &root, const RString &sFile, bool bMinified); + + template + static void SerializeVectorObjects(const vector &v, void fn(const T &, Json::Value &), Json::Value &root) + { + root = Json::Value(Json::arrayValue); + root.resize(v.size()); + for(unsigned i=0; i + static void SerializeVectorPointers(const vector &v, void fn(const T &, Json::Value &), Json::Value &root) + { + root = Json::Value(Json::arrayValue); + root.resize(v.size()); + for(unsigned i=0; i + static void SerializeVectorValues(const vector &v, Json::Value &root) + { + root = Json::Value(Json::arrayValue); + root.resize(v.size()); + for(unsigned i=0; i + static void DeserializeVectorObjects(vector &v, void fn(T &, const Json::Value &), const Json::Value &root) + { + v.resize(root.size()); + for(unsigned i=0; i + static void DeserializeVectorPointers(vector &v, void fn(T &, const Json::Value &), const Json::Value &root) + { + for(unsigned i=0; i + static void DeserializeVectorValues(vector &v, const Json::Value &root) + { + v.resize(root.size()); + for(unsigned i=0; i ver.cpp; \ - echo "extern const char *const version_time = \"`date`\";" >> ver.cpp; - echo "extern const char *const version_date = \"`date`\";" >> ver.cpp; - -ver.cpp: - $(MAKE) increment_version - -Screens = \ -Screen.cpp Screen.h ScreenAttract.cpp ScreenAttract.h \ -ScreenBookkeeping.cpp ScreenBookkeeping.h \ -ScreenContinue.cpp ScreenContinue.h \ -ScreenDebugOverlay.cpp ScreenDebugOverlay.h \ -ScreenDemonstration.cpp ScreenDemonstration.h ScreenDimensions.h \ -ScreenEdit.cpp ScreenEdit.h \ -ScreenEditMenu.cpp ScreenEditMenu.h ScreenEnding.cpp ScreenEnding.h \ -ScreenEvaluation.cpp ScreenEvaluation.h \ -ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ -ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNetSelectBase.h ScreenNetRoom.cpp ScreenNetRoom.h \ -ScreenGameplay.cpp ScreenGameplay.h \ -ScreenGameplayLesson.cpp ScreenGameplayLesson.h \ -ScreenGameplayNormal.cpp ScreenGameplayNormal.h \ -ScreenGameplayShared.cpp ScreenGameplayShared.h \ -ScreenGameplaySyncMachine.cpp ScreenGameplaySyncMachine.h \ -ScreenHighScores.cpp ScreenHighScores.h \ -ScreenHowToPlay.cpp ScreenHowToPlay.h \ -ScreenInstructions.cpp ScreenInstructions.h \ -ScreenJukebox.cpp ScreenJukebox.h \ -ScreenMapControllers.cpp ScreenMapControllers.h \ -ScreenMessage.cpp ScreenMessage.h ScreenMiniMenu.cpp ScreenMiniMenu.h \ -ScreenNameEntry.cpp ScreenNameEntry.h ScreenNameEntryTraditional.cpp ScreenNameEntryTraditional.h \ -ScreenOptions.cpp ScreenOptions.h \ -ScreenOptionsEditProfile.cpp ScreenOptionsEditProfile.h \ -ScreenOptionsManageCourses.cpp ScreenOptionsManageCourses.h \ -ScreenOptionsManageEditSteps.cpp ScreenOptionsManageEditSteps.h \ -ScreenOptionsManageProfiles.cpp ScreenOptionsManageProfiles.h \ -ScreenOptionsMaster.cpp ScreenOptionsMaster.h \ -ScreenOptionsMasterPrefs.cpp ScreenOptionsMasterPrefs.h \ -ScreenOptionsToggleSongs.cpp ScreenOptionsToggleSongs.h \ -ScreenPackages.cpp ScreenPackages.h ScreenPackagesSSC.cpp ScreenPackagesSSC.h \ -ScreenNetworkOptions.h ScreenNetworkOptions.cpp \ -ScreenPlayerOptions.cpp ScreenPlayerOptions.h \ -ScreenProfileLoad.cpp ScreenProfileLoad.h \ -ScreenProfileSave.cpp ScreenProfileSave.h \ -ScreenPrompt.cpp ScreenPrompt.h ScreenRanking.cpp ScreenRanking.h \ -ScreenReloadSongs.cpp ScreenReloadSongs.h \ -ScreenSandbox.cpp ScreenSandbox.h \ -ScreenSaveSync.cpp ScreenSaveSync.h \ -ScreenServiceAction.cpp ScreenServiceAction.h \ -ScreenStatsOverlay.cpp ScreenStatsOverlay.h \ -ScreenSelect.cpp ScreenSelect.h ScreenSelectCharacter.cpp ScreenSelectCharacter.h \ -ScreenSelectLanguage.cpp ScreenSelectLanguage.h \ -ScreenSelectMaster.cpp ScreenSelectMaster.h \ -ScreenSelectMusic.cpp ScreenSelectMusic.h \ -ScreenSelectProfile.cpp ScreenSelectProfile.h \ -ScreenSyncOverlay.cpp ScreenSyncOverlay.h \ -ScreenSystemLayer.cpp ScreenSystemLayer.h ScreenSetTime.cpp ScreenSetTime.h \ -ScreenSongOptions.cpp ScreenSongOptions.h \ -ScreenSplash.cpp ScreenSplash.h \ -ScreenTestFonts.cpp ScreenTestFonts.h ScreenTestInput.cpp ScreenTestInput.h \ -ScreenTestLights.cpp ScreenTestLights.h ScreenTestSound.cpp ScreenTestSound.h ScreenTextEntry.cpp ScreenTextEntry.h \ -ScreenTitleMenu.cpp ScreenTitleMenu.h \ -ScreenUnlockBrowse.cpp ScreenUnlockBrowse.h \ -ScreenUnlockCelebrate.cpp ScreenUnlockCelebrate.h \ -ScreenUnlockStatus.cpp ScreenUnlockStatus.h \ -ScreenWithMenuElements.cpp ScreenWithMenuElements.h - -if !WITHOUT_NETWORKING -Screens += ScreenSMOnlineLogin.cpp ScreenSMOnlineLogin.h -endif - -DataStructures = \ -Attack.cpp Attack.h AutoKeysounds.cpp AutoKeysounds.h \ -AdjustSync.cpp AdjustSync.h \ -BackgroundUtil.cpp BackgroundUtil.h \ -BannerCache.cpp BannerCache.h \ -Character.cpp Character.h \ -CodeDetector.cpp CodeDetector.h \ -CodeSet.cpp CodeSet.h \ -Command.cpp Command.h \ -CommonMetrics.cpp CommonMetrics.h \ -Course.cpp Course.h \ -CourseLoaderCRS.cpp CourseLoaderCRS.h \ -CourseUtil.cpp CourseUtil.h \ -CourseWriterCRS.cpp CourseWriterCRS.h \ -CryptHelpers.cpp CryptHelpers.h \ -DateTime.cpp DateTime.h \ -Difficulty.cpp Difficulty.h \ -DisplayResolutions.h \ -EnumHelper.cpp EnumHelper.h \ -Font.cpp Font.h \ -FontCharAliases.cpp FontCharAliases.h \ -FontCharmaps.cpp FontCharmaps.h Game.cpp Game.h GameCommand.cpp GameCommand.h \ -GameplayAssist.cpp GameplayAssist.h \ -GameConstantsAndTypes.cpp GameConstantsAndTypes.h \ -GamePreferences.cpp GamePreferences.h \ -GameInput.cpp GameInput.h Grade.cpp Grade.h \ -HighScore.cpp HighScore.h \ -InputEventPlus.h \ -Inventory.cpp Inventory.h \ -LocalizedString.cpp LocalizedString.h \ -LuaReference.cpp LuaReference.h \ -LuaExpressionTransform.cpp LuaExpressionTransform.h \ -LyricsLoader.cpp LyricsLoader.h \ -ModsGroup.cpp ModsGroup.h \ -NoteData.cpp NoteData.h NoteDataUtil.cpp NoteDataUtil.h NoteDataWithScoring.cpp NoteDataWithScoring.h \ -NoteTypes.cpp NoteTypes.h NotesLoader.cpp NotesLoader.h \ -NotesLoaderBMS.cpp NotesLoaderBMS.h NotesLoaderDWI.cpp NotesLoaderDWI.h NotesLoaderKSF.cpp NotesLoaderKSF.h NotesLoaderMidi.cpp NotesLoaderMidi.h \ -NotesLoaderPMS.cpp NotesLoaderPMS.h NotesLoaderSM.cpp NotesLoaderSM.h NotesWriterDWI.cpp NotesWriterDWI.h NotesWriterSM.cpp NotesWriterSM.h \ -OptionRowHandler.cpp OptionRowHandler.h OptionsList.cpp OptionsList.h \ -PlayerAI.cpp PlayerAI.h PlayerNumber.cpp PlayerNumber.h PlayerOptions.cpp PlayerOptions.h \ -PlayerStageStats.cpp PlayerStageStats.h \ -PlayerState.cpp PlayerState.h Preference.cpp Preference.h Profile.cpp Profile.h \ -RandomSample.cpp RandomSample.h RadarValues.cpp RadarValues.h \ -SampleHistory.cpp SampleHistory.h \ -ScreenDimensions.h ScreenDimensions.cpp \ -ScoreKeeper.h ScoreKeeper.cpp \ -ScoreKeeperGuitar.cpp ScoreKeeperGuitar.h \ -ScoreKeeperNormal.cpp ScoreKeeperNormal.h \ -ScoreKeeperRave.cpp ScoreKeeperRave.h \ -ScoreKeeperShared.cpp ScoreKeeperShared.h \ -Song.cpp Song.h SongCacheIndex.cpp SongCacheIndex.h \ -SongOptions.cpp SongOptions.h SongUtil.cpp SongUtil.h StageStats.cpp StageStats.h Steps.cpp Steps.h \ -SoundEffectControl.cpp SoundEffectControl.h \ -StepsUtil.cpp StepsUtil.h Style.cpp Style.h StyleUtil.cpp StyleUtil.h \ -SubscriptionManager.h \ -TimingData.cpp TimingData.h \ -ThemeMetric.h \ -Trail.cpp Trail.h TrailUtil.cpp TrailUtil.h TitleSubstitution.cpp TitleSubstitution.h \ -Tween.cpp Tween.h - -if !WITHOUT_NETWORKING -DataStructures += RoomWheel.cpp RoomWheel.h -endif - -FileTypes = IniFile.cpp IniFile.h \ -MsdFile.cpp MsdFile.h \ -XmlFile.cpp XmlFile.h \ -XmlFileUtil.cpp XmlFileUtil.h - -StepMania = CommandLineActions.h CommandLineActions.cpp \ -StdString.h Foreach.h \ -StepMania.cpp StepMania.h \ -GameLoop.cpp GameLoop.h \ -global.cpp global.h \ -SpecialFiles.cpp SpecialFiles.h \ -ProductInfo.h - -LoadingWindow = arch/LoadingWindow/LoadingWindow.cpp \ - arch/LoadingWindow/LoadingWindow.h \ - arch/LoadingWindow/LoadingWindow_Null.h - -if HAVE_GTK -LoadingWindow += arch/LoadingWindow/LoadingWindow_Gtk.cpp arch/LoadingWindow/LoadingWindow_Gtk.h \ -arch/LoadingWindow/LoadingWindow_GtkModule.h -endif - -Sound = arch/Sound/RageSoundDriver.h arch/Sound/RageSoundDriver.cpp \ - arch/Sound/RageSoundDriver_Null.cpp arch/Sound/RageSoundDriver_Null.h \ - arch/Sound/RageSoundDriver_Generic_Software.cpp - -if HAVE_PULSE -Sound += arch/Sound/RageSoundDriver_PulseAudio.cpp arch/Sound/RageSoundDriver_PulseAudio.h -endif - -if HAVE_OSS -Sound += arch/Sound/RageSoundDriver_OSS.cpp arch/Sound/RageSoundDriver_OSS.h -endif - -if HAVE_ALSA -Sound += arch/Sound/ALSA9Dynamic.cpp arch/Sound/ALSA9Dynamic.h arch/Sound/ALSA9Functions.h \ - arch/Sound/ALSA9Helpers.cpp arch/Sound/ALSA9Helpers.h \ - arch/Sound/RageSoundDriver_ALSA9_Software.cpp arch/Sound/RageSoundDriver_ALSA9_Software.h - -# Add this to AM_CXXFLAGS, not stepmania_CXXFLAGS: that'll cause multiple copies of -# several sources to be built. We link to this at runtime, so don't add ALSA_LDFLAGS. -AM_CXXFLAGS += $(ALSA_CFLAGS) -endif - -ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h \ - arch/ArchHooks/ArchHooksUtil.cpp - -InputHandler = arch/InputHandler/InputHandler.cpp arch/InputHandler/InputHandler.h \ - arch/InputHandler/InputHandler_MonkeyKeyboard.cpp arch/InputHandler/InputHandler_MonkeyKeyboard.h - -MovieTexture = arch/MovieTexture/MovieTexture.cpp arch/MovieTexture/MovieTexture.h \ - arch/MovieTexture/MovieTexture_Generic.cpp arch/MovieTexture/MovieTexture_Generic.h \ - arch/MovieTexture/MovieTexture_Null.cpp arch/MovieTexture/MovieTexture_Null.h - -if HAVE_THEORA -MovieTexture += arch/MovieTexture/MovieTexture_Theora.cpp arch/MovieTexture/MovieTexture_Theora.h -endif - -if HAVE_FFMPEG -MovieTexture += arch/MovieTexture/MovieTexture_FFMpeg.cpp arch/MovieTexture/MovieTexture_FFMpeg.h -endif - -Lights = arch/Lights/LightsDriver.cpp arch/Lights/LightsDriver.h \ - arch/Lights/LightsDriver_Export.cpp arch/Lights/LightsDriver_Export.h \ - arch/Lights/LightsDriver_SystemMessage.cpp arch/Lights/LightsDriver_SystemMessage.h - -MemoryCard = arch/MemoryCard/MemoryCardDriver.cpp arch/MemoryCard/MemoryCardDriver.h arch/MemoryCard/MemoryCardDriver_Null.h -LowLevelWindow = arch/LowLevelWindow/LowLevelWindow.cpp arch/LowLevelWindow/LowLevelWindow.h - -ArchUtils = - -Dialog = arch/Dialog/Dialog.cpp arch/Dialog/Dialog.h arch/Dialog/DialogDriver.h arch/Dialog/DialogDriver.cpp - -Threads = arch/Threads/Threads.h - -if HAVE_X11 -# InputHandler_X11 depends on LowLevelWindow_X11 -InputHandler += arch/InputHandler/InputHandler_X11.cpp arch/InputHandler/InputHandler_X11.h -LowLevelWindow += arch/LowLevelWindow/LowLevelWindow_X11.cpp arch/LowLevelWindow/LowLevelWindow_X11.h -LowLevelWindow += archutils/Unix/X11Helper.cpp archutils/Unix/X11Helper.h -endif - -# Platform-specific drivers: - -if UNIX -ArchHooks += arch/ArchHooks/ArchHooks_Unix.cpp arch/ArchHooks/ArchHooks_Unix.h -Threads += arch/Threads/Threads_Pthreads.cpp arch/Threads/Threads_Pthreads.h -if LINUX -Lights += arch/Lights/LightsDriver_LinuxWeedTech.cpp arch/Lights/LightsDriver_LinuxWeedTech.h -if HAVE_PARALLEL_PORT -Lights += arch/Lights/LightsDriver_LinuxParallel.cpp arch/Lights/LightsDriver_LinuxParallel.h -endif -endif - -ArchUtils += archutils/Unix/AssertionHandler.cpp archutils/Unix/AssertionHandler.h \ - archutils/Unix/arch_setup.h \ - archutils/Unix/GetSysInfo.cpp archutils/Unix/GetSysInfo.h \ - archutils/Unix/SignalHandler.cpp archutils/Unix/SignalHandler.h \ - archutils/Unix/LinuxThreadHelpers.cpp archutils/Unix/LinuxThreadHelpers.h \ - archutils/Unix/RunningUnderValgrind.cpp archutils/Unix/RunningUnderValgrind.h \ - archutils/Unix/EmergencyShutdown.cpp archutils/Unix/EmergencyShutdown.h \ - archutils/Unix/StackCheck.cpp \ - archutils/Common/gcc_byte_swaps.h - -if USE_CRASH_HANDLER -ArchUtils += archutils/Unix/Backtrace.cpp archutils/Unix/Backtrace.h \ - archutils/Unix/BacktraceNames.cpp archutils/Unix/BacktraceNames.h \ - archutils/Unix/CrashHandler.cpp archutils/Unix/CrashHandler.h \ - archutils/Unix/CrashHandlerChild.cpp archutils/Unix/CrashHandlerInternal.h \ - archutils/Unix/CrashHandlerInternal.cpp -endif - -endif - -if LINUX -MemoryCard += arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp arch/MemoryCard/MemoryCardDriverThreaded_Linux.h -InputHandler += arch/InputHandler/InputHandler_Linux_Joystick.cpp arch/InputHandler/InputHandler_Linux_Joystick.h -InputHandler += arch/InputHandler/InputHandler_Linux_Event.cpp arch/InputHandler/InputHandler_Linux_Event.h -endif - -Arch = $(LoadingWindow) $(Sound) $(ArchHooks) $(InputHandler) $(MovieTexture) \ - $(Lights) $(MemoryCard) $(LowLevelWindow) $(ArchUtils) $(Dialog) $(Threads) \ - arch/arch_default.h arch/RageDriver.cpp arch/RageDriver.h - -RageSoundFileReaders = RageSoundReader_WAV.cpp RageSoundReader_WAV.h - -if HAVE_VORBIS -RageSoundFileReaders += RageSoundReader_Vorbisfile.cpp RageSoundReader_Vorbisfile.h -endif - -if HAVE_MP3 -RageSoundFileReaders += RageSoundReader_MP3.cpp RageSoundReader_MP3.h -endif - -ActorsInGameplayAndMenus = \ -BGAnimation.cpp BGAnimation.h BGAnimationLayer.cpp BGAnimationLayer.h Banner.cpp Banner.h \ -DifficultyIcon.cpp DifficultyIcon.h \ -MeterDisplay.cpp MeterDisplay.h StreamDisplay.cpp StreamDisplay.h \ -Transition.cpp Transition.h - -ActorsInMenus = \ -ActiveAttackList.cpp ActiveAttackList.h BPMDisplay.cpp BPMDisplay.h ComboGraph.cpp ComboGraph.h \ -CourseContentsList.cpp CourseContentsList.h \ -StepsDisplay.cpp StepsDisplay.h \ -DifficultyList.cpp DifficultyList.h \ -DualScrollBar.cpp DualScrollBar.h \ -EditMenu.cpp EditMenu.h FadingBanner.cpp FadingBanner.h \ -GradeDisplay.cpp GradeDisplay.h GraphDisplay.cpp GraphDisplay.h \ -GrooveRadar.cpp GrooveRadar.h GroupList.cpp GroupList.h HelpDisplay.cpp HelpDisplay.h \ -MemoryCardDisplay.cpp MemoryCardDisplay.h \ -MenuTimer.cpp MenuTimer.h \ -ModIcon.cpp ModIcon.h ModIconRow.cpp ModIconRow.h \ -MusicList.cpp MusicList.h MusicWheel.cpp MusicWheel.h \ -MusicWheelItem.cpp MusicWheelItem.h \ -OptionRow.cpp OptionRow.h OptionsCursor.cpp OptionsCursor.h \ -PaneDisplay.cpp PaneDisplay.h ScrollBar.cpp ScrollBar.h \ -SnapDisplay.cpp SnapDisplay.h \ -TextBanner.cpp TextBanner.h WheelBase.cpp WheelBase.h WheelItemBase.cpp WheelItemBase.h \ -WheelNotifyIcon.cpp WheelNotifyIcon.h \ -WorkoutGraph.cpp WorkoutGraph.h - -if !WITHOUT_NETWORKING -ActorsInMenus += RoomInfoDisplay.cpp RoomInfoDisplay.h -endif - -ActorsInGameplay = \ -ArrowEffects.cpp ArrowEffects.h AttackDisplay.cpp AttackDisplay.h \ -Background.cpp Background.h BeginnerHelper.cpp BeginnerHelper.h CombinedLifeMeter.h CombinedLifeMeterTug.cpp CombinedLifeMeterTug.h \ -DancingCharacters.cpp DancingCharacters.h Foreground.cpp Foreground.h \ -GhostArrowRow.cpp GhostArrowRow.h HoldJudgment.cpp HoldJudgment.h \ -LifeMeter.cpp LifeMeter.h \ -LifeMeterBar.cpp LifeMeterBar.h \ -LifeMeterBattery.cpp LifeMeterBattery.h LifeMeterTime.cpp LifeMeterTime.h \ -LyricDisplay.cpp LyricDisplay.h NoteDisplay.cpp NoteDisplay.h NoteField.cpp NoteField.h \ -PercentageDisplay.cpp PercentageDisplay.h Player.cpp Player.h \ -ReceptorArrow.cpp ReceptorArrow.h ReceptorArrowRow.cpp ReceptorArrowRow.h \ -ScoreDisplay.cpp ScoreDisplay.h \ -ScoreDisplayAliveTime.cpp ScoreDisplayAliveTime.h \ -ScoreDisplayBattle.cpp ScoreDisplayBattle.h \ -ScoreDisplayCalories.cpp ScoreDisplayCalories.h \ -ScoreDisplayLifeTime.cpp ScoreDisplayLifeTime.h \ -ScoreDisplayNormal.cpp ScoreDisplayNormal.h ScoreDisplayOni.cpp ScoreDisplayOni.h \ -ScoreDisplayPercentage.cpp ScoreDisplayPercentage.h ScoreDisplayRave.cpp ScoreDisplayRave.h - -PCRE = pcre/get.c pcre/internal.h pcre/maketables.c pcre/pcre.c pcre/pcre.h pcre/study.c -EXTRA_DIST += pcre/chartables.c - -Lua = lua-5.1/src/lapi.c lua-5.1/src/lauxlib.c lua-5.1/src/lbaselib.c lua-5.1/src/lcode.c lua-5.1/src/ldblib.c \ -lua-5.1/src/ldebug.c lua-5.1/src/ldo.c lua-5.1/src/ldump.c lua-5.1/src/lfunc.c lua-5.1/src/lgc.c lua-5.1/src/linit.c \ -lua-5.1/src/liolib.c lua-5.1/src/llex.c lua-5.1/src/lmathlib.c lua-5.1/src/lmem.c lua-5.1/src/loadlib.c \ -lua-5.1/src/lobject.c lua-5.1/src/lopcodes.c lua-5.1/src/loslib.c lua-5.1/src/lparser.c lua-5.1/src/lstate.c \ -lua-5.1/src/lstring.c lua-5.1/src/lstrlib.c lua-5.1/src/ltable.c lua-5.1/src/ltablib.c lua-5.1/src/ltm.c \ -lua-5.1/src/lundump.c lua-5.1/src/lvm.c lua-5.1/src/lzio.c lua-5.1/src/lapi.h lua-5.1/src/lauxlib.h lua-5.1/src/lcode.h \ -lua-5.1/src/ldebug.h lua-5.1/src/ldo.h lua-5.1/src/lfunc.h lua-5.1/src/lgc.h lua-5.1/src/llex.h lua-5.1/src/llimits.h \ -lua-5.1/src/lmem.h lua-5.1/src/lobject.h lua-5.1/src/lopcodes.h lua-5.1/src/lparser.h lua-5.1/src/lstate.h \ -lua-5.1/src/lstring.h lua-5.1/src/ltable.h lua-5.1/src/ltm.h lua-5.1/src/luaconf.h lua-5.1/src/lua.h lua-5.1/src/lualib.h \ -lua-5.1/src/lundump.h lua-5.1/src/lvm.h lua-5.1/src/lzio.h - -RageFile = \ -RageFileBasic.cpp RageFileBasic.h \ -RageFile.cpp RageFile.h RageFileDriver.cpp RageFileDriver.h RageFileManager.cpp RageFileManager.h \ -RageFileManager_ReadAhead.cpp RageFileManager_ReadAhead.h \ -RageFileDriverDirect.cpp RageFileDriverDirect.h RageFileDriverDirectHelpers.cpp RageFileDriverDirectHelpers.h \ -RageFileDriverMemory.cpp RageFileDriverMemory.h RageFileDriverZip.cpp RageFileDriverZip.h \ -RageFileDriverDeflate.cpp RageFileDriverDeflate.h \ -RageFileDriverReadAhead.cpp RageFileDriverReadAhead.h \ -RageFileDriverSlice.cpp RageFileDriverSlice.h \ -RageFileDriverTimeout.cpp RageFileDriverTimeout.h - -Rage = $(PCRE) $(Lua) $(RageFile) $(RageSoundFileReaders) \ -RageBitmapTexture.cpp RageBitmapTexture.h RageDisplay.cpp RageDisplay.h RageDisplay_OGL.cpp RageDisplay_OGL.h \ -RageDisplay_OGL_Helpers.cpp RageDisplay_OGL_Helpers.h glext.h \ -RageDisplay_Null.cpp RageDisplay_Null.h RageException.cpp RageException.h RageInput.cpp RageInput.h \ -RageInputDevice.cpp RageInputDevice.h RageLog.cpp RageLog.h RageMath.cpp RageMath.h \ -RageModelGeometry.cpp RageModelGeometry.h RageSound.cpp RageSound.h RageSoundManager.cpp RageSoundManager.h \ -RageSoundUtil.cpp RageSoundUtil.h RageSoundMixBuffer.cpp RageSoundMixBuffer.h \ -RageSoundPosMap.cpp RageSoundPosMap.h RageSoundReader.cpp RageSoundReader.h RageSoundReader_FileReader.cpp RageSoundReader_FileReader.h \ -RageSoundReader_Filter.h \ -RageSoundReader_ChannelSplit.cpp RageSoundReader_ChannelSplit.h \ -RageSoundReader_Extend.cpp RageSoundReader_Extend.h \ -RageSoundReader_Merge.cpp RageSoundReader_Merge.h \ -RageSoundReader_PitchChange.cpp RageSoundReader_PitchChange.h \ -RageSoundReader_PostBuffering.cpp RageSoundReader_PostBuffering.h \ -RageSoundReader_Pan.cpp RageSoundReader_Pan.h \ -RageSoundReader_Preload.cpp RageSoundReader_Preload.h \ -RageSoundReader_Resample_Good.cpp RageSoundReader_Resample_Good.h \ -RageSoundReader_SpeedChange.cpp RageSoundReader_SpeedChange.h \ -RageSoundReader_ThreadedBuffer.cpp RageSoundReader_ThreadedBuffer.h \ -RageSoundReader_Chain.cpp RageSoundReader_Chain.h \ -RageSurface.cpp RageSurface.h RageSurfaceUtils.cpp RageSurfaceUtils.h \ -RageSurfaceUtils_Dither.cpp RageSurfaceUtils_Dither.h \ -RageSurface_Save_JPEG.cpp RageSurface_Save_JPEG.h \ -RageSurfaceUtils_Palettize.cpp RageSurfaceUtils_Palettize.h \ -RageSurfaceUtils_Zoom.cpp RageSurfaceUtils_Zoom.h \ -RageSurface_Load.cpp RageSurface_Load.h RageSurface_Load_PNG.cpp RageSurface_Load_PNG.h \ -RageSurface_Load_JPEG.cpp RageSurface_Load_JPEG.h RageSurface_Load_GIF.cpp RageSurface_Load_GIF.h \ -RageSurface_Load_BMP.cpp RageSurface_Load_BMP.h \ -RageSurface_Load_XPM.cpp RageSurface_Load_XPM.h RageTexture.cpp RageTexture.h \ -RageTexturePreloader.cpp RageTexturePreloader.h \ -RageTextureRenderTarget.cpp RageTextureRenderTarget.h \ -RageSurface_Save_BMP.cpp RageSurface_Save_BMP.h \ -RageSurface_Save_PNG.cpp RageSurface_Save_PNG.h \ -RageTextureID.cpp RageTextureID.h RageTextureManager.cpp RageTextureManager.h RageThreads.cpp RageThreads.h \ -RageTimer.cpp RageTimer.h RageTypes.cpp RageTypes.h RageUtil.cpp RageUtil.h \ -RageUtil_CachedObject.cpp RageUtil_CachedObject.h \ -RageUtil_CharConversions.cpp RageUtil_CharConversions.h \ -RageUtil_BackgroundLoader.cpp RageUtil_BackgroundLoader.h RageUtil_FileDB.cpp RageUtil_FileDB.h RageUtil_CircularBuffer.h \ -RageUtil_AutoPtr.h \ -RageUtil_WorkerThread.cpp RageUtil_WorkerThread.h - -Actors = \ -Actor.cpp Actor.h ActorFrame.cpp ActorFrame.h \ -ActorFrameTexture.cpp ActorFrameTexture.h \ -ActorMultiTexture.cpp ActorMultiTexture.h \ -ActorProxy.cpp ActorProxy.h \ -ActorScroller.cpp ActorScroller.h ActorUtil.cpp ActorUtil.h \ -ActorSound.cpp ActorSound.h \ -AutoActor.cpp AutoActor.h \ -BitmapText.cpp BitmapText.h Model.cpp Model.h \ -DynamicActorScroller.cpp DynamicActorScroller.h \ -ModelManager.cpp ModelManager.h ModelTypes.cpp ModelTypes.h \ -Quad.cpp Quad.h \ -RollingNumbers.cpp RollingNumbers.h Sprite.cpp Sprite.h - -GlobalSingletons = \ -AnnouncerManager.cpp AnnouncerManager.h \ -Bookkeeper.cpp Bookkeeper.h \ -CharacterManager.cpp CharacterManager.h \ -CryptManager.cpp CryptManager.h \ -FontManager.cpp FontManager.h GameSoundManager.cpp GameSoundManager.h \ -GameManager.cpp GameManager.h \ -GameState.cpp GameState.h \ -InputFilter.cpp InputFilter.h \ -InputMapper.cpp InputMapper.h InputQueue.cpp InputQueue.h \ -LuaBinding.cpp LuaBinding.h \ -LuaManager.cpp LuaManager.h LightsManager.cpp LightsManager.h \ -MemoryCardManager.cpp MemoryCardManager.h \ -MessageManager.cpp MessageManager.h NetworkSyncManager.cpp NetworkSyncManager.h \ -NoteSkinManager.cpp NoteSkinManager.h \ -PrefsManager.cpp PrefsManager.h ProfileManager.cpp ProfileManager.h ScreenManager.cpp \ -ScreenManager.h SongManager.cpp SongManager.h \ -StatsManager.cpp StatsManager.h \ -ThemeManager.cpp ThemeManager.h \ -UnlockManager.cpp UnlockManager.h - -if !WITHOUT_NETWORKING -# Compile NetworkSyncManager even if networking is disabled; it'll stub itself. -GlobalSingletons += ezsockets.cpp ezsockets.h -endif - -libtommath_a_SOURCES = \ -libtommath/bncore.c libtommath/bn_mp_init.c libtommath/bn_mp_clear.c libtommath/bn_mp_exch.c libtommath/bn_mp_grow.c libtommath/bn_mp_shrink.c \ -libtommath/bn_mp_clamp.c libtommath/bn_mp_zero.c libtommath/bn_mp_set.c libtommath/bn_mp_set_int.c libtommath/bn_mp_init_size.c libtommath/bn_mp_copy.c \ -libtommath/bn_mp_init_copy.c libtommath/bn_mp_abs.c libtommath/bn_mp_neg.c libtommath/bn_mp_cmp_mag.c libtommath/bn_mp_cmp.c libtommath/bn_mp_cmp_d.c \ -libtommath/bn_mp_rshd.c libtommath/bn_mp_lshd.c libtommath/bn_mp_mod_2d.c libtommath/bn_mp_div_2d.c libtommath/bn_mp_mul_2d.c libtommath/bn_mp_div_2.c \ -libtommath/bn_mp_mul_2.c libtommath/bn_s_mp_add.c libtommath/bn_s_mp_sub.c libtommath/bn_fast_s_mp_mul_digs.c libtommath/bn_s_mp_mul_digs.c \ -libtommath/bn_fast_s_mp_mul_high_digs.c libtommath/bn_s_mp_mul_high_digs.c libtommath/bn_fast_s_mp_sqr.c libtommath/bn_s_mp_sqr.c \ -libtommath/bn_mp_add.c libtommath/bn_mp_sub.c libtommath/bn_mp_karatsuba_mul.c libtommath/bn_mp_mul.c libtommath/bn_mp_karatsuba_sqr.c \ -libtommath/bn_mp_sqr.c libtommath/bn_mp_div.c libtommath/bn_mp_mod.c libtommath/bn_mp_add_d.c libtommath/bn_mp_sub_d.c libtommath/bn_mp_mul_d.c \ -libtommath/bn_mp_div_d.c libtommath/bn_mp_mod_d.c libtommath/bn_mp_expt_d.c libtommath/bn_mp_addmod.c libtommath/bn_mp_submod.c \ -libtommath/bn_mp_mulmod.c libtommath/bn_mp_sqrmod.c libtommath/bn_mp_gcd.c libtommath/bn_mp_lcm.c libtommath/bn_fast_mp_invmod.c libtommath/bn_mp_invmod.c \ -libtommath/bn_mp_reduce.c libtommath/bn_mp_montgomery_setup.c libtommath/bn_fast_mp_montgomery_reduce.c libtommath/bn_mp_montgomery_reduce.c \ -libtommath/bn_mp_exptmod_fast.c libtommath/bn_mp_exptmod.c libtommath/bn_mp_2expt.c libtommath/bn_mp_n_root.c libtommath/bn_mp_jacobi.c libtommath/bn_reverse.c \ -libtommath/bn_mp_count_bits.c libtommath/bn_mp_read_unsigned_bin.c libtommath/bn_mp_read_signed_bin.c libtommath/bn_mp_to_unsigned_bin.c \ -libtommath/bn_mp_to_signed_bin.c libtommath/bn_mp_unsigned_bin_size.c libtommath/bn_mp_signed_bin_size.c \ -libtommath/bn_mp_xor.c libtommath/bn_mp_and.c libtommath/bn_mp_or.c libtommath/bn_mp_rand.c libtommath/bn_mp_montgomery_calc_normalization.c \ -libtommath/bn_mp_prime_is_divisible.c libtommath/bn_prime_tab.c libtommath/bn_mp_prime_fermat.c libtommath/bn_mp_prime_miller_rabin.c \ -libtommath/bn_mp_prime_is_prime.c libtommath/bn_mp_prime_next_prime.c libtommath/bn_mp_dr_reduce.c \ -libtommath/bn_mp_dr_is_modulus.c libtommath/bn_mp_dr_setup.c libtommath/bn_mp_reduce_setup.c \ -libtommath/bn_mp_toom_mul.c libtommath/bn_mp_toom_sqr.c libtommath/bn_mp_div_3.c libtommath/bn_s_mp_exptmod.c \ -libtommath/bn_mp_reduce_2k.c libtommath/bn_mp_reduce_is_2k.c libtommath/bn_mp_reduce_2k_setup.c \ -libtommath/bn_mp_reduce_2k_l.c libtommath/bn_mp_reduce_is_2k_l.c libtommath/bn_mp_reduce_2k_setup_l.c \ -libtommath/bn_mp_radix_smap.c libtommath/bn_mp_read_radix.c libtommath/bn_mp_toradix.c libtommath/bn_mp_radix_size.c \ -libtommath/bn_mp_fread.c libtommath/bn_mp_fwrite.c libtommath/bn_mp_cnt_lsb.c libtommath/bn_error.c \ -libtommath/bn_mp_init_multi.c libtommath/bn_mp_clear_multi.c libtommath/bn_mp_exteuclid.c libtommath/bn_mp_toradix_n.c \ -libtommath/bn_mp_prime_random_ex.c libtommath/bn_mp_get_int.c libtommath/bn_mp_sqrt.c libtommath/bn_mp_is_square.c libtommath/bn_mp_init_set.c \ -libtommath/bn_mp_init_set_int.c libtommath/bn_mp_invmod_slow.c libtommath/bn_mp_prime_rabin_miller_trials.c \ -libtommath/bn_mp_to_signed_bin_n.c libtommath/bn_mp_to_unsigned_bin_n.c \ -libtommath/tommath_class.h libtommath/tommath.h libtommath/tommath_superclass.h -EXTRA_DIST += libtommath/bn_prime_tab.c - -libtommath_a_CPPFLAGS = -I$(srcdir)/libtommath $(AM_CPPFLAGS) -noinst_LIBRARIES += libtommath.a - -libtomcrypt_a_SOURCES = \ -libtomcrypt/src/ciphers/aes/aes.c \ -libtomcrypt/src/hashes/md5.c libtomcrypt/src/hashes/sha1.c libtomcrypt/src/hashes/helper/hash_memory.c \ -libtomcrypt/src/math/fp/ltc_ecc_fp_mulmod.c libtomcrypt/src/math/ltm_desc.c libtomcrypt/src/math/multi.c \ -libtomcrypt/src/math/rand_prime.c libtomcrypt/src/misc/base64/base64_decode.c \ -libtomcrypt/src/misc/base64/base64_encode.c libtomcrypt/src/misc/burn_stack.c libtomcrypt/src/misc/crypt/crypt.c \ -libtomcrypt/src/misc/crypt/crypt_argchk.c libtomcrypt/src/misc/crypt/crypt_cipher_descriptor.c \ -libtomcrypt/src/misc/crypt/crypt_cipher_is_valid.c libtomcrypt/src/misc/crypt/crypt_find_cipher.c \ -libtomcrypt/src/misc/crypt/crypt_find_cipher_any.c libtomcrypt/src/misc/crypt/crypt_find_cipher_id.c \ -libtomcrypt/src/misc/crypt/crypt_find_hash.c libtomcrypt/src/misc/crypt/crypt_find_hash_any.c \ -libtomcrypt/src/misc/crypt/crypt_find_hash_id.c libtomcrypt/src/misc/crypt/crypt_find_hash_oid.c \ -libtomcrypt/src/misc/crypt/crypt_find_prng.c libtomcrypt/src/misc/crypt/crypt_fsa.c libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c \ -libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c libtomcrypt/src/misc/crypt/crypt_ltc_mp_descriptor.c \ -libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c \ -libtomcrypt/src/misc/crypt/crypt_register_cipher.c libtomcrypt/src/misc/crypt/crypt_register_hash.c \ -libtomcrypt/src/misc/crypt/crypt_register_prng.c libtomcrypt/src/misc/crypt/crypt_unregister_cipher.c \ -libtomcrypt/src/misc/crypt/crypt_unregister_hash.c libtomcrypt/src/misc/crypt/crypt_unregister_prng.c \ -libtomcrypt/src/misc/error_to_string.c libtomcrypt/src/misc/pkcs5/pkcs_5_1.c libtomcrypt/src/misc/pkcs5/pkcs_5_2.c libtomcrypt/src/misc/zeromem.c \ -libtomcrypt/src/modes/cbc/cbc_decrypt.c libtomcrypt/src/modes/cbc/cbc_done.c libtomcrypt/src/modes/cbc/cbc_encrypt.c \ -libtomcrypt/src/modes/cbc/cbc_getiv.c libtomcrypt/src/modes/cbc/cbc_setiv.c libtomcrypt/src/modes/cbc/cbc_start.c \ -libtomcrypt/src/modes/cfb/cfb_decrypt.c libtomcrypt/src/modes/cfb/cfb_done.c libtomcrypt/src/modes/cfb/cfb_encrypt.c \ -libtomcrypt/src/modes/cfb/cfb_getiv.c libtomcrypt/src/modes/cfb/cfb_setiv.c libtomcrypt/src/modes/cfb/cfb_start.c \ -libtomcrypt/src/modes/ctr/ctr_decrypt.c libtomcrypt/src/modes/ctr/ctr_done.c libtomcrypt/src/modes/ctr/ctr_encrypt.c \ -libtomcrypt/src/modes/ctr/ctr_getiv.c libtomcrypt/src/modes/ctr/ctr_setiv.c libtomcrypt/src/modes/ctr/ctr_start.c libtomcrypt/src/modes/ctr/ctr_test.c \ -libtomcrypt/src/modes/ecb/ecb_decrypt.c libtomcrypt/src/modes/ecb/ecb_done.c libtomcrypt/src/modes/ecb/ecb_encrypt.c \ -libtomcrypt/src/modes/ecb/ecb_start.c \ -libtomcrypt/src/modes/ofb/ofb_decrypt.c libtomcrypt/src/modes/ofb/ofb_done.c \ -libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c \ -libtomcrypt/src/pk/asn1/der/bit/der_encode_bit_string.c libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c \ -libtomcrypt/src/pk/asn1/der/boolean/der_decode_boolean.c libtomcrypt/src/pk/asn1/der/boolean/der_encode_boolean.c \ -libtomcrypt/src/pk/asn1/der/boolean/der_length_boolean.c libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c \ -libtomcrypt/src/pk/asn1/der/ia5/der_decode_ia5_string.c libtomcrypt/src/pk/asn1/der/ia5/der_encode_ia5_string.c \ -libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c libtomcrypt/src/pk/asn1/der/integer/der_decode_integer.c \ -libtomcrypt/src/pk/asn1/der/integer/der_encode_integer.c libtomcrypt/src/pk/asn1/der/integer/der_length_integer.c \ -libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c \ -libtomcrypt/src/pk/asn1/der/object_identifier/der_encode_object_identifier.c \ -libtomcrypt/src/pk/asn1/der/object_identifier/der_length_object_identifier.c \ -libtomcrypt/src/pk/asn1/der/octet/der_decode_octet_string.c libtomcrypt/src/pk/asn1/der/octet/der_encode_octet_string.c \ -libtomcrypt/src/pk/asn1/der/octet/der_length_octet_string.c \ -libtomcrypt/src/pk/asn1/der/printable_string/der_decode_printable_string.c \ -libtomcrypt/src/pk/asn1/der/printable_string/der_encode_printable_string.c \ -libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_ex.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_multi.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_ex.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c libtomcrypt/src/pk/asn1/der/sequence/der_length_sequence.c \ -libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c libtomcrypt/src/pk/asn1/der/set/der_encode_set.c \ -libtomcrypt/src/pk/asn1/der/set/der_encode_setof.c libtomcrypt/src/pk/asn1/der/short_integer/der_decode_short_integer.c \ -libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.c \ -libtomcrypt/src/pk/asn1/der/short_integer/der_length_short_integer.c libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c \ -libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c libtomcrypt/src/pk/asn1/der/utctime/der_length_utctime.c \ -libtomcrypt/src/pk/asn1/der/utf8/der_decode_utf8_string.c libtomcrypt/src/pk/asn1/der/utf8/der_encode_utf8_string.c \ -libtomcrypt/src/pk/asn1/der/utf8/der_length_utf8_string.c libtomcrypt/src/pk/dsa/dsa_decrypt_key.c \ -libtomcrypt/src/pk/dsa/dsa_encrypt_key.c libtomcrypt/src/pk/dsa/dsa_export.c libtomcrypt/src/pk/dsa/dsa_free.c libtomcrypt/src/pk/dsa/dsa_import.c \ -libtomcrypt/src/pk/dsa/dsa_make_key.c libtomcrypt/src/pk/dsa/dsa_shared_secret.c libtomcrypt/src/pk/dsa/dsa_sign_hash.c \ -libtomcrypt/src/pk/dsa/dsa_verify_hash.c libtomcrypt/src/pk/dsa/dsa_verify_key.c \ -libtomcrypt/src/pk/pkcs1/pkcs_1_i2osp.c libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c \ -libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c libtomcrypt/src/pk/pkcs1/pkcs_1_os2ip.c \ -libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c \ -libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c libtomcrypt/src/pk/rsa/rsa_decrypt_key.c libtomcrypt/src/pk/rsa/rsa_encrypt_key.c \ -libtomcrypt/src/pk/rsa/rsa_export.c libtomcrypt/src/pk/rsa/rsa_exptmod.c libtomcrypt/src/pk/rsa/rsa_free.c libtomcrypt/src/pk/rsa/rsa_import.c \ -libtomcrypt/src/pk/rsa/rsa_make_key.c libtomcrypt/src/pk/rsa/rsa_sign_hash.c libtomcrypt/src/pk/rsa/rsa_verify_hash.c libtomcrypt/src/prngs/fortuna.c \ -libtomcrypt/src/prngs/rng_get_bytes.c libtomcrypt/src/prngs/rng_make_prng.c \ -libtomcrypt/src/prngs/sprng.c libtomcrypt/src/prngs/yarrow.c \ -libtomcrypt/src/headers/tomcrypt_argchk.h libtomcrypt/src/headers/tomcrypt_cfg.h libtomcrypt/src/headers/tomcrypt_cipher.h \ -libtomcrypt/src/headers/tomcrypt_custom.h libtomcrypt/src/headers/tomcrypt.h libtomcrypt/src/headers/tomcrypt_hash.h \ -libtomcrypt/src/headers/tomcrypt_mac.h libtomcrypt/src/headers/tomcrypt_macros.h libtomcrypt/src/headers/tomcrypt_math.h \ -libtomcrypt/src/headers/tomcrypt_misc.h libtomcrypt/src/headers/tomcrypt_pkcs.h libtomcrypt/src/headers/tomcrypt_pk.h \ -libtomcrypt/src/headers/tomcrypt_prng.h -EXTRA_DIST += libtomcrypt/src/ciphers/aes/aes_tab.c libtomcrypt/src/prngs/sober128tab.c - -libtomcrypt_a_CPPFLAGS = -I$(srcdir)/libtomcrypt/src/headers $(AM_CPPFLAGS) - -noinst_LIBRARIES += libtomcrypt.a - -main_SOURCES = $(Screens) \ - $(DataStructures) \ - $(FileTypes) \ - $(StepMania) \ - $(Arch) \ - $(ActorsInGameplayAndMenus) \ - $(ActorsInMenus) \ - $(ActorsInGameplay) \ - $(Rage) \ - $(Actors) \ - $(GlobalSingletons) - -main_LDADD = \ - $(AUDIO_LIBS) \ - $(XLIBS) \ - libtomcrypt.a libtommath.a - -nodist_stepmania_SOURCES = ver.cpp -stepmania_SOURCES = $(main_SOURCES) -stepmania_LDADD = $(main_LDADD) - -if BUILD_LUA_BINARIES -noinst_PROGRAMS += lua luac -lua_SOURCES = $(Lua) lua-5.1/src/lua.c -lua_LDADD = -lreadline - -luac_SOURCES = $(Lua) lua-5.1/src/luac.c lua-5.1/src/print.c -luac_LDADD = -endif - - -if HAVE_GTK -noinst_PROGRAMS += GtkModule.so -GtkModule_so_LDFLAGS = -rdynamic -shared -GtkModule_so_CPPFLAGS = $(GTK_CFLAGS) -fPIC -GtkModule_so_LDADD = $(GTK_LIBS) -GtkModule_so_SOURCES = arch/LoadingWindow/LoadingWindow_GtkModule.cpp -endif - -all_test_SOURCES = \ - $(ArchUtils) \ - $(PCRE) \ - $(RageFile) \ - $(Lua) \ - $(ArchHooks) \ - $(Threads) \ - $(Dialog) \ - tests/test_misc.cpp tests/test_misc.h \ - IniFile.cpp IniFile.h \ - XmlFile.cpp XmlFile.h \ - Command.cpp Command.h \ - DateTime.cpp DateTime.h \ - EnumHelper.cpp EnumHelper.h \ - PrefsManager.cpp PrefsManager.h \ - Preference.cpp Preference.h \ - LocalizedString.cpp LocalizedString.h \ - LuaBinding.cpp LuaBinding.h \ - LuaManager.cpp LuaManager.h \ - LuaReference.cpp LuaReference.h \ - SpecialFiles.cpp SpecialFiles.h \ - RageException.cpp \ - RageLog.cpp \ - RageThreads.cpp \ - RageTimer.cpp RageTimer.h \ - RageUtil.cpp \ - RageUtil_FileDB.cpp RageUtil_FileDB.h \ - global.cpp global.h \ - RageUtil_WorkerThread.cpp RageUtil_WorkerThread.h \ - MessageManager.cpp MessageManager.h - -TESTS += test_audio_readers -test_audio_readers_SOURCES = \ - $(RageSoundFileReaders) \ - $(all_test_SOURCES) \ - tests/test_audio_readers.cpp \ - RageSoundUtil.cpp RageSoundUtil.h RageSoundMixBuffer.cpp RageSoundMixBuffer.h \ - RageSoundReader.cpp RageSoundReader.h \ - RageSoundReader_FileReader.cpp RageSoundReader_FileReader.h \ - RageSoundReader_Pan.cpp RageSoundReader_Pan.h \ - RageSoundReader_Preload.cpp RageSoundReader_Preload.h \ - RageSoundReader_Resample_Good.cpp RageSoundReader_Resample_Good.h \ - RageSoundReader_Chain.cpp RageSoundReader_Chain.h - -test_audio_readers_LDADD = $(AUDIO_LIBS) - -TESTS += test_file_readers -test_file_readers_SOURCES = \ - $(all_test_SOURCES) \ - tests/test_file_readers.cpp - -TESTS += test_file_errors -test_file_errors_SOURCES = \ - $(all_test_SOURCES) \ - tests/test_file_errors.cpp \ - MsdFile.cpp MsdFile.h \ - CryptManager.cpp CryptManager.h - -test_file_errors_LDADD = \ - libtomcrypt.a libtommath.a - -TESTS += test_timing_data -test_timing_data_SOURCES = \ - $(all_test_SOURCES) \ - tests/test_timing_data.cpp \ - TimingData.cpp TimingData.h - -#TESTS += test_notedata -#test_notedata_SOURCES = \ -# $(all_test_SOURCES) \ -# tests/test_notedata.cpp \ -# NoteData.cpp NoteData.h NoteDataUtil.cpp NoteDataUtil.h \ -# NewNoteData.cpp NewNoteData.h \ -# NoteTypes.cpp NoteTypes.h \ -# TimingData.cpp TimingData.h -#NewNoteDataUtil.cpp NewNoteDataUtil.h - -TESTS += test_threads -test_threads_SOURCES = \ - $(all_test_SOURCES) \ - tests/test_threads.cpp - -INCLUDES = +## Do not install stepmania in the traditional way. +noinst_PROGRAMS = stepmania +TESTS = +tests: $(TESTS) +if BUILD_TESTS +noinst_PROGRAMS += $(TESTS) +endif + +AM_LDFLAGS = +AM_CXXFLAGS = +AM_CFLAGS = +noinst_LIBRARIES = +EXTRA_DIST = + + +AM_CXXFLAGS += -fno-exceptions + +# Relax inlining; the default of 600 takes way too long to compile and +# generates enormous output. +AM_CXXFLAGS += -finline-limit=300 + +AM_CXXFLAGS += $(XCFLAGS) + +LIBS += +LIBS += -lpthread -lrt + +.PHONY: increment_version + +all: increment_version + +increment_version: + if test -e ver.cpp; then \ + build=`sed -rs 's/.*version_num = ([[:digit:]]+);/\1/;q' ver.cpp`; \ + build=`expr $$build + 1`; \ + else \ + build=0; \ + fi; \ + echo "extern const unsigned long version_num = $$build;" > ver.cpp; \ + echo "extern const char *const version_time = \"`date`\";" >> ver.cpp; + echo "extern const char *const version_date = \"`date`\";" >> ver.cpp; + +ver.cpp: + $(MAKE) increment_version + +Screens = \ +Screen.cpp Screen.h ScreenAttract.cpp ScreenAttract.h \ +ScreenBookkeeping.cpp ScreenBookkeeping.h \ +ScreenContinue.cpp ScreenContinue.h \ +ScreenDebugOverlay.cpp ScreenDebugOverlay.h \ +ScreenDemonstration.cpp ScreenDemonstration.h ScreenDimensions.h \ +ScreenEdit.cpp ScreenEdit.h \ +ScreenEditMenu.cpp ScreenEditMenu.h ScreenEnding.cpp ScreenEnding.h \ +ScreenEvaluation.cpp ScreenEvaluation.h \ +ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ +ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNetSelectBase.h ScreenNetRoom.cpp ScreenNetRoom.h \ +ScreenGameplay.cpp ScreenGameplay.h \ +ScreenGameplayLesson.cpp ScreenGameplayLesson.h \ +ScreenGameplayNormal.cpp ScreenGameplayNormal.h \ +ScreenGameplayShared.cpp ScreenGameplayShared.h \ +ScreenGameplaySyncMachine.cpp ScreenGameplaySyncMachine.h \ +ScreenHighScores.cpp ScreenHighScores.h \ +ScreenHowToPlay.cpp ScreenHowToPlay.h \ +ScreenInstallOverlay.cpp ScreenInstallOverlay.h \ +ScreenInstructions.cpp ScreenInstructions.h \ +ScreenJukebox.cpp ScreenJukebox.h \ +ScreenMapControllers.cpp ScreenMapControllers.h \ +ScreenMessage.cpp ScreenMessage.h ScreenMiniMenu.cpp ScreenMiniMenu.h \ +ScreenNameEntry.cpp ScreenNameEntry.h ScreenNameEntryTraditional.cpp ScreenNameEntryTraditional.h \ +ScreenOptions.cpp ScreenOptions.h \ +ScreenOptionsEditProfile.cpp ScreenOptionsEditProfile.h \ +ScreenOptionsManageCourses.cpp ScreenOptionsManageCourses.h \ +ScreenOptionsManageEditSteps.cpp ScreenOptionsManageEditSteps.h \ +ScreenOptionsManageProfiles.cpp ScreenOptionsManageProfiles.h \ +ScreenOptionsMaster.cpp ScreenOptionsMaster.h \ +ScreenOptionsMasterPrefs.cpp ScreenOptionsMasterPrefs.h \ +ScreenOptionsToggleSongs.cpp ScreenOptionsToggleSongs.h \ +ScreenPackages.cpp ScreenPackages.h ScreenPackagesSSC.cpp ScreenPackagesSSC.h \ +ScreenNetworkOptions.h ScreenNetworkOptions.cpp \ +ScreenPlayerOptions.cpp ScreenPlayerOptions.h \ +ScreenProfileLoad.cpp ScreenProfileLoad.h \ +ScreenProfileSave.cpp ScreenProfileSave.h \ +ScreenPrompt.cpp ScreenPrompt.h ScreenRanking.cpp ScreenRanking.h \ +ScreenReloadSongs.cpp ScreenReloadSongs.h \ +ScreenSandbox.cpp ScreenSandbox.h \ +ScreenSaveSync.cpp ScreenSaveSync.h \ +ScreenServiceAction.cpp ScreenServiceAction.h \ +ScreenStatsOverlay.cpp ScreenStatsOverlay.h \ +ScreenSelect.cpp ScreenSelect.h ScreenSelectCharacter.cpp ScreenSelectCharacter.h \ +ScreenSelectLanguage.cpp ScreenSelectLanguage.h \ +ScreenSelectMaster.cpp ScreenSelectMaster.h \ +ScreenSelectMusic.cpp ScreenSelectMusic.h \ +ScreenSelectProfile.cpp ScreenSelectProfile.h \ +ScreenSyncOverlay.cpp ScreenSyncOverlay.h \ +ScreenSystemLayer.cpp ScreenSystemLayer.h ScreenSetTime.cpp ScreenSetTime.h \ +ScreenSongOptions.cpp ScreenSongOptions.h \ +ScreenSplash.cpp ScreenSplash.h \ +ScreenTestFonts.cpp ScreenTestFonts.h ScreenTestInput.cpp ScreenTestInput.h \ +ScreenTestLights.cpp ScreenTestLights.h ScreenTestSound.cpp ScreenTestSound.h ScreenTextEntry.cpp ScreenTextEntry.h \ +ScreenTitleMenu.cpp ScreenTitleMenu.h \ +ScreenUnlockBrowse.cpp ScreenUnlockBrowse.h \ +ScreenUnlockCelebrate.cpp ScreenUnlockCelebrate.h \ +ScreenUnlockStatus.cpp ScreenUnlockStatus.h \ +ScreenWithMenuElements.cpp ScreenWithMenuElements.h + +if !WITHOUT_NETWORKING +Screens += ScreenSMOnlineLogin.cpp ScreenSMOnlineLogin.h +endif + +DataStructures = \ +Attack.cpp Attack.h AutoKeysounds.cpp AutoKeysounds.h \ +AdjustSync.cpp AdjustSync.h \ +BackgroundUtil.cpp BackgroundUtil.h \ +BannerCache.cpp BannerCache.h \ +Character.cpp Character.h \ +CodeDetector.cpp CodeDetector.h \ +CodeSet.cpp CodeSet.h \ +Command.cpp Command.h \ +CommonMetrics.cpp CommonMetrics.h \ +Course.cpp Course.h \ +CourseLoaderCRS.cpp CourseLoaderCRS.h \ +CourseUtil.cpp CourseUtil.h \ +CourseWriterCRS.cpp CourseWriterCRS.h \ +CryptHelpers.cpp CryptHelpers.h \ +DateTime.cpp DateTime.h \ +Difficulty.cpp Difficulty.h \ +DisplayResolutions.h \ +EnumHelper.cpp EnumHelper.h \ +FileDownload.cpp FileDownload.h \ +Font.cpp Font.h \ +FontCharAliases.cpp FontCharAliases.h \ +FontCharmaps.cpp FontCharmaps.h Game.cpp Game.h GameCommand.cpp GameCommand.h \ +GameplayAssist.cpp GameplayAssist.h \ +GameConstantsAndTypes.cpp GameConstantsAndTypes.h \ +GamePreferences.cpp GamePreferences.h \ +GameInput.cpp GameInput.h Grade.cpp Grade.h \ +HighScore.cpp HighScore.h \ +InputEventPlus.h \ +Inventory.cpp Inventory.h \ +JsonUtil.cpp JsonUtil.h \ +LocalizedString.cpp LocalizedString.h \ +LuaReference.cpp LuaReference.h \ +LuaExpressionTransform.cpp LuaExpressionTransform.h \ +LyricsLoader.cpp LyricsLoader.h \ +ModsGroup.cpp ModsGroup.h \ +NoteData.cpp NoteData.h NoteDataUtil.cpp NoteDataUtil.h NoteDataWithScoring.cpp NoteDataWithScoring.h \ +NoteTypes.cpp NoteTypes.h NotesLoader.cpp NotesLoader.h \ +NotesLoaderBMS.cpp NotesLoaderBMS.h NotesLoaderDWI.cpp NotesLoaderDWI.h NotesLoaderKSF.cpp NotesLoaderKSF.h NotesLoaderMidi.cpp NotesLoaderMidi.h \ +NotesLoaderPMS.cpp NotesLoaderPMS.h NotesLoaderSM.cpp NotesLoaderSM.h NotesWriterDWI.cpp NotesWriterDWI.h NotesWriterSM.cpp NotesWriterSM.h \ +OptionRowHandler.cpp OptionRowHandler.h OptionsList.cpp OptionsList.h \ +PlayerAI.cpp PlayerAI.h PlayerNumber.cpp PlayerNumber.h PlayerOptions.cpp PlayerOptions.h \ +PlayerStageStats.cpp PlayerStageStats.h \ +PlayerState.cpp PlayerState.h Preference.cpp Preference.h Profile.cpp Profile.h \ +RandomSample.cpp RandomSample.h RadarValues.cpp RadarValues.h \ +SampleHistory.cpp SampleHistory.h \ +ScreenDimensions.h ScreenDimensions.cpp \ +ScoreKeeper.h ScoreKeeper.cpp \ +ScoreKeeperGuitar.cpp ScoreKeeperGuitar.h \ +ScoreKeeperNormal.cpp ScoreKeeperNormal.h \ +ScoreKeeperRave.cpp ScoreKeeperRave.h \ +ScoreKeeperShared.cpp ScoreKeeperShared.h \ +Song.cpp Song.h SongCacheIndex.cpp SongCacheIndex.h \ +SongOptions.cpp SongOptions.h SongUtil.cpp SongUtil.h StageStats.cpp StageStats.h Steps.cpp Steps.h \ +SoundEffectControl.cpp SoundEffectControl.h \ +StepsUtil.cpp StepsUtil.h Style.cpp Style.h StyleUtil.cpp StyleUtil.h \ +SubscriptionManager.h \ +TimingData.cpp TimingData.h \ +ThemeMetric.h \ +Trail.cpp Trail.h TrailUtil.cpp TrailUtil.h TitleSubstitution.cpp TitleSubstitution.h \ +Tween.cpp Tween.h + +if !WITHOUT_NETWORKING +DataStructures += RoomWheel.cpp RoomWheel.h +endif + +FileTypes = IniFile.cpp IniFile.h \ +MsdFile.cpp MsdFile.h \ +XmlFile.cpp XmlFile.h \ +XmlFileUtil.cpp XmlFileUtil.h + +StepMania = CommandLineActions.h CommandLineActions.cpp \ +StdString.h Foreach.h \ +StepMania.cpp StepMania.h \ +GameLoop.cpp GameLoop.h \ +global.cpp global.h \ +SpecialFiles.cpp SpecialFiles.h \ +ProductInfo.h + +LoadingWindow = arch/LoadingWindow/LoadingWindow.cpp \ + arch/LoadingWindow/LoadingWindow.h \ + arch/LoadingWindow/LoadingWindow_Null.h + +if HAVE_GTK +LoadingWindow += arch/LoadingWindow/LoadingWindow_Gtk.cpp arch/LoadingWindow/LoadingWindow_Gtk.h \ +arch/LoadingWindow/LoadingWindow_GtkModule.h +endif + +Sound = arch/Sound/RageSoundDriver.h arch/Sound/RageSoundDriver.cpp \ + arch/Sound/RageSoundDriver_Null.cpp arch/Sound/RageSoundDriver_Null.h \ + arch/Sound/RageSoundDriver_Generic_Software.cpp + +if HAVE_PULSE +Sound += arch/Sound/RageSoundDriver_PulseAudio.cpp arch/Sound/RageSoundDriver_PulseAudio.h +endif + +if HAVE_OSS +Sound += arch/Sound/RageSoundDriver_OSS.cpp arch/Sound/RageSoundDriver_OSS.h +endif + +if HAVE_ALSA +Sound += arch/Sound/ALSA9Dynamic.cpp arch/Sound/ALSA9Dynamic.h arch/Sound/ALSA9Functions.h \ + arch/Sound/ALSA9Helpers.cpp arch/Sound/ALSA9Helpers.h \ + arch/Sound/RageSoundDriver_ALSA9_Software.cpp arch/Sound/RageSoundDriver_ALSA9_Software.h + +# Add this to AM_CXXFLAGS, not stepmania_CXXFLAGS: that'll cause multiple copies of +# several sources to be built. We link to this at runtime, so don't add ALSA_LDFLAGS. +AM_CXXFLAGS += $(ALSA_CFLAGS) +endif + +ArchHooks = arch/ArchHooks/ArchHooks.cpp arch/ArchHooks/ArchHooks.h \ + arch/ArchHooks/ArchHooksUtil.cpp + +InputHandler = arch/InputHandler/InputHandler.cpp arch/InputHandler/InputHandler.h \ + arch/InputHandler/InputHandler_MonkeyKeyboard.cpp arch/InputHandler/InputHandler_MonkeyKeyboard.h + +MovieTexture = arch/MovieTexture/MovieTexture.cpp arch/MovieTexture/MovieTexture.h \ + arch/MovieTexture/MovieTexture_Generic.cpp arch/MovieTexture/MovieTexture_Generic.h \ + arch/MovieTexture/MovieTexture_Null.cpp arch/MovieTexture/MovieTexture_Null.h + +if HAVE_THEORA +MovieTexture += arch/MovieTexture/MovieTexture_Theora.cpp arch/MovieTexture/MovieTexture_Theora.h +endif + +if HAVE_FFMPEG +MovieTexture += arch/MovieTexture/MovieTexture_FFMpeg.cpp arch/MovieTexture/MovieTexture_FFMpeg.h +endif + +Lights = arch/Lights/LightsDriver.cpp arch/Lights/LightsDriver.h \ + arch/Lights/LightsDriver_Export.cpp arch/Lights/LightsDriver_Export.h \ + arch/Lights/LightsDriver_SystemMessage.cpp arch/Lights/LightsDriver_SystemMessage.h + +MemoryCard = arch/MemoryCard/MemoryCardDriver.cpp arch/MemoryCard/MemoryCardDriver.h arch/MemoryCard/MemoryCardDriver_Null.h +LowLevelWindow = arch/LowLevelWindow/LowLevelWindow.cpp arch/LowLevelWindow/LowLevelWindow.h + +ArchUtils = + +Dialog = arch/Dialog/Dialog.cpp arch/Dialog/Dialog.h arch/Dialog/DialogDriver.h arch/Dialog/DialogDriver.cpp + +Threads = arch/Threads/Threads.h + +if HAVE_X11 +# InputHandler_X11 depends on LowLevelWindow_X11 +InputHandler += arch/InputHandler/InputHandler_X11.cpp arch/InputHandler/InputHandler_X11.h +LowLevelWindow += arch/LowLevelWindow/LowLevelWindow_X11.cpp arch/LowLevelWindow/LowLevelWindow_X11.h +LowLevelWindow += archutils/Unix/X11Helper.cpp archutils/Unix/X11Helper.h +endif + +# Platform-specific drivers: + +if UNIX +ArchHooks += arch/ArchHooks/ArchHooks_Unix.cpp arch/ArchHooks/ArchHooks_Unix.h +Threads += arch/Threads/Threads_Pthreads.cpp arch/Threads/Threads_Pthreads.h +if LINUX +Lights += arch/Lights/LightsDriver_LinuxWeedTech.cpp arch/Lights/LightsDriver_LinuxWeedTech.h +if HAVE_PARALLEL_PORT +Lights += arch/Lights/LightsDriver_LinuxParallel.cpp arch/Lights/LightsDriver_LinuxParallel.h +endif +endif + +ArchUtils += archutils/Unix/AssertionHandler.cpp archutils/Unix/AssertionHandler.h \ + archutils/Unix/arch_setup.h \ + archutils/Unix/GetSysInfo.cpp archutils/Unix/GetSysInfo.h \ + archutils/Unix/SignalHandler.cpp archutils/Unix/SignalHandler.h \ + archutils/Unix/LinuxThreadHelpers.cpp archutils/Unix/LinuxThreadHelpers.h \ + archutils/Unix/RunningUnderValgrind.cpp archutils/Unix/RunningUnderValgrind.h \ + archutils/Unix/EmergencyShutdown.cpp archutils/Unix/EmergencyShutdown.h \ + archutils/Unix/StackCheck.cpp \ + archutils/Common/gcc_byte_swaps.h + +if USE_CRASH_HANDLER +ArchUtils += archutils/Unix/Backtrace.cpp archutils/Unix/Backtrace.h \ + archutils/Unix/BacktraceNames.cpp archutils/Unix/BacktraceNames.h \ + archutils/Unix/CrashHandler.cpp archutils/Unix/CrashHandler.h \ + archutils/Unix/CrashHandlerChild.cpp archutils/Unix/CrashHandlerInternal.h \ + archutils/Unix/CrashHandlerInternal.cpp +endif + +endif + +if LINUX +MemoryCard += arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp arch/MemoryCard/MemoryCardDriverThreaded_Linux.h +InputHandler += arch/InputHandler/InputHandler_Linux_Joystick.cpp arch/InputHandler/InputHandler_Linux_Joystick.h +InputHandler += arch/InputHandler/InputHandler_Linux_Event.cpp arch/InputHandler/InputHandler_Linux_Event.h +endif + +Arch = $(LoadingWindow) $(Sound) $(ArchHooks) $(InputHandler) $(MovieTexture) \ + $(Lights) $(MemoryCard) $(LowLevelWindow) $(ArchUtils) $(Dialog) $(Threads) \ + arch/arch_default.h arch/RageDriver.cpp arch/RageDriver.h + +RageSoundFileReaders = RageSoundReader_WAV.cpp RageSoundReader_WAV.h + +if HAVE_VORBIS +RageSoundFileReaders += RageSoundReader_Vorbisfile.cpp RageSoundReader_Vorbisfile.h +endif + +if HAVE_MP3 +RageSoundFileReaders += RageSoundReader_MP3.cpp RageSoundReader_MP3.h +endif + +ActorsInGameplayAndMenus = \ +BGAnimation.cpp BGAnimation.h BGAnimationLayer.cpp BGAnimationLayer.h Banner.cpp Banner.h \ +DifficultyIcon.cpp DifficultyIcon.h \ +MeterDisplay.cpp MeterDisplay.h StreamDisplay.cpp StreamDisplay.h \ +Transition.cpp Transition.h + +ActorsInMenus = \ +ActiveAttackList.cpp ActiveAttackList.h BPMDisplay.cpp BPMDisplay.h ComboGraph.cpp ComboGraph.h \ +CourseContentsList.cpp CourseContentsList.h \ +StepsDisplay.cpp StepsDisplay.h \ +DifficultyList.cpp DifficultyList.h \ +DualScrollBar.cpp DualScrollBar.h \ +EditMenu.cpp EditMenu.h FadingBanner.cpp FadingBanner.h \ +GradeDisplay.cpp GradeDisplay.h GraphDisplay.cpp GraphDisplay.h \ +GrooveRadar.cpp GrooveRadar.h GroupList.cpp GroupList.h HelpDisplay.cpp HelpDisplay.h \ +MemoryCardDisplay.cpp MemoryCardDisplay.h \ +MenuTimer.cpp MenuTimer.h \ +ModIcon.cpp ModIcon.h ModIconRow.cpp ModIconRow.h \ +MusicList.cpp MusicList.h MusicWheel.cpp MusicWheel.h \ +MusicWheelItem.cpp MusicWheelItem.h \ +OptionRow.cpp OptionRow.h OptionsCursor.cpp OptionsCursor.h \ +PaneDisplay.cpp PaneDisplay.h ScrollBar.cpp ScrollBar.h \ +SnapDisplay.cpp SnapDisplay.h \ +TextBanner.cpp TextBanner.h WheelBase.cpp WheelBase.h WheelItemBase.cpp WheelItemBase.h \ +WheelNotifyIcon.cpp WheelNotifyIcon.h \ +WorkoutGraph.cpp WorkoutGraph.h + +if !WITHOUT_NETWORKING +ActorsInMenus += RoomInfoDisplay.cpp RoomInfoDisplay.h +endif + +ActorsInGameplay = \ +ArrowEffects.cpp ArrowEffects.h AttackDisplay.cpp AttackDisplay.h \ +Background.cpp Background.h BeginnerHelper.cpp BeginnerHelper.h CombinedLifeMeter.h CombinedLifeMeterTug.cpp CombinedLifeMeterTug.h \ +DancingCharacters.cpp DancingCharacters.h Foreground.cpp Foreground.h \ +GhostArrowRow.cpp GhostArrowRow.h HoldJudgment.cpp HoldJudgment.h \ +LifeMeter.cpp LifeMeter.h \ +LifeMeterBar.cpp LifeMeterBar.h \ +LifeMeterBattery.cpp LifeMeterBattery.h LifeMeterTime.cpp LifeMeterTime.h \ +LyricDisplay.cpp LyricDisplay.h NoteDisplay.cpp NoteDisplay.h NoteField.cpp NoteField.h \ +PercentageDisplay.cpp PercentageDisplay.h Player.cpp Player.h \ +ReceptorArrow.cpp ReceptorArrow.h ReceptorArrowRow.cpp ReceptorArrowRow.h \ +ScoreDisplay.cpp ScoreDisplay.h \ +ScoreDisplayAliveTime.cpp ScoreDisplayAliveTime.h \ +ScoreDisplayBattle.cpp ScoreDisplayBattle.h \ +ScoreDisplayCalories.cpp ScoreDisplayCalories.h \ +ScoreDisplayLifeTime.cpp ScoreDisplayLifeTime.h \ +ScoreDisplayNormal.cpp ScoreDisplayNormal.h ScoreDisplayOni.cpp ScoreDisplayOni.h \ +ScoreDisplayPercentage.cpp ScoreDisplayPercentage.h ScoreDisplayRave.cpp ScoreDisplayRave.h + +PCRE = pcre/get.c pcre/internal.h pcre/maketables.c pcre/pcre.c pcre/pcre.h pcre/study.c +EXTRA_DIST += pcre/chartables.c + +Lua = lua-5.1/src/lapi.c lua-5.1/src/lauxlib.c lua-5.1/src/lbaselib.c lua-5.1/src/lcode.c lua-5.1/src/ldblib.c \ +lua-5.1/src/ldebug.c lua-5.1/src/ldo.c lua-5.1/src/ldump.c lua-5.1/src/lfunc.c lua-5.1/src/lgc.c lua-5.1/src/linit.c \ +lua-5.1/src/liolib.c lua-5.1/src/llex.c lua-5.1/src/lmathlib.c lua-5.1/src/lmem.c lua-5.1/src/loadlib.c \ +lua-5.1/src/lobject.c lua-5.1/src/lopcodes.c lua-5.1/src/loslib.c lua-5.1/src/lparser.c lua-5.1/src/lstate.c \ +lua-5.1/src/lstring.c lua-5.1/src/lstrlib.c lua-5.1/src/ltable.c lua-5.1/src/ltablib.c lua-5.1/src/ltm.c \ +lua-5.1/src/lundump.c lua-5.1/src/lvm.c lua-5.1/src/lzio.c lua-5.1/src/lapi.h lua-5.1/src/lauxlib.h lua-5.1/src/lcode.h \ +lua-5.1/src/ldebug.h lua-5.1/src/ldo.h lua-5.1/src/lfunc.h lua-5.1/src/lgc.h lua-5.1/src/llex.h lua-5.1/src/llimits.h \ +lua-5.1/src/lmem.h lua-5.1/src/lobject.h lua-5.1/src/lopcodes.h lua-5.1/src/lparser.h lua-5.1/src/lstate.h \ +lua-5.1/src/lstring.h lua-5.1/src/ltable.h lua-5.1/src/ltm.h lua-5.1/src/luaconf.h lua-5.1/src/lua.h lua-5.1/src/lualib.h \ +lua-5.1/src/lundump.h lua-5.1/src/lvm.h lua-5.1/src/lzio.h + +jsoncpp = jsoncpp/src/lib_json/json_reader.cpp jsoncpp/src/lib_json/json_value.cpp \ +jsoncpp/src/lib_json/json_writer.cpp + +RageFile = \ +RageFileBasic.cpp RageFileBasic.h \ +RageFile.cpp RageFile.h RageFileDriver.cpp RageFileDriver.h RageFileManager.cpp RageFileManager.h \ +RageFileManager_ReadAhead.cpp RageFileManager_ReadAhead.h \ +RageFileDriverDirect.cpp RageFileDriverDirect.h RageFileDriverDirectHelpers.cpp RageFileDriverDirectHelpers.h \ +RageFileDriverMemory.cpp RageFileDriverMemory.h RageFileDriverZip.cpp RageFileDriverZip.h \ +RageFileDriverDeflate.cpp RageFileDriverDeflate.h \ +RageFileDriverReadAhead.cpp RageFileDriverReadAhead.h \ +RageFileDriverSlice.cpp RageFileDriverSlice.h \ +RageFileDriverTimeout.cpp RageFileDriverTimeout.h + +Rage = $(PCRE) $(Lua) $(jsoncpp) $(RageFile) $(RageSoundFileReaders) \ +RageBitmapTexture.cpp RageBitmapTexture.h RageDisplay.cpp RageDisplay.h RageDisplay_OGL.cpp RageDisplay_OGL.h \ +RageDisplay_OGL_Helpers.cpp RageDisplay_OGL_Helpers.h glext.h \ +RageDisplay_Null.cpp RageDisplay_Null.h RageException.cpp RageException.h RageInput.cpp RageInput.h \ +RageInputDevice.cpp RageInputDevice.h RageLog.cpp RageLog.h RageMath.cpp RageMath.h \ +RageModelGeometry.cpp RageModelGeometry.h RageSound.cpp RageSound.h RageSoundManager.cpp RageSoundManager.h \ +RageSoundUtil.cpp RageSoundUtil.h RageSoundMixBuffer.cpp RageSoundMixBuffer.h \ +RageSoundPosMap.cpp RageSoundPosMap.h RageSoundReader.cpp RageSoundReader.h RageSoundReader_FileReader.cpp RageSoundReader_FileReader.h \ +RageSoundReader_Filter.h \ +RageSoundReader_ChannelSplit.cpp RageSoundReader_ChannelSplit.h \ +RageSoundReader_Extend.cpp RageSoundReader_Extend.h \ +RageSoundReader_Merge.cpp RageSoundReader_Merge.h \ +RageSoundReader_PitchChange.cpp RageSoundReader_PitchChange.h \ +RageSoundReader_PostBuffering.cpp RageSoundReader_PostBuffering.h \ +RageSoundReader_Pan.cpp RageSoundReader_Pan.h \ +RageSoundReader_Preload.cpp RageSoundReader_Preload.h \ +RageSoundReader_Resample_Good.cpp RageSoundReader_Resample_Good.h \ +RageSoundReader_SpeedChange.cpp RageSoundReader_SpeedChange.h \ +RageSoundReader_ThreadedBuffer.cpp RageSoundReader_ThreadedBuffer.h \ +RageSoundReader_Chain.cpp RageSoundReader_Chain.h \ +RageSurface.cpp RageSurface.h RageSurfaceUtils.cpp RageSurfaceUtils.h \ +RageSurfaceUtils_Dither.cpp RageSurfaceUtils_Dither.h \ +RageSurface_Save_JPEG.cpp RageSurface_Save_JPEG.h \ +RageSurfaceUtils_Palettize.cpp RageSurfaceUtils_Palettize.h \ +RageSurfaceUtils_Zoom.cpp RageSurfaceUtils_Zoom.h \ +RageSurface_Load.cpp RageSurface_Load.h RageSurface_Load_PNG.cpp RageSurface_Load_PNG.h \ +RageSurface_Load_JPEG.cpp RageSurface_Load_JPEG.h RageSurface_Load_GIF.cpp RageSurface_Load_GIF.h \ +RageSurface_Load_BMP.cpp RageSurface_Load_BMP.h \ +RageSurface_Load_XPM.cpp RageSurface_Load_XPM.h RageTexture.cpp RageTexture.h \ +RageTexturePreloader.cpp RageTexturePreloader.h \ +RageTextureRenderTarget.cpp RageTextureRenderTarget.h \ +RageSurface_Save_BMP.cpp RageSurface_Save_BMP.h \ +RageSurface_Save_PNG.cpp RageSurface_Save_PNG.h \ +RageTextureID.cpp RageTextureID.h RageTextureManager.cpp RageTextureManager.h RageThreads.cpp RageThreads.h \ +RageTimer.cpp RageTimer.h RageTypes.cpp RageTypes.h RageUtil.cpp RageUtil.h \ +RageUtil_CachedObject.cpp RageUtil_CachedObject.h \ +RageUtil_CharConversions.cpp RageUtil_CharConversions.h \ +RageUtil_BackgroundLoader.cpp RageUtil_BackgroundLoader.h RageUtil_FileDB.cpp RageUtil_FileDB.h RageUtil_CircularBuffer.h \ +RageUtil_AutoPtr.h \ +RageUtil_WorkerThread.cpp RageUtil_WorkerThread.h + +Actors = \ +Actor.cpp Actor.h ActorFrame.cpp ActorFrame.h \ +ActorFrameTexture.cpp ActorFrameTexture.h \ +ActorMultiTexture.cpp ActorMultiTexture.h \ +ActorProxy.cpp ActorProxy.h \ +ActorScroller.cpp ActorScroller.h ActorUtil.cpp ActorUtil.h \ +ActorSound.cpp ActorSound.h \ +AutoActor.cpp AutoActor.h \ +BitmapText.cpp BitmapText.h Model.cpp Model.h \ +DynamicActorScroller.cpp DynamicActorScroller.h \ +ModelManager.cpp ModelManager.h ModelTypes.cpp ModelTypes.h \ +Quad.cpp Quad.h \ +RollingNumbers.cpp RollingNumbers.h Sprite.cpp Sprite.h + +GlobalSingletons = \ +AnnouncerManager.cpp AnnouncerManager.h \ +Bookkeeper.cpp Bookkeeper.h \ +CharacterManager.cpp CharacterManager.h \ +CryptManager.cpp CryptManager.h \ +FontManager.cpp FontManager.h GameSoundManager.cpp GameSoundManager.h \ +GameManager.cpp GameManager.h \ +GameState.cpp GameState.h \ +InputFilter.cpp InputFilter.h \ +InputMapper.cpp InputMapper.h InputQueue.cpp InputQueue.h \ +LuaBinding.cpp LuaBinding.h \ +LuaManager.cpp LuaManager.h LightsManager.cpp LightsManager.h \ +MemoryCardManager.cpp MemoryCardManager.h \ +MessageManager.cpp MessageManager.h NetworkSyncManager.cpp NetworkSyncManager.h \ +NoteSkinManager.cpp NoteSkinManager.h \ +PrefsManager.cpp PrefsManager.h ProfileManager.cpp ProfileManager.h ScreenManager.cpp \ +ScreenManager.h SongManager.cpp SongManager.h \ +StatsManager.cpp StatsManager.h \ +ThemeManager.cpp ThemeManager.h \ +UnlockManager.cpp UnlockManager.h + +if !WITHOUT_NETWORKING +# Compile NetworkSyncManager even if networking is disabled; it'll stub itself. +GlobalSingletons += ezsockets.cpp ezsockets.h +endif + +libtommath_a_SOURCES = \ +libtommath/bncore.c libtommath/bn_mp_init.c libtommath/bn_mp_clear.c libtommath/bn_mp_exch.c libtommath/bn_mp_grow.c libtommath/bn_mp_shrink.c \ +libtommath/bn_mp_clamp.c libtommath/bn_mp_zero.c libtommath/bn_mp_set.c libtommath/bn_mp_set_int.c libtommath/bn_mp_init_size.c libtommath/bn_mp_copy.c \ +libtommath/bn_mp_init_copy.c libtommath/bn_mp_abs.c libtommath/bn_mp_neg.c libtommath/bn_mp_cmp_mag.c libtommath/bn_mp_cmp.c libtommath/bn_mp_cmp_d.c \ +libtommath/bn_mp_rshd.c libtommath/bn_mp_lshd.c libtommath/bn_mp_mod_2d.c libtommath/bn_mp_div_2d.c libtommath/bn_mp_mul_2d.c libtommath/bn_mp_div_2.c \ +libtommath/bn_mp_mul_2.c libtommath/bn_s_mp_add.c libtommath/bn_s_mp_sub.c libtommath/bn_fast_s_mp_mul_digs.c libtommath/bn_s_mp_mul_digs.c \ +libtommath/bn_fast_s_mp_mul_high_digs.c libtommath/bn_s_mp_mul_high_digs.c libtommath/bn_fast_s_mp_sqr.c libtommath/bn_s_mp_sqr.c \ +libtommath/bn_mp_add.c libtommath/bn_mp_sub.c libtommath/bn_mp_karatsuba_mul.c libtommath/bn_mp_mul.c libtommath/bn_mp_karatsuba_sqr.c \ +libtommath/bn_mp_sqr.c libtommath/bn_mp_div.c libtommath/bn_mp_mod.c libtommath/bn_mp_add_d.c libtommath/bn_mp_sub_d.c libtommath/bn_mp_mul_d.c \ +libtommath/bn_mp_div_d.c libtommath/bn_mp_mod_d.c libtommath/bn_mp_expt_d.c libtommath/bn_mp_addmod.c libtommath/bn_mp_submod.c \ +libtommath/bn_mp_mulmod.c libtommath/bn_mp_sqrmod.c libtommath/bn_mp_gcd.c libtommath/bn_mp_lcm.c libtommath/bn_fast_mp_invmod.c libtommath/bn_mp_invmod.c \ +libtommath/bn_mp_reduce.c libtommath/bn_mp_montgomery_setup.c libtommath/bn_fast_mp_montgomery_reduce.c libtommath/bn_mp_montgomery_reduce.c \ +libtommath/bn_mp_exptmod_fast.c libtommath/bn_mp_exptmod.c libtommath/bn_mp_2expt.c libtommath/bn_mp_n_root.c libtommath/bn_mp_jacobi.c libtommath/bn_reverse.c \ +libtommath/bn_mp_count_bits.c libtommath/bn_mp_read_unsigned_bin.c libtommath/bn_mp_read_signed_bin.c libtommath/bn_mp_to_unsigned_bin.c \ +libtommath/bn_mp_to_signed_bin.c libtommath/bn_mp_unsigned_bin_size.c libtommath/bn_mp_signed_bin_size.c \ +libtommath/bn_mp_xor.c libtommath/bn_mp_and.c libtommath/bn_mp_or.c libtommath/bn_mp_rand.c libtommath/bn_mp_montgomery_calc_normalization.c \ +libtommath/bn_mp_prime_is_divisible.c libtommath/bn_prime_tab.c libtommath/bn_mp_prime_fermat.c libtommath/bn_mp_prime_miller_rabin.c \ +libtommath/bn_mp_prime_is_prime.c libtommath/bn_mp_prime_next_prime.c libtommath/bn_mp_dr_reduce.c \ +libtommath/bn_mp_dr_is_modulus.c libtommath/bn_mp_dr_setup.c libtommath/bn_mp_reduce_setup.c \ +libtommath/bn_mp_toom_mul.c libtommath/bn_mp_toom_sqr.c libtommath/bn_mp_div_3.c libtommath/bn_s_mp_exptmod.c \ +libtommath/bn_mp_reduce_2k.c libtommath/bn_mp_reduce_is_2k.c libtommath/bn_mp_reduce_2k_setup.c \ +libtommath/bn_mp_reduce_2k_l.c libtommath/bn_mp_reduce_is_2k_l.c libtommath/bn_mp_reduce_2k_setup_l.c \ +libtommath/bn_mp_radix_smap.c libtommath/bn_mp_read_radix.c libtommath/bn_mp_toradix.c libtommath/bn_mp_radix_size.c \ +libtommath/bn_mp_fread.c libtommath/bn_mp_fwrite.c libtommath/bn_mp_cnt_lsb.c libtommath/bn_error.c \ +libtommath/bn_mp_init_multi.c libtommath/bn_mp_clear_multi.c libtommath/bn_mp_exteuclid.c libtommath/bn_mp_toradix_n.c \ +libtommath/bn_mp_prime_random_ex.c libtommath/bn_mp_get_int.c libtommath/bn_mp_sqrt.c libtommath/bn_mp_is_square.c libtommath/bn_mp_init_set.c \ +libtommath/bn_mp_init_set_int.c libtommath/bn_mp_invmod_slow.c libtommath/bn_mp_prime_rabin_miller_trials.c \ +libtommath/bn_mp_to_signed_bin_n.c libtommath/bn_mp_to_unsigned_bin_n.c \ +libtommath/tommath_class.h libtommath/tommath.h libtommath/tommath_superclass.h +EXTRA_DIST += libtommath/bn_prime_tab.c + +libtommath_a_CPPFLAGS = -I$(srcdir)/libtommath $(AM_CPPFLAGS) +noinst_LIBRARIES += libtommath.a + +libtomcrypt_a_SOURCES = \ +libtomcrypt/src/ciphers/aes/aes.c \ +libtomcrypt/src/hashes/md5.c libtomcrypt/src/hashes/sha1.c libtomcrypt/src/hashes/helper/hash_memory.c \ +libtomcrypt/src/math/fp/ltc_ecc_fp_mulmod.c libtomcrypt/src/math/ltm_desc.c libtomcrypt/src/math/multi.c \ +libtomcrypt/src/math/rand_prime.c libtomcrypt/src/misc/base64/base64_decode.c \ +libtomcrypt/src/misc/base64/base64_encode.c libtomcrypt/src/misc/burn_stack.c libtomcrypt/src/misc/crypt/crypt.c \ +libtomcrypt/src/misc/crypt/crypt_argchk.c libtomcrypt/src/misc/crypt/crypt_cipher_descriptor.c \ +libtomcrypt/src/misc/crypt/crypt_cipher_is_valid.c libtomcrypt/src/misc/crypt/crypt_find_cipher.c \ +libtomcrypt/src/misc/crypt/crypt_find_cipher_any.c libtomcrypt/src/misc/crypt/crypt_find_cipher_id.c \ +libtomcrypt/src/misc/crypt/crypt_find_hash.c libtomcrypt/src/misc/crypt/crypt_find_hash_any.c \ +libtomcrypt/src/misc/crypt/crypt_find_hash_id.c libtomcrypt/src/misc/crypt/crypt_find_hash_oid.c \ +libtomcrypt/src/misc/crypt/crypt_find_prng.c libtomcrypt/src/misc/crypt/crypt_fsa.c libtomcrypt/src/misc/crypt/crypt_hash_descriptor.c \ +libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c libtomcrypt/src/misc/crypt/crypt_ltc_mp_descriptor.c \ +libtomcrypt/src/misc/crypt/crypt_prng_descriptor.c libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c \ +libtomcrypt/src/misc/crypt/crypt_register_cipher.c libtomcrypt/src/misc/crypt/crypt_register_hash.c \ +libtomcrypt/src/misc/crypt/crypt_register_prng.c libtomcrypt/src/misc/crypt/crypt_unregister_cipher.c \ +libtomcrypt/src/misc/crypt/crypt_unregister_hash.c libtomcrypt/src/misc/crypt/crypt_unregister_prng.c \ +libtomcrypt/src/misc/error_to_string.c libtomcrypt/src/misc/pkcs5/pkcs_5_1.c libtomcrypt/src/misc/pkcs5/pkcs_5_2.c libtomcrypt/src/misc/zeromem.c \ +libtomcrypt/src/modes/cbc/cbc_decrypt.c libtomcrypt/src/modes/cbc/cbc_done.c libtomcrypt/src/modes/cbc/cbc_encrypt.c \ +libtomcrypt/src/modes/cbc/cbc_getiv.c libtomcrypt/src/modes/cbc/cbc_setiv.c libtomcrypt/src/modes/cbc/cbc_start.c \ +libtomcrypt/src/modes/cfb/cfb_decrypt.c libtomcrypt/src/modes/cfb/cfb_done.c libtomcrypt/src/modes/cfb/cfb_encrypt.c \ +libtomcrypt/src/modes/cfb/cfb_getiv.c libtomcrypt/src/modes/cfb/cfb_setiv.c libtomcrypt/src/modes/cfb/cfb_start.c \ +libtomcrypt/src/modes/ctr/ctr_decrypt.c libtomcrypt/src/modes/ctr/ctr_done.c libtomcrypt/src/modes/ctr/ctr_encrypt.c \ +libtomcrypt/src/modes/ctr/ctr_getiv.c libtomcrypt/src/modes/ctr/ctr_setiv.c libtomcrypt/src/modes/ctr/ctr_start.c libtomcrypt/src/modes/ctr/ctr_test.c \ +libtomcrypt/src/modes/ecb/ecb_decrypt.c libtomcrypt/src/modes/ecb/ecb_done.c libtomcrypt/src/modes/ecb/ecb_encrypt.c \ +libtomcrypt/src/modes/ecb/ecb_start.c \ +libtomcrypt/src/modes/ofb/ofb_decrypt.c libtomcrypt/src/modes/ofb/ofb_done.c \ +libtomcrypt/src/pk/asn1/der/bit/der_decode_bit_string.c \ +libtomcrypt/src/pk/asn1/der/bit/der_encode_bit_string.c libtomcrypt/src/pk/asn1/der/bit/der_length_bit_string.c \ +libtomcrypt/src/pk/asn1/der/boolean/der_decode_boolean.c libtomcrypt/src/pk/asn1/der/boolean/der_encode_boolean.c \ +libtomcrypt/src/pk/asn1/der/boolean/der_length_boolean.c libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c \ +libtomcrypt/src/pk/asn1/der/ia5/der_decode_ia5_string.c libtomcrypt/src/pk/asn1/der/ia5/der_encode_ia5_string.c \ +libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c libtomcrypt/src/pk/asn1/der/integer/der_decode_integer.c \ +libtomcrypt/src/pk/asn1/der/integer/der_encode_integer.c libtomcrypt/src/pk/asn1/der/integer/der_length_integer.c \ +libtomcrypt/src/pk/asn1/der/object_identifier/der_decode_object_identifier.c \ +libtomcrypt/src/pk/asn1/der/object_identifier/der_encode_object_identifier.c \ +libtomcrypt/src/pk/asn1/der/object_identifier/der_length_object_identifier.c \ +libtomcrypt/src/pk/asn1/der/octet/der_decode_octet_string.c libtomcrypt/src/pk/asn1/der/octet/der_encode_octet_string.c \ +libtomcrypt/src/pk/asn1/der/octet/der_length_octet_string.c \ +libtomcrypt/src/pk/asn1/der/printable_string/der_decode_printable_string.c \ +libtomcrypt/src/pk/asn1/der/printable_string/der_encode_printable_string.c \ +libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_ex.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_decode_sequence_multi.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_ex.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_multi.c libtomcrypt/src/pk/asn1/der/sequence/der_length_sequence.c \ +libtomcrypt/src/pk/asn1/der/sequence/der_sequence_free.c libtomcrypt/src/pk/asn1/der/set/der_encode_set.c \ +libtomcrypt/src/pk/asn1/der/set/der_encode_setof.c libtomcrypt/src/pk/asn1/der/short_integer/der_decode_short_integer.c \ +libtomcrypt/src/pk/asn1/der/short_integer/der_encode_short_integer.c \ +libtomcrypt/src/pk/asn1/der/short_integer/der_length_short_integer.c libtomcrypt/src/pk/asn1/der/utctime/der_decode_utctime.c \ +libtomcrypt/src/pk/asn1/der/utctime/der_encode_utctime.c libtomcrypt/src/pk/asn1/der/utctime/der_length_utctime.c \ +libtomcrypt/src/pk/asn1/der/utf8/der_decode_utf8_string.c libtomcrypt/src/pk/asn1/der/utf8/der_encode_utf8_string.c \ +libtomcrypt/src/pk/asn1/der/utf8/der_length_utf8_string.c libtomcrypt/src/pk/dsa/dsa_decrypt_key.c \ +libtomcrypt/src/pk/dsa/dsa_encrypt_key.c libtomcrypt/src/pk/dsa/dsa_export.c libtomcrypt/src/pk/dsa/dsa_free.c libtomcrypt/src/pk/dsa/dsa_import.c \ +libtomcrypt/src/pk/dsa/dsa_make_key.c libtomcrypt/src/pk/dsa/dsa_shared_secret.c libtomcrypt/src/pk/dsa/dsa_sign_hash.c \ +libtomcrypt/src/pk/dsa/dsa_verify_hash.c libtomcrypt/src/pk/dsa/dsa_verify_key.c \ +libtomcrypt/src/pk/pkcs1/pkcs_1_i2osp.c libtomcrypt/src/pk/pkcs1/pkcs_1_mgf1.c \ +libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c libtomcrypt/src/pk/pkcs1/pkcs_1_os2ip.c \ +libtomcrypt/src/pk/pkcs1/pkcs_1_pss_decode.c libtomcrypt/src/pk/pkcs1/pkcs_1_pss_encode.c libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_decode.c \ +libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c libtomcrypt/src/pk/rsa/rsa_decrypt_key.c libtomcrypt/src/pk/rsa/rsa_encrypt_key.c \ +libtomcrypt/src/pk/rsa/rsa_export.c libtomcrypt/src/pk/rsa/rsa_exptmod.c libtomcrypt/src/pk/rsa/rsa_free.c libtomcrypt/src/pk/rsa/rsa_import.c \ +libtomcrypt/src/pk/rsa/rsa_make_key.c libtomcrypt/src/pk/rsa/rsa_sign_hash.c libtomcrypt/src/pk/rsa/rsa_verify_hash.c libtomcrypt/src/prngs/fortuna.c \ +libtomcrypt/src/prngs/rng_get_bytes.c libtomcrypt/src/prngs/rng_make_prng.c \ +libtomcrypt/src/prngs/sprng.c libtomcrypt/src/prngs/yarrow.c \ +libtomcrypt/src/headers/tomcrypt_argchk.h libtomcrypt/src/headers/tomcrypt_cfg.h libtomcrypt/src/headers/tomcrypt_cipher.h \ +libtomcrypt/src/headers/tomcrypt_custom.h libtomcrypt/src/headers/tomcrypt.h libtomcrypt/src/headers/tomcrypt_hash.h \ +libtomcrypt/src/headers/tomcrypt_mac.h libtomcrypt/src/headers/tomcrypt_macros.h libtomcrypt/src/headers/tomcrypt_math.h \ +libtomcrypt/src/headers/tomcrypt_misc.h libtomcrypt/src/headers/tomcrypt_pkcs.h libtomcrypt/src/headers/tomcrypt_pk.h \ +libtomcrypt/src/headers/tomcrypt_prng.h +EXTRA_DIST += libtomcrypt/src/ciphers/aes/aes_tab.c libtomcrypt/src/prngs/sober128tab.c + +libtomcrypt_a_CPPFLAGS = -I$(srcdir)/libtomcrypt/src/headers $(AM_CPPFLAGS) + +noinst_LIBRARIES += libtomcrypt.a + +main_SOURCES = $(Screens) \ + $(DataStructures) \ + $(FileTypes) \ + $(StepMania) \ + $(Arch) \ + $(ActorsInGameplayAndMenus) \ + $(ActorsInMenus) \ + $(ActorsInGameplay) \ + $(Rage) \ + $(Actors) \ + $(GlobalSingletons) + +main_LDADD = \ + $(AUDIO_LIBS) \ + $(XLIBS) \ + libtomcrypt.a libtommath.a + +nodist_stepmania_SOURCES = ver.cpp +stepmania_SOURCES = $(main_SOURCES) +stepmania_LDADD = $(main_LDADD) + +if BUILD_LUA_BINARIES +noinst_PROGRAMS += lua luac +lua_SOURCES = $(Lua) lua-5.1/src/lua.c +lua_LDADD = -lreadline + +luac_SOURCES = $(Lua) lua-5.1/src/luac.c lua-5.1/src/print.c +luac_LDADD = +endif + + +if HAVE_GTK +noinst_PROGRAMS += GtkModule.so +GtkModule_so_LDFLAGS = -rdynamic -shared +GtkModule_so_CPPFLAGS = $(GTK_CFLAGS) -fPIC +GtkModule_so_LDADD = $(GTK_LIBS) +GtkModule_so_SOURCES = arch/LoadingWindow/LoadingWindow_GtkModule.cpp +endif + +all_test_SOURCES = \ + $(ArchUtils) \ + $(PCRE) \ + $(RageFile) \ + $(Lua) \ + $(ArchHooks) \ + $(Threads) \ + $(Dialog) \ + tests/test_misc.cpp tests/test_misc.h \ + IniFile.cpp IniFile.h \ + XmlFile.cpp XmlFile.h \ + Command.cpp Command.h \ + DateTime.cpp DateTime.h \ + EnumHelper.cpp EnumHelper.h \ + PrefsManager.cpp PrefsManager.h \ + Preference.cpp Preference.h \ + LocalizedString.cpp LocalizedString.h \ + LuaBinding.cpp LuaBinding.h \ + LuaManager.cpp LuaManager.h \ + LuaReference.cpp LuaReference.h \ + SpecialFiles.cpp SpecialFiles.h \ + RageException.cpp \ + RageLog.cpp \ + RageThreads.cpp \ + RageTimer.cpp RageTimer.h \ + RageUtil.cpp \ + RageUtil_FileDB.cpp RageUtil_FileDB.h \ + global.cpp global.h \ + RageUtil_WorkerThread.cpp RageUtil_WorkerThread.h \ + MessageManager.cpp MessageManager.h + +TESTS += test_audio_readers +test_audio_readers_SOURCES = \ + $(RageSoundFileReaders) \ + $(all_test_SOURCES) \ + tests/test_audio_readers.cpp \ + RageSoundUtil.cpp RageSoundUtil.h RageSoundMixBuffer.cpp RageSoundMixBuffer.h \ + RageSoundReader.cpp RageSoundReader.h \ + RageSoundReader_FileReader.cpp RageSoundReader_FileReader.h \ + RageSoundReader_Pan.cpp RageSoundReader_Pan.h \ + RageSoundReader_Preload.cpp RageSoundReader_Preload.h \ + RageSoundReader_Resample_Good.cpp RageSoundReader_Resample_Good.h \ + RageSoundReader_Chain.cpp RageSoundReader_Chain.h + +test_audio_readers_LDADD = $(AUDIO_LIBS) + +TESTS += test_file_readers +test_file_readers_SOURCES = \ + $(all_test_SOURCES) \ + tests/test_file_readers.cpp + +TESTS += test_file_errors +test_file_errors_SOURCES = \ + $(all_test_SOURCES) \ + tests/test_file_errors.cpp \ + MsdFile.cpp MsdFile.h \ + CryptManager.cpp CryptManager.h + +test_file_errors_LDADD = \ + libtomcrypt.a libtommath.a + +TESTS += test_timing_data +test_timing_data_SOURCES = \ + $(all_test_SOURCES) \ + tests/test_timing_data.cpp \ + TimingData.cpp TimingData.h + +#TESTS += test_notedata +#test_notedata_SOURCES = \ +# $(all_test_SOURCES) \ +# tests/test_notedata.cpp \ +# NoteData.cpp NoteData.h NoteDataUtil.cpp NoteDataUtil.h \ +# NewNoteData.cpp NewNoteData.h \ +# NoteTypes.cpp NoteTypes.h \ +# TimingData.cpp TimingData.h +#NewNoteDataUtil.cpp NewNoteDataUtil.h + +TESTS += test_threads +test_threads_SOURCES = \ + $(all_test_SOURCES) \ + tests/test_threads.cpp + +INCLUDES = diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index f0c5901dec..a7750bdb48 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -85,7 +85,7 @@ void MusicWheel::Load( RString sType ) split( MODE_MENU_CHOICE_NAMES, ",", vsModeChoiceNames ); CHOICE .Load(sType,CHOICE_NAME,vsModeChoiceNames); SECTION_COLORS .Load(sType,SECTION_COLORS_NAME,NUM_SECTION_COLORS); - + WheelBase::Load( sType ); SONGMAN->UpdateRankingCourses(); @@ -93,7 +93,7 @@ void MusicWheel::Load( RString sType ) m_soundChangeSort.Load( THEME->GetPathS(sType,"sort") ); m_soundExpand.Load( THEME->GetPathS(sType,"expand"), true ); - /* Update for SORT_MOST_PLAYED. */ + // Update for SORT_MOST_PLAYED. SONGMAN->UpdatePopular(); /* Sort SONGMAN's songs by CompareSongPointersByTitle, so we can do other sorts (with @@ -106,8 +106,8 @@ void MusicWheel::BeginScreen() { RageTimer timer; RString times; - /* Build all of the wheel item data. Do this after selecting - * the extra stage, so it knows to always display it. */ + /* Build all of the wheel item data. Do this after selecting the extra stage, + * so it knows to always display it. */ FOREACH_ENUM( SortOrder, so ) { BuildWheelItemDatas( m_WheelItemDatas[so], so ); diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index 7dcf3eff54..209cc35f7f 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -49,9 +49,13 @@ MusicWheelItem::MusicWheelItem( RString sType ): FOREACH_ENUM( MusicWheelItemType, i ) { m_sprColorPart[i].Load( THEME->GetPathG(sType,MusicWheelItemTypeToString(i)+" ColorPart") ); + m_sprColorPart[i]->SetName( MusicWheelItemTypeToString(i)+"ColorPart" ); + ActorUtil::LoadAllCommands(m_sprColorPart[i],"MusicWheelItem"); this->AddChild( m_sprColorPart[i] ); m_sprNormalPart[i].Load( THEME->GetPathG(sType,MusicWheelItemTypeToString(i)+" NormalPart") ); + m_sprNormalPart[i]->SetName( MusicWheelItemTypeToString(i)+"NormalPart" ); + ActorUtil::LoadAllCommands(m_sprNormalPart[i],"MusicWheelItem"); this->AddChild( m_sprNormalPart[i] ); } @@ -62,6 +66,14 @@ MusicWheelItem::MusicWheelItem( RString sType ): m_TextBanner.PlayCommand( "On" ); this->AddChild( &m_TextBanner ); + FOREACH_ENUM( MusicWheelItemType, i ) + { + m_sprOverPart[i].Load( THEME->GetPathG(sType,MusicWheelItemTypeToString(i)+" OverPart") ); + m_sprOverPart[i]->SetName( MusicWheelItemTypeToString(i)+"OverPart" ); + ActorUtil::LoadAllCommands(m_sprOverPart[i],"MusicWheelItem"); + this->AddChild( m_sprOverPart[i] ); + } + FOREACH_ENUM( MusicWheelItemType, i ) { m_pText[i] = NULL; @@ -126,6 +138,12 @@ MusicWheelItem::MusicWheelItem( const MusicWheelItem &cpy ): this->AddChild( &m_TextBanner ); + FOREACH_ENUM( MusicWheelItemType, i ) + { + m_sprOverPart[i] = cpy.m_sprOverPart[i]; + this->AddChild( m_sprOverPart[i] ); + } + FOREACH_ENUM( MusicWheelItemType, i ) { if( cpy.m_pText[i] == NULL ) @@ -166,6 +184,7 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int { m_sprColorPart[i]->SetVisible( false ); m_sprNormalPart[i]->SetVisible( false ); + m_sprOverPart[i]->SetVisible( false ); } m_TextBanner.SetVisible( false ); FOREACH_ENUM( MusicWheelItemType, i ) @@ -242,6 +261,7 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int m_sprColorPart[type]->SetVisible( true ); m_sprColorPart[type]->SetDiffuse( pWID->m_color ); m_sprNormalPart[type]->SetVisible( true ); + m_sprOverPart[type]->SetVisible( true ); BitmapText *bt = m_pText[type]; if( bt ) { @@ -269,6 +289,7 @@ void MusicWheelItem::LoadFromWheelItemData( const WheelItemBaseData *pData, int msg.SetParam( "SongGroup", pWID->m_sText ); msg.SetParam( "DrawIndex", iDrawIndex ); msg.SetParam( "Type", MusicWheelItemTypeToString(type) ); + msg.SetParam( "Color", pWID->m_color ); this->HandleMessage( msg ); } diff --git a/src/MusicWheelItem.h b/src/MusicWheelItem.h index 246de3e0d6..28c07d301e 100644 --- a/src/MusicWheelItem.h +++ b/src/MusicWheelItem.h @@ -51,6 +51,7 @@ private: AutoActor m_sprColorPart[NUM_MusicWheelItemType]; AutoActor m_sprNormalPart[NUM_MusicWheelItemType]; + AutoActor m_sprOverPart[NUM_MusicWheelItemType]; TextBanner m_TextBanner; // used by Type_Song instead of m_pText BitmapText *m_pText[NUM_MusicWheelItemType]; diff --git a/src/NotesLoaderSM.cpp b/src/NotesLoaderSM.cpp index 7c1219fef9..73b168d931 100644 --- a/src/NotesLoaderSM.cpp +++ b/src/NotesLoaderSM.cpp @@ -237,11 +237,15 @@ void SMLoader::LoadTimingFromSMFile( const MsdFile &msd, TimingData &out ) fDeltaBeat,(fNextPositiveBPM/60.0f),abs(fNewBPM/60.0f),BeatToNoteRow(fNextPositiveBeat),BeatToNoteRow(fBeat)) ); */ + + out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); + continue; } else { // last BPM is a negative one? ugh. -aj (MAX_NOTE_ROW exists btw) + out.AddBPMSegment( BPMSegment(BeatToNoteRow(fBeat), fNewBPM) ); } } diff --git a/src/PrefsManager.cpp b/src/PrefsManager.cpp index f92260adcf..a47285277c 100644 --- a/src/PrefsManager.cpp +++ b/src/PrefsManager.cpp @@ -188,7 +188,7 @@ PrefsManager::PrefsManager() : m_bOnlyDedicatedMenuButtons ( "OnlyDedicatedMenuButtons", false ), m_bMenuTimer ( "MenuTimer", false ), - m_fLifeDifficultyScale ( "LifeDifficultyScale", 1.0f ), + m_fLifeDifficultyScale ( "LifeDifficultyScale", .0f ), m_iRegenComboAfterMiss ( "RegenComboAfterMiss", 5 ), diff --git a/src/ProductInfo.h b/src/ProductInfo.h index b352b0165c..d59dadb80e 100644 --- a/src/ProductInfo.h +++ b/src/ProductInfo.h @@ -21,7 +21,7 @@ * "v0.0": Final Releases */ #ifndef PRODUCT_VER_BARE -#define PRODUCT_VER_BARE v1.0 +#define PRODUCT_VER_BARE v1.1 #endif // A unique ID for a build of an application. This is used in crash reports and in the network code's version handling diff --git a/src/ProductInfo.inc b/src/ProductInfo.inc index db3ffe6639..fbd6a80dbf 100644 --- a/src/ProductInfo.inc +++ b/src/ProductInfo.inc @@ -5,7 +5,7 @@ ; see ProductInfo.h for use descriptions !define PRODUCT_ID "sm-ssc" -!define PRODUCT_VER "v1.0" +!define PRODUCT_VER "v1.1" !define PRODUCT_DISPLAY "${PRODUCT_ID} ${PRODUCT_VER}" !define PRODUCT_BITMAP "ssc" @@ -17,7 +17,8 @@ !define INSTALL_PROGRAM_LIBRARIES !define INSTALL_EXECUTABLES !define INSTALL_NON_PCK_FILES -;!define ASSOCIATE_SMZIP +!define ASSOCIATE_SMZIP +!define ASSOCIATE_SMURL ;!define SHOW_AUTORUN !define MAKE_OPEN_PROGRAM_FOLDER_SHORTCUT !define MAKE_OPEN_SETTINGS_FOLDER_SHORTCUT diff --git a/src/Profile.cpp b/src/Profile.cpp index fd686eaa91..35c52c7377 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -201,6 +201,12 @@ Character *Profile::GetCharacter() const return CHARMAN->GetDefaultCharacter(); } +void Profile::SetCharacter(const RString sCharacterID) +{ + if(CHARMAN->GetCharacterFromID(sCharacterID)) + m_sCharacterID = sCharacterID; +} + static RString FormatCalories( float fCals ) { return Commify((int)fCals) + " Cal"; @@ -1957,6 +1963,7 @@ public: } static int GetCharacter( T* p, lua_State *L ) { p->GetCharacter()->PushSelf(L); return 1; } + static int SetCharacter( T* p, lua_State *L ) { p->SetCharacter(SArg(1)); return 0; } static int GetWeightPounds( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iWeightPounds ); return 1; } static int SetWeightPounds( T* p, lua_State *L ) { p->m_iWeightPounds = IArg(1); return 0; } static int GetGoalType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_GoalType ); return 1; } @@ -2030,6 +2037,7 @@ public: ADD_METHOD( GetDisplayName ); ADD_METHOD( GetHighScoreList ); ADD_METHOD( GetCharacter ); + ADD_METHOD( SetCharacter ); ADD_METHOD( GetWeightPounds ); ADD_METHOD( SetWeightPounds ); ADD_METHOD( GetGoalType ); diff --git a/src/Profile.h b/src/Profile.h index aa998d3825..9809c68467 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -67,6 +67,7 @@ public: // smart accessors RString GetDisplayNameOrHighScoreName() const; Character *GetCharacter() const; + void SetCharacter(const RString sCharacterID); RString GetDisplayTotalCaloriesBurned() const; // remove me and use Lua instead RString GetDisplayTotalCaloriesBurnedToday() const; // remove me and use Lua instead int GetCalculatedWeightPounds() const; // returns a default value if m_iWeightPounds isn't set diff --git a/src/RollingNumbers.cpp b/src/RollingNumbers.cpp index bae90d9547..d005b35a72 100644 --- a/src/RollingNumbers.cpp +++ b/src/RollingNumbers.cpp @@ -82,7 +82,7 @@ void RollingNumbers::Update( float fDeltaTime ) void RollingNumbers::SetTargetNumber( float fTargetNumber ) { - if( fTargetNumber == m_fTargetNumber ) // no change + if( fTargetNumber == m_fTargetNumber ) // no change return; m_fTargetNumber = fTargetNumber; m_fScoreVelocity = (m_fTargetNumber-m_fCurrentNumber) / APPROACH_SECONDS.GetValue(); @@ -102,10 +102,12 @@ void RollingNumbers::UpdateText() class LunaRollingNumbers: public Luna { public: + static int Load( T* p, lua_State *L ) { p->Load(SArg(1)); return 0; } static int targetnumber( T* p, lua_State *L ) { p->SetTargetNumber( FArg(1) ); return 0; } LunaRollingNumbers() { + ADD_METHOD( Load ); ADD_METHOD( targetnumber ); } }; diff --git a/src/Screen.cpp b/src/Screen.cpp index 45f1841d69..7b997ece81 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -184,7 +184,10 @@ void Screen::Input( const InputEventPlus &input ) { Message msg(""); if( m_Codes.InputMessage(input, msg) ) + { this->HandleMessage( msg ); + return; + } // Don't send release messages with the default handler. switch( input.type ) diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 4c717f1888..d8717a790e 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -2174,8 +2174,7 @@ void ScreenGameplay::Input( const InputEventPlus &input ) if( m_PauseController == GameController_Invalid || m_PauseController == input.GameI.controller ) { // IMO, it's better to have this configurable. -DaisuMaster - if( UNPAUSE_WITH_START ) - this->PauseGame( false ); + if( UNPAUSE_WITH_START ) this->PauseGame( false ); } } return; diff --git a/src/ScreenInstallOverlay.cpp b/src/ScreenInstallOverlay.cpp new file mode 100644 index 0000000000..4841a10d2d --- /dev/null +++ b/src/ScreenInstallOverlay.cpp @@ -0,0 +1,400 @@ +#include "global.h" +#include "ScreenInstallOverlay.h" +#include "RageFileManager.h" +#include "ScreenManager.h" +#include "Preference.h" +#include "RageLog.h" +#include "FileDownload.h" +#include "jsoncpp/include/json/value.h" +#include "JsonUtil.h" +#include "SpecialFiles.h" +class Song; +#include "SongManager.h" +#include "GameState.h" +#include "GameManager.h" +#include "CommonMetrics.h" +#include "SongManager.h" +#include "CommandLineActions.h" +#include "ScreenDimensions.h" +#include "StepMania.h" +#include "ActorUtil.h" + +struct PlayAfterLaunchInfo +{ + RString sSongDir; + RString sTheme; + bool bAnySongChanged; + bool bAnyThemeChanged; + + PlayAfterLaunchInfo() + { + bAnySongChanged = false; + bAnyThemeChanged = false; + } + + void OverlayWith( const PlayAfterLaunchInfo &other ) + { + if( !other.sSongDir.empty() ) sSongDir = other.sSongDir; + if( !other.sTheme.empty() ) sTheme = other.sTheme; + bAnySongChanged |= other.bAnySongChanged; + bAnyThemeChanged |= other.bAnyThemeChanged; + } +}; + +static void Parse( const RString &sDir, PlayAfterLaunchInfo &out ) +{ + vector vsDirParts; + split( sDir, "/", vsDirParts, true ); + if( vsDirParts.size() == 3 && vsDirParts[0].EqualsNoCase("Songs") ) + out.sSongDir = "/" + sDir; + else if( vsDirParts.size() == 2 && vsDirParts[0].EqualsNoCase("Themes") ) + out.sTheme = vsDirParts[1]; +} + +static const RString TEMP_ZIP_MOUNT_POINT = "/@temp-zip/"; +const RString TEMP_OS_MOUNT_POINT = "/@temp-os/"; + +static void InstallSmzip( const RString &sZipFile, PlayAfterLaunchInfo &out ) +{ + if( !FILEMAN->Mount( "zip", sZipFile, TEMP_ZIP_MOUNT_POINT ) ) + FAIL_M("Failed to mount " + sZipFile ); + + vector vsFiles; + { + vector vsRawFiles; + GetDirListingRecursive( TEMP_ZIP_MOUNT_POINT, "*", vsRawFiles); + + vector vsPrettyFiles; + FOREACH_CONST( RString, vsRawFiles, s ) + { + if( GetExtension(*s).EqualsNoCase("ctl") ) + continue; + + vsFiles.push_back( *s); + + RString s2 = s->Right( s->length() - TEMP_ZIP_MOUNT_POINT.length() ); + vsPrettyFiles.push_back( s2 ); + } + sort( vsPrettyFiles.begin(), vsPrettyFiles.end() ); + } + + RString sResult = "Success installing " + sZipFile; + FOREACH_CONST( RString, vsFiles, sSrcFile ) + { + RString sDestFile = *sSrcFile; + sDestFile = sDestFile.Right( sDestFile.length() - TEMP_ZIP_MOUNT_POINT.length() ); + + RString sDir, sThrowAway; + splitpath( sDestFile, sDir, sThrowAway, sThrowAway ); + + Parse( sDir, out ); + out.bAnySongChanged = true; + + FILEMAN->CreateDir( sDir ); + + if( !FileCopy( *sSrcFile, sDestFile ) ) + { + sResult = "Error extracting " + sDestFile; + break; + } + } + FILEMAN->Unmount( "zip", sZipFile, TEMP_ZIP_MOUNT_POINT ); + + SCREENMAN->SystemMessage( sResult ); +} + +void InstallSmzipOsArg( const RString &sOsZipFile, PlayAfterLaunchInfo &out ) +{ + SCREENMAN->SystemMessage("Installing " + sOsZipFile ); + + RString sOsDir, sFilename, sExt; + splitpath( sOsZipFile, sOsDir, sFilename, sExt ); + + if( !FILEMAN->Mount( "dir", sOsDir, TEMP_OS_MOUNT_POINT ) ) + FAIL_M("Failed to mount " + sOsDir ); + InstallSmzip( TEMP_OS_MOUNT_POINT + sFilename + sExt, out ); + + FILEMAN->Unmount( "dir", sOsDir, TEMP_OS_MOUNT_POINT ); +} + +struct FileCopyResult +{ + FileCopyResult( RString _sFile, RString _sComment ) : sFile(_sFile), sComment(_sComment) {} + RString sFile, sComment; +}; + +Preference g_sCookie( "Cookie", "" ); + +class DownloadTask +{ + FileTransfer *m_pTransfer; + vector m_vsQueuedPackageUrls; + RString m_sCurrentPackageTempFile; + enum + { + control, + packages + } m_DownloadState; + PlayAfterLaunchInfo m_playAfterLaunchInfo; +public: + DownloadTask(const RString &sControlFileUri) + { + //SCREENMAN->SystemMessage( "Downloading control file." ); + m_pTransfer = new FileTransfer(); + m_pTransfer->StartDownload( sControlFileUri, "" ); + m_DownloadState = control; + } + ~DownloadTask() + { + SAFE_DELETE(m_pTransfer); + } + RString GetStatus() + { + if( m_pTransfer == NULL ) + return ""; + else + return m_pTransfer->GetStatus(); + } + bool UpdateAndIsFinished( float fDeltaSeconds, PlayAfterLaunchInfo &playAfterLaunchInfo ) + { + m_pTransfer->Update( fDeltaSeconds ); + switch( m_DownloadState ) + { + case control: + if( m_pTransfer->IsFinished() ) + { + SCREENMAN->SystemMessage( "Downloading required .smzip" ); + + RString sResponse = m_pTransfer->GetResponse(); + SAFE_DELETE( m_pTransfer ); + + Json::Value root; + RString sError; + if( !JsonUtil::LoadFromString(root, sResponse, sError) ) + { + SCREENMAN->SystemMessage( sError ); + return true; + } + + // Parse the JSON response, make a list of all packages need to be downloaded. + { + if( root["Cookie"].isString() ) + g_sCookie.Set( root["Cookie"].asString() ); + Json::Value require = root["Require"]; + if( require.isArray() ) + { + for( unsigned i=0; iStartDownload( sUrl, m_sCurrentPackageTempFile ); + } + } + break; + case packages: + { + if( m_pTransfer->IsFinished() ) + { + SAFE_DELETE( m_pTransfer ); + InstallSmzip( m_sCurrentPackageTempFile, m_playAfterLaunchInfo ); + FILEMAN->Remove( m_sCurrentPackageTempFile ); // Harmless if this fails because download didn't finish + } + if( !m_vsQueuedPackageUrls.empty() ) + { + RString sUrl = m_vsQueuedPackageUrls.back(); + m_vsQueuedPackageUrls.pop_back(); + m_sCurrentPackageTempFile = MakeTempFileName(sUrl); + ASSERT(m_pTransfer == NULL); + m_pTransfer = new FileTransfer(); + m_pTransfer->StartDownload( sUrl, m_sCurrentPackageTempFile ); + } + } + break; + } + bool bFinsihed = m_DownloadState == packages && + m_vsQueuedPackageUrls.empty() && + m_pTransfer == NULL; + if( bFinsihed ) + { + playAfterLaunchInfo = m_playAfterLaunchInfo; + return true; + } + else + { + return false; + } + } + static RString MakeTempFileName( RString s ) + { + return SpecialFiles::CACHE_DIR + "Downloads/" + Basename(s); + } +}; +static vector g_pDownloadTasks; + +static bool IsStepManiaProtocol(const RString &arg) +{ + // for now, only load from the StepMania domain until the security implications of this feature are better understood. + //return BeginsWith(arg,"stepmania://beta.stepmania.com/"); + return BeginsWith(arg,"stepmania://"); +} + +static bool IsPackageFile(const RString &arg) +{ + RString ext = GetExtension(arg); + return ext.EqualsNoCase("smzip") || ext.EqualsNoCase("zip"); +} + +PlayAfterLaunchInfo DoInstalls( CommandLineActions::CommandLineArgs args ) +{ + PlayAfterLaunchInfo ret; + for( int i = 0; i<(int)args.argv.size(); i++ ) + { + RString s = args.argv[i]; + if( IsStepManiaProtocol(s) ) + g_pDownloadTasks.push_back( new DownloadTask(s) ); + else if( IsPackageFile(s) ) + InstallSmzipOsArg(s, ret); + } + return ret; +} + +REGISTER_SCREEN_CLASS( ScreenInstallOverlay ); + +ScreenInstallOverlay::~ScreenInstallOverlay() +{ +} +void ScreenInstallOverlay::Init() +{ + Screen::Init(); + + m_textStatus.LoadFromFont( THEME->GetPathF("ScreenInstallOverlay", "status") ); + m_textStatus.SetName("Status"); + ActorUtil::LoadAllCommandsAndSetXY(m_textStatus,"ScreenInstallOverlay"); + this->AddChild( &m_textStatus ); +} + +void ScreenInstallOverlay::Update( float fDeltaTime ) +{ + Screen::Update(fDeltaTime); + PlayAfterLaunchInfo playAfterLaunchInfo; + while( CommandLineActions::ToProcess.size() > 0 ) + { + CommandLineActions::CommandLineArgs args = CommandLineActions::ToProcess.back(); + CommandLineActions::ToProcess.pop_back(); + PlayAfterLaunchInfo pali2 = DoInstalls( args ); + playAfterLaunchInfo.OverlayWith( pali2 ); + } + + for(int i=g_pDownloadTasks.size()-1; i>=0; --i) + { + DownloadTask *p = g_pDownloadTasks[i]; + PlayAfterLaunchInfo pali; + if( p->UpdateAndIsFinished( fDeltaTime, pali) ) + { + playAfterLaunchInfo.OverlayWith(pali); + SAFE_DELETE(p); + g_pDownloadTasks.erase( g_pDownloadTasks.begin()+i ); + } + } + + { + vector vsMessages; + FOREACH_CONST( DownloadTask*, g_pDownloadTasks, pDT ) + { + vsMessages.push_back( (*pDT)->GetStatus() ); + } + m_textStatus.SetText( join("\n", vsMessages) ); + } + + if( playAfterLaunchInfo.bAnySongChanged ) + SONGMAN->Reload( false, NULL ); + + if( !playAfterLaunchInfo.sSongDir.empty() ) + { + Song* pSong = NULL; + GAMESTATE->Reset(); + RString sInitialScreen; + if( playAfterLaunchInfo.sSongDir.length() > 0 ) + pSong = SONGMAN->GetSongFromDir( playAfterLaunchInfo.sSongDir ); + if( pSong ) + { + vector vpStyle; + GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vpStyle, false ); + GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); + GAMESTATE->m_bSideIsJoined[0] = true; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + GAMESTATE->m_pCurStyle.Set( vpStyle[0] ); + GAMESTATE->m_pCurSong.Set( pSong ); + GAMESTATE->m_pPreferredSong = pSong; + sInitialScreen = StepMania::GetSelectMusicScreen(); + } + else + { + sInitialScreen = StepMania::GetInitialScreen(); + } + + SCREENMAN->SetNewScreen( sInitialScreen ); + } +} + +/* + * (c) 2001-2005 Chris Danford, 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. + */ diff --git a/src/ScreenInstallOverlay.h b/src/ScreenInstallOverlay.h new file mode 100644 index 0000000000..313ddd30b6 --- /dev/null +++ b/src/ScreenInstallOverlay.h @@ -0,0 +1,48 @@ +/* ScreenInstallOverlay - package installation processing and messaging. */ + +#ifndef ScreenInstallOverlay_H +#define ScreenInstallOverlay_H + +#include "Screen.h" +#include "BitmapText.h" + +class ScreenInstallOverlay : public Screen +{ +public: + virtual ~ScreenInstallOverlay(); + virtual void Init(); + + void Update( float fDeltaTime ); + +private: + void UpdateText(); + + BitmapText m_textStatus; +}; + +#endif + +/* + * (c) 2001-2005 Chris Danford, 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. + */ diff --git a/src/Sprite.cpp b/src/Sprite.cpp index 02c2155823..25a7033a1d 100644 --- a/src/Sprite.cpp +++ b/src/Sprite.cpp @@ -1152,6 +1152,7 @@ public: return 0; } static int GetNumStates( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumStates() ); return 1; } + static int SetAllStateDelays( T* p, lua_State *L ) { p->SetAllStateDelays(FArg(1)); return 0; } LunaSprite() { @@ -1172,6 +1173,7 @@ public: ADD_METHOD( GetTexture ); ADD_METHOD( SetEffectMode ); ADD_METHOD( GetNumStates ); + ADD_METHOD( SetAllStateDelays ); } }; diff --git a/src/StepMania-net2008.vcproj b/src/StepMania-net2008.vcproj index 72901af6a1..e510383dfb 100644 --- a/src/StepMania-net2008.vcproj +++ b/src/StepMania-net2008.vcproj @@ -50,7 +50,7 @@ + + + + @@ -1200,6 +1208,14 @@ RelativePath="EnumHelper.h" > + + + + @@ -1304,6 +1320,14 @@ RelativePath="Inventory.h" > + + + + @@ -1843,10 +1867,18 @@ + + + + @@ -2278,6 +2310,10 @@ RelativePath="arch\Dialog\DialogDriver_Win32.h" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + m_sTestInitialScreen; return INITIAL_SCREEN.GetValue(); } +ThemeMetric SELECT_MUSIC_SCREEN ("Common","SelectMusicScreen"); +RString StepMania::GetSelectMusicScreen() +{ + return SELECT_MUSIC_SCREEN.GetValue(); +} #if defined(WIN32) static Preference g_iLastSeenMemory( "LastSeenMemory", 0 ); @@ -959,25 +964,6 @@ int main(int argc, char* argv[]) SetCommandlineArguments( argc, argv ); - - enum RunMode - { - RunMode_Normal, - RunMode_Install, - RunMode_ExportNsisStrings, - RunMode_ExportLuaInformation, - RunMode_DisplayVersion, - }; - RunMode runmode = RunMode_Normal; - if( CommandLineActions::AnyPackageFilesInCommandLine() ) - runmode = RunMode_Install; - else if( GetCommandlineArgument("ExportNsisStrings") ) - runmode = RunMode_ExportNsisStrings; - else if( GetCommandlineArgument("ExportLuaInformation") ) - runmode = RunMode_ExportLuaInformation; - else if( GetCommandlineArgument("version") ) - runmode = RunMode_DisplayVersion; - // Set up arch hooks first. This may set up crash handling. HOOKS = ArchHooks::Create(); HOOKS->Init(); @@ -991,7 +977,6 @@ int main(int argc, char* argv[]) if( !bPortable ) FILEMAN->MountUserFilesystems(); - // Set this up next. Do this early, since it's needed for RageException::Throw. LOG = new RageLog; @@ -1004,7 +989,7 @@ int main(int argc, char* argv[]) * so ArchHooks can use a preference to turn this off. We want to do this before ApplyLogPreferences, * so if we exit because of another instance, we don't try to clobber its log. We also want to * do this before opening the loading window, so if we give focus away, we don't flash the window. */ - if( !g_bAllowMultipleInstances.Get() && HOOKS->CheckForMultipleInstances() ) + if(!g_bAllowMultipleInstances.Get() && HOOKS->CheckForMultipleInstances(argc, argv)) { ShutdownGame(); return 0; @@ -1057,17 +1042,9 @@ int main(int argc, char* argv[]) GAMESTATE = new GameState; // This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow. - LoadingWindow *pLoadingWindow = NULL; - switch( runmode ) - { - case RunMode_Normal: - pLoadingWindow = LoadingWindow::Create(); - if( pLoadingWindow == NULL ) - RageException::Throw( "%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str() ); - break; - default: - ; // no loading window for other RunModes - } + LoadingWindow *pLoadingWindow = LoadingWindow::Create(); + if(pLoadingWindow == NULL) + RageException::Throw("%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str()); srand( time(NULL) ); // seed number generator @@ -1091,36 +1068,7 @@ int main(int argc, char* argv[]) // Switch to the last used game type, and set up the theme and announcer. SwitchToLastPlayedGame(); - // Handle special RunModes. Some of these depend on ThemeManager being loaded above in SwitchToLastPlayedGame. - switch( runmode ) - { - DEFAULT_FAIL( runmode ); - case RunMode_Normal: - break; - case RunMode_Install: - case RunMode_ExportNsisStrings: - case RunMode_ExportLuaInformation: - case RunMode_DisplayVersion: - THEME->SwitchThemeAndLanguage( "default", PREFSMAN->m_sLanguage, PREFSMAN->m_bPseudoLocalize ); - switch( runmode ) - { - DEFAULT_FAIL( runmode ); - case RunMode_Install: - CommandLineActions::Install(); - break; - case RunMode_ExportNsisStrings: - CommandLineActions::Nsis(); - break; - case RunMode_ExportLuaInformation: - CommandLineActions::LuaInformation(); - break; - case RunMode_DisplayVersion: - CommandLineActions::Version(); - break; - }; - exit(0); - } - + CommandLineActions::Handle(pLoadingWindow); { /* Now that THEME is loaded, load the icon for the current theme into diff --git a/src/StepMania.h b/src/StepMania.h index 5605089085..04aa4754bc 100644 --- a/src/StepMania.h +++ b/src/StepMania.h @@ -13,6 +13,7 @@ namespace StepMania void ResetPreferences(); void ResetGame(); RString GetInitialScreen(); + RString GetSelectMusicScreen(); void ChangeCurrentGame( const Game* g ); // If successful, return filename of screenshot in sDir, else return "" diff --git a/src/arch/ArchHooks/ArchHooks.h b/src/arch/ArchHooks/ArchHooks.h index 847149d7e6..b7e534c668 100644 --- a/src/arch/ArchHooks/ArchHooks.h +++ b/src/arch/ArchHooks/ArchHooks.h @@ -32,11 +32,9 @@ public: */ virtual RString GetMachineId() const { return RString(); } - /* - * If this is a second instance, return true. Optionally, give focus to the existing - * window. - */ - virtual bool CheckForMultipleInstances() { return false; } + /* If this is a second instance, return true. + * Optionally, give focus to the existing window. */ + virtual bool CheckForMultipleInstances(int argc, char* argv[]) { return false; } virtual void SetTime( tm newtime ) { } diff --git a/src/arch/ArchHooks/ArchHooks_Win32.cpp b/src/arch/ArchHooks/ArchHooks_Win32.cpp index 41d4a316fe..a036ef764d 100644 --- a/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -92,7 +92,7 @@ RString ArchHooks_Win32::GetMachineId() const return RString(); } -bool ArchHooks_Win32::CheckForMultipleInstances() +bool ArchHooks_Win32::CheckForMultipleInstances(int argc, char* argv[]) { if( !g_bIsMultipleInstance ) return false; @@ -117,6 +117,21 @@ bool ArchHooks_Win32::CheckForMultipleInstances() SetForegroundWindow( data.hResult ); else SetForegroundWindow( hWnd ); + + // Send the command line to the existing window. + vector vsArgs; + for( int i=0; i g_sIgnoredDialogs( "IgnoredDialogs", "" ); #endif +#include "Selector_Dialog.h" +DialogDriver *MakeDialogDriver() +{ + RString sDrivers = "win32,cocoa,null"; + vector asDriversToTry; + split( sDrivers, ",", asDriversToTry, true ); + + ASSERT( asDriversToTry.size() != 0 ); + + RString sDriver; + DialogDriver *pRet = NULL; + + for( unsigned i = 0; pRet == NULL && i < asDriversToTry.size(); ++i ) + { + sDriver = asDriversToTry[i]; + +#ifdef USE_DIALOG_DRIVER_COCOA + if( !asDriversToTry[i].CompareNoCase("Cocoa") ) pRet = new DialogDriver_Cocoa; +#endif +#ifdef USE_DIALOG_DRIVER_WIN32 + if( !asDriversToTry[i].CompareNoCase("Win32") ) pRet = new DialogDriver_Win32; +#endif +#ifdef USE_DIALOG_DRIVER_NULL + if( !asDriversToTry[i].CompareNoCase("Null") ) pRet = new DialogDriver_Null; +#endif + + if( pRet == NULL ) + { + continue; + } + + RString sError = pRet->Init(); + if( sError != "" ) + { + if( LOG ) + LOG->Info( "Couldn't load driver %s: %s", asDriversToTry[i].c_str(), sError.c_str() ); + SAFE_DELETE( pRet ); + } + } + + return pRet; +} + static DialogDriver *g_pImpl = NULL; static DialogDriver_Null g_NullDriver; -static bool g_bWindowed = true; // Start out true so that we'll show errors before DISPLAY is init'd. +static bool g_bWindowed = true; // Start out true so that we'll show errors before DISPLAY is init'd. static bool DialogsEnabled() { @@ -28,7 +72,7 @@ void Dialog::Init() g_pImpl = DialogDriver::Create(); - /* DialogDriver_Null should have worked, at least. */ + // DialogDriver_Null should have worked, at least. ASSERT( g_pImpl != NULL ); } @@ -52,7 +96,7 @@ static bool MessageIsIgnored( RString sID ) void Dialog::IgnoreMessage( RString sID ) { - /* We can't ignore messages before PREFSMAN is around. */ + // We can't ignore messages before PREFSMAN is around. #if !defined(SMPACKAGE) if( PREFSMAN == NULL ) { @@ -118,6 +162,30 @@ void Dialog::OK( RString sMessage, RString sID ) RageThread::SetIsShowingDialog( false ); } +Dialog::Result Dialog::OKCancel( RString sMessage, RString sID ) +{ + Dialog::Init(); + + if( LOG ) + LOG->Trace( "Dialog: \"%s\" [%s]", sMessage.c_str(), sID.c_str() ); + + if( sID != "" && MessageIsIgnored(sID) ) + return g_NullDriver.OKCancel( sMessage, sID ); + + RageThread::SetIsShowingDialog( true ); + + // only show Dialog if windowed + Dialog::Result ret; + if( DialogsEnabled() ) + ret = g_pImpl->OKCancel( sMessage, sID ); // call derived version + else + ret = g_NullDriver.OKCancel( sMessage, sID ); + + RageThread::SetIsShowingDialog( false ); + + return ret; +} + Dialog::Result Dialog::AbortRetryIgnore( RString sMessage, RString sID ) { Dialog::Init(); diff --git a/src/arch/Dialog/Dialog.h b/src/arch/Dialog/Dialog.h index 92fbd4ca22..a51a8776f4 100644 --- a/src/arch/Dialog/Dialog.h +++ b/src/arch/Dialog/Dialog.h @@ -10,9 +10,10 @@ namespace Dialog void SetWindowed( bool bWindowed ); - enum Result { abort, retry, ignore }; + enum Result { ok, cancel, abort, retry, ignore }; void Error( RString sError, RString sID = "" ); void OK( RString sMessage, RString sID = "" ); + Result OKCancel( RString sMessage, RString sID = "" ); Result AbortRetryIgnore( RString sMessage, RString sID = "" ); Result AbortRetry( RString sMessage, RString sID = "" ); diff --git a/src/arch/Dialog/DialogDriver.cpp b/src/arch/Dialog/DialogDriver.cpp index 83cbd7963c..8f0aaeb398 100644 --- a/src/arch/Dialog/DialogDriver.cpp +++ b/src/arch/Dialog/DialogDriver.cpp @@ -8,7 +8,7 @@ RegisterDialogDriver::RegisterDialogDriver( const istring &sName, CreateDialogDr { if( g_pRegistrees == NULL ) g_pRegistrees = new map; - + ASSERT( g_pRegistrees->find(sName) == g_pRegistrees->end() ); (*g_pRegistrees)[sName] = pfn; } @@ -20,20 +20,20 @@ DialogDriver *DialogDriver::Create() RString sDrivers = "win32,macosx,null"; vector asDriversToTry; split( sDrivers, ",", asDriversToTry, true ); - + ASSERT( asDriversToTry.size() != 0 ); - + FOREACH_CONST( RString, asDriversToTry, Driver ) { map::const_iterator iter = RegisterDialogDriver::g_pRegistrees->find( istring(*Driver) ); - + if( iter == RegisterDialogDriver::g_pRegistrees->end() ) continue; - + DialogDriver *pRet = (iter->second)(); DEBUG_ASSERT( pRet ); const RString sError = pRet->Init(); - + if( sError.empty() ) return pRet; if( LOG ) diff --git a/src/arch/Dialog/DialogDriver.h b/src/arch/Dialog/DialogDriver.h index 727657e4ac..44f107887a 100644 --- a/src/arch/Dialog/DialogDriver.h +++ b/src/arch/Dialog/DialogDriver.h @@ -11,6 +11,7 @@ public: virtual void Error( RString sMessage, RString sID ) { printf("Error: %s\n", sMessage.c_str()); } virtual void OK( RString sMessage, RString sID ) {} + virtual Dialog::Result OKCancel( RString sMessage, RString sID ) { return Dialog::ok; } virtual Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ) { return Dialog::ignore; } virtual Dialog::Result AbortRetry( RString sMessage, RString sID ) { return Dialog::abort; } @@ -18,6 +19,7 @@ public: virtual ~DialogDriver() { } }; class DialogDriver_Null : public DialogDriver { }; +#define USE_DIALOG_DRIVER_NULL typedef DialogDriver *(*CreateDialogDriverFn)(); struct RegisterDialogDriver @@ -28,7 +30,6 @@ struct RegisterDialogDriver #define REGISTER_DIALOG_DRIVER_CLASS( name ) \ static RegisterDialogDriver register_##name( #name, CreateClass ) - #endif /* diff --git a/src/arch/Dialog/DialogDriver_MacOSX.h b/src/arch/Dialog/DialogDriver_MacOSX.h index 0c61b0d820..ca045802fd 100644 --- a/src/arch/Dialog/DialogDriver_MacOSX.h +++ b/src/arch/Dialog/DialogDriver_MacOSX.h @@ -11,6 +11,7 @@ public: Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ); Dialog::Result AbortRetry( RString sMessage, RString sID ); }; +#define USE_DIALOG_DRIVER_COCOA #endif diff --git a/src/arch/Dialog/DialogDriver_Win32.cpp b/src/arch/Dialog/DialogDriver_Win32.cpp index ee419f129c..62333fd2a3 100644 --- a/src/arch/Dialog/DialogDriver_Win32.cpp +++ b/src/arch/Dialog/DialogDriver_Win32.cpp @@ -57,7 +57,7 @@ static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara SetWindowText( GetDlgItem(hWnd, IDC_MESSAGE), sMessage ); // Focus is on any of the controls in the dialog by default. - // I'm not sure why. Set focus to the button manually. -Chris + // I'm not sure why. Set focus to the button manually. -Chris SetFocus( GetDlgItem(hWnd, IDOK) ); } break; @@ -72,7 +72,7 @@ static BOOL CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara { case IDOK: g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH ); - /* fall through */ + // fall through case IDCANCEL: EndDialog( hWnd, 0 ); break; @@ -112,6 +112,30 @@ void DialogDriver_Win32::OK( RString sMessage, RString sID ) Dialog::IgnoreMessage( sID ); } +Dialog::Result DialogDriver_Win32::OKCancel( RString sMessage, RString sID ) +{ + g_bAllowHush = sID != ""; + g_sMessage = sMessage; + AppInstance handle; + +#if !defined(SMPACKAGE) + //DialogBox( handle.Get(), MAKEINTRESOURCE(IDD_OK), ::GetHwnd(), OKWndProc ); + int result = ::MessageBox( NULL, sMessage, GetWindowTitle(), MB_OKCANCEL ); +#else + int result = ::AfxMessageBox( ConvertUTF8ToACP(sMessage).c_str(), MB_OKCANCEL, 0 ); +#endif + if( g_bAllowHush && g_bHush ) + Dialog::IgnoreMessage( sID ); + + switch( result ) + { + case IDOK: + return Dialog::ok; + default: + return Dialog::cancel; + } +} + #if !defined(SMPACKAGE) static RString g_sErrorString; @@ -159,7 +183,7 @@ static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP break; case IDC_BUTTON_RESTART: Win32RestartProgram(); - /* not reached */ + // not reached ASSERT( 0 ); EndDialog( hWnd, 0 ); break; diff --git a/src/arch/Dialog/DialogDriver_Win32.h b/src/arch/Dialog/DialogDriver_Win32.h index 28dc05504a..15654e646d 100644 --- a/src/arch/Dialog/DialogDriver_Win32.h +++ b/src/arch/Dialog/DialogDriver_Win32.h @@ -8,6 +8,7 @@ class DialogDriver_Win32: public DialogDriver public: void Error( RString sMessage, RString sID ); void OK( RString sMessage, RString sID ); + Dialog::Result OKCancel( RString sMessage, RString sID ); Dialog::Result AbortRetryIgnore( RString sMessage, RString sID ); Dialog::Result AbortRetry( RString sMessage, RString sID ); }; diff --git a/src/arch/Dialog/Selector_Dialog.h b/src/arch/Dialog/Selector_Dialog.h new file mode 100644 index 0000000000..baf647a9b5 --- /dev/null +++ b/src/arch/Dialog/Selector_Dialog.h @@ -0,0 +1,41 @@ +#ifndef SELECTOR_DIALOG +#define SELECTOR_DIALOG + +#include "arch/arch_platform.h" + +// Dialog drivers selector. +#if defined(WIN32) +#include "DialogDriver_Win32.h" + +#elif defined(MACOSX) +#include "DialogDriver_Cocoa.h" +#endif + +#include "DialogDriver.h" // DialogDriver_Null is in here + +#endif + +/* + * (c) 2005 Ben Anderson. + * 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. + */ diff --git a/src/arch/LoadingWindow/LoadingWindow.cpp b/src/arch/LoadingWindow/LoadingWindow.cpp index 61de2cd1e3..5883d64942 100644 --- a/src/arch/LoadingWindow/LoadingWindow.cpp +++ b/src/arch/LoadingWindow/LoadingWindow.cpp @@ -11,7 +11,7 @@ LoadingWindow *LoadingWindow::Create() #if defined(UNIX) && !defined(HAVE_GTK) return new LoadingWindow_Null; #endif - /* Don't load NULL by default. */ + // Don't load NULL by default. const RString drivers = "xbox,win32,macosx,gtk"; vector DriversToTry; split( drivers, ",", DriversToTry, true ); @@ -39,7 +39,6 @@ LoadingWindow *LoadingWindow::Create() #endif if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null; - if( ret == NULL ) continue; @@ -50,10 +49,10 @@ LoadingWindow *LoadingWindow::Create() SAFE_DELETE( ret ); } } - + if( ret ) LOG->Info( "Loading window: %s", Driver.c_str() ); - + return ret; } diff --git a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm index a62a67be8e..c34d8d4d85 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm +++ b/src/arch/LowLevelWindow/LowLevelWindow_MacOSX.mm @@ -7,7 +7,7 @@ #import "arch/ArchHooks/ArchHooks.h" #import -#import +#import #import #import diff --git a/src/arch/Sound/DSoundHelpers.cpp b/src/arch/Sound/DSoundHelpers.cpp index 37e40aa378..9f2859b0cf 100644 --- a/src/arch/Sound/DSoundHelpers.cpp +++ b/src/arch/Sound/DSoundHelpers.cpp @@ -22,7 +22,6 @@ BOOL CALLBACK DSound::EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPC { sLine += ssprintf( " %s", lpcstrModule ); -#ifndef _XBOX RString sPath = FindSystemFile( lpcstrModule ); if( sPath != "" ) { @@ -30,7 +29,6 @@ BOOL CALLBACK DSound::EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPC if( GetFileVersion(sPath, sVersion) ) sLine += ssprintf( " %s", sVersion.c_str() ); } -#endif } LOG->Info( "%s", sLine.c_str() ); @@ -40,7 +38,6 @@ BOOL CALLBACK DSound::EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPC void DSound::SetPrimaryBufferMode() { -#ifndef _XBOX DSBUFFERDESC format; memset( &format, 0, sizeof(format) ); format.dwSize = sizeof(format); @@ -96,7 +93,6 @@ void DSound::SetPrimaryBufferMode() // pBuffer->Play( 0, 0, DSBPLAY_LOOPING ); pBuffer->Release(); -#endif } DSound::DSound() @@ -113,7 +109,6 @@ RString DSound::Init() if( FAILED( hr = DirectSoundCreate(NULL, &m_pDS, NULL) ) ) return hr_ssprintf( hr, "DirectSoundCreate" ); -#ifndef _XBOX static bool bShownInfo = false; if( !bShownInfo ) { @@ -136,7 +131,6 @@ RString DSound::Init() /* Try to set primary mixing privileges */ hr = m_pDS->SetCooperativeLevel( GetDesktopWindow(), DSSCL_PRIORITY ); -#endif SetPrimaryBufferMode(); @@ -152,7 +146,6 @@ DSound::~DSound() bool DSound::IsEmulated() const { -#ifndef _XBOX /* Don't bother wasting time trying to create buffers if we're * emulated. This also gives us better diagnostic information. */ DSCAPS Caps; @@ -166,9 +159,6 @@ bool DSound::IsEmulated() const } return !!(Caps.dwFlags & DSCAPS_EMULDRIVER); -#else - return false; -#endif } DSoundBuf::DSoundBuf() @@ -220,45 +210,21 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware, DSBUFFERDESC format; memset( &format, 0, sizeof(format) ); format.dwSize = sizeof(format); -#ifdef _XBOX - format.dwFlags = 0; -#else format.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME; -#endif - -#ifndef _XBOX + /* Don't use DSBCAPS_STATIC. It's meant for static buffers, and we * only use streaming buffers. */ if( hardware == HW_HARDWARE ) format.dwFlags |= DSBCAPS_LOCHARDWARE; else format.dwFlags |= DSBCAPS_LOCSOFTWARE; -#endif if( bNeedCtrlFrequency ) format.dwFlags |= DSBCAPS_CTRLFREQUENCY; format.dwBufferBytes = m_iBufferSize; -#ifndef _XBOX - format.dwReserved = 0; -#else - DSMIXBINVOLUMEPAIR dsmbvp[8] = - { - { DSMIXBIN_FRONT_LEFT, DSBVOLUME_MAX }, // left channel - { DSMIXBIN_FRONT_RIGHT, DSBVOLUME_MAX }, // right channel - { DSMIXBIN_FRONT_CENTER, DSBVOLUME_MAX }, // left channel - { DSMIXBIN_FRONT_CENTER, DSBVOLUME_MAX }, // right channel - { DSMIXBIN_BACK_LEFT, DSBVOLUME_MAX }, // left channel - { DSMIXBIN_BACK_RIGHT, DSBVOLUME_MAX }, // right channel - { DSMIXBIN_LOW_FREQUENCY, DSBVOLUME_MAX }, // left channel - { DSMIXBIN_LOW_FREQUENCY, DSBVOLUME_MAX } // right channel - }; - DSMIXBINS dsmb; - dsmb.dwMixBinCount = 8; - dsmb.lpMixBinVolumePairs = dsmbvp; - format.lpMixBins = &dsmb; -#endif + format.dwReserved = 0; format.lpwfxFormat = &waveformat; @@ -266,7 +232,6 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware, if( FAILED(hr) ) return hr_ssprintf( hr, "CreateSoundBuffer failed (%i hz)", m_iSampleBits ); -#ifndef _XBOX /* I'm not sure this should ever be needed, but ... */ DSBCAPS bcaps; bcaps.dwSize=sizeof(bcaps); @@ -291,8 +256,7 @@ RString DSoundBuf::Init( DSound &ds, DSoundBuf::hw hardware, LOG->Warn( hr_ssprintf(hr, "GetFormat on secondary buffer") ); else if( (int) waveformat.nSamplesPerSec != m_iSampleRate ) LOG->Warn( "Secondary buffer set to %i instead of %i", waveformat.nSamplesPerSec, m_iSampleRate ); -#endif - + m_pTempBuffer = new char[m_iBufferSize]; return RString(); @@ -456,7 +420,6 @@ bool DSoundBuf::get_output_buf( char **pBuffer, unsigned *pBufferSize, int iChun /* It's easiest to think of the cursor as a block, starting and ending at * the two values returned by GetCurrentPosition, that we can't write to. */ result = m_pBuffer->GetCurrentPosition( &iCursorStart, &iCursorEnd ); -#ifndef _XBOX if( result == DSERR_BUFFERLOST ) { m_pBuffer->Restore(); @@ -467,7 +430,6 @@ bool DSoundBuf::get_output_buf( char **pBuffer, unsigned *pBufferSize, int iChun LOG->Warn( hr_ssprintf(result, "DirectSound::GetCurrentPosition failed") ); return false; } -#endif memmove( &m_iLastCursors[0][0], &m_iLastCursors[1][0], sizeof(int)*6 ); m_iLastCursors[3][0] = iCursorStart; @@ -552,13 +514,12 @@ bool DSoundBuf::get_output_buf( char **pBuffer, unsigned *pBufferSize, int iChun /* Lock the audio buffer. */ result = m_pBuffer->Lock( m_iWriteCursor, iNumBytesEmpty, (LPVOID *) &m_pLockedBuf1, (DWORD *) &m_iLockedSize1, (LPVOID *) &m_pLockedBuf2, (DWORD *) &m_iLockedSize2, 0 ); -#ifndef _XBOX if( result == DSERR_BUFFERLOST ) { m_pBuffer->Restore(); result = m_pBuffer->Lock( m_iWriteCursor, iNumBytesEmpty, (LPVOID *) &m_pLockedBuf1, (DWORD *) &m_iLockedSize1, (LPVOID *) &m_pLockedBuf2, (DWORD *) &m_iLockedSize2, 0 ); } -#endif + if( result != DS_OK ) { LOG->Warn( hr_ssprintf(result, "Couldn't lock the DirectSound buffer.") ); @@ -593,7 +554,6 @@ int64_t DSoundBuf::GetPosition() const DWORD iCursor, iJunk; HRESULT hr = m_pBuffer->GetCurrentPosition( &iCursor, &iJunk ); -#ifndef _XBOX if( hr == DSERR_BUFFERLOST ) { m_pBuffer->Restore(); @@ -604,7 +564,6 @@ int64_t DSoundBuf::GetPosition() const LOG->Warn( hr_ssprintf(hr, "DirectSound::GetPosition failed") ); iCursor = 0; } -#endif /* This happens occasionally on "Realtek AC97 Audio". */ if( (int) iCursor == m_iBufferSize ) diff --git a/src/arch/arch.cpp b/src/arch/arch.cpp new file mode 100644 index 0000000000..07f9593bef --- /dev/null +++ b/src/arch/arch.cpp @@ -0,0 +1,334 @@ +/* + * This file provides functions to create driver objects. + */ + +#include "global.h" +#include "RageLog.h" +#include "RageUtil.h" +#include "PrefsManager.h" +#include "arch.h" +#include "arch_platform.h" +#include "Foreach.h" +#include "LocalizedString.h" +#include "arch/arch_default.h" + +#include "InputHandler/Selector_InputHandler.h" +static LocalizedString INPUT_HANDLERS_EMPTY( "Arch", "Input Handlers cannot be empty." ); +void MakeInputHandlers( const RString &drivers, vector &Add ) +{ + vector DriversToTry; + split( drivers, ",", DriversToTry, true ); + + if( DriversToTry.empty() ) + RageException::Throw( INPUT_HANDLERS_EMPTY.GetValue() ); + + RString Driver; + + FOREACH_CONST( RString, DriversToTry, s ) + { + InputHandler *ret = NULL; + +#ifdef USE_INPUT_HANDLER_DIRECTINPUT + if( !s->CompareNoCase("DirectInput") ) ret = new InputHandler_DInput; +#endif +#ifdef USE_INPUT_HANDLER_LINUX_JOYSTICK + if( !s->CompareNoCase("Joystick") ) ret = new InputHandler_Linux_Joystick; +#endif +#ifdef USE_INPUT_HANDLER_LINUX_TTY + if( !s->CompareNoCase("tty") ) ret = new InputHandler_Linux_tty; +#endif +#ifdef USE_INPUT_HANDLER_SDL + if( !s->CompareNoCase("SDL") ) ret = new InputHandler_SDL; +#endif +#ifdef USE_INPUT_HANDLER_WIN32_PARA + if( !s->CompareNoCase("Para") ) ret = new InputHandler_Win32_Para; +#endif +#ifdef USE_INPUT_HANDLER_WIN32_PUMP + if( !s->CompareNoCase("Pump") ) ret = new InputHandler_Win32_Pump; +#endif +#ifdef USE_INPUT_HANDLER_WIN32_MIDI + if( !s->CompareNoCase("MIDI") ) ret = new InputHandler_Win32_MIDI; +#endif +#ifdef USE_INPUT_HANDLER_X11 + if( !s->CompareNoCase("X11") ) ret = new InputHandler_X11; +#endif +#ifdef USE_INPUT_HANDLER_XBOX + if( !s->CompareNoCase("Xbox") ) ret = new InputHandler_Xbox; +#endif +#ifdef USE_INPUT_HANDLER_MACOSX_HID + if( !s->CompareNoCase("MacOSX") ) ret = new InputHandler_MacOSX_HID; +#endif + + if( ret == NULL ) + LOG->Trace( "Unknown Input Handler name: %s", s->c_str() ); + else + Add.push_back( ret ); + } + + // Always add + Add.push_back( new InputHandler_MonkeyKeyboard ); + +} + +#include "Lights/Selector_LightsDriver.h" +void MakeLightsDrivers( const RString &driver, vector &Add ) +{ + LOG->Trace( "Initializing lights driver: %s", driver.c_str() ); + + LightsDriver *ret = NULL; + +#ifdef USE_LIGHTS_DRIVER_LINUX_PARALLEL + if( !driver.CompareNoCase("LinuxParallel") ) ret = new LightsDriver_LinuxParallel; +#endif +#ifdef USE_LIGHTS_DRIVER_LINUX_WEEDTECH + if( !driver.CompareNoCase("WeedTech") ) ret = new LightsDriver_LinuxWeedTech; +#endif +#ifdef USE_LIGHTS_DRIVER_WIN32_PARALLEL + if( !driver.CompareNoCase("Parallel") ) ret = new LightsDriver_Win32Parallel; +#endif + + if( ret == NULL && driver.CompareNoCase("Null") ) + LOG->Trace( "Unknown lights driver name: %s", driver.c_str() ); + else if( ret != NULL ) + Add.push_back( ret ); + + Add.push_back( new LightsDriver_SystemMessage ); +} + +#include "LoadingWindow/Selector_LoadingWindow.h" +LoadingWindow *MakeLoadingWindow() +{ + if( !PREFSMAN->m_bShowLoadingWindow ) + return new LoadingWindow_Null; +#if defined(LINUX) && !defined(HAVE_GTK) + return new LoadingWindow_Null; +#endif + // Don't load NULL by default. + const RString drivers = "xbox,win32,cocoa,gtk"; + vector DriversToTry; + split( drivers, ",", DriversToTry, true ); + + ASSERT( DriversToTry.size() != 0 ); + + RString Driver; + LoadingWindow *ret = NULL; + + for( unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i ) + { + Driver = DriversToTry[i]; + +#ifdef USE_LOADING_WINDOW_COCOA + if( !DriversToTry[i].CompareNoCase("Cocoa") ) ret = new LoadingWindow_Cocoa; +#endif +#ifdef USE_LOADING_WINDOW_GTK + if( !DriversToTry[i].CompareNoCase("Gtk") ) ret = new LoadingWindow_Gtk; +#endif +#ifdef USE_LOADING_WINDOW_NULL + if( !DriversToTry[i].CompareNoCase("Null") ) ret = new LoadingWindow_Null; +#endif +#ifdef USE_LOADING_WINDOW_WIN32 + if( !DriversToTry[i].CompareNoCase("Win32") ) ret = new LoadingWindow_Win32; +#endif +#ifdef USE_LOADING_WINDOW_XBOX + if( !DriversToTry[i].CompareNoCase("Xbox") ) ret = new LoadingWindow_Xbox; +#endif + + + if( ret == NULL ) + continue; + + RString sError = ret->Init(); + if( sError != "" ) + { + LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() ); + SAFE_DELETE( ret ); + } + } + + if(ret) + LOG->Info( "Loading window: %s", Driver.c_str() ); + + return ret; +} + +#if defined(SUPPORT_OPENGL) +#include "LowLevelWindow/Selector_LowLevelWindow.h" +LowLevelWindow *MakeLowLevelWindow() +{ + return new ARCH_LOW_LEVEL_WINDOW; +} +#endif + +#include "MemoryCard/MemoryCardDriver_Null.h" +#include "MemoryCard/Selector_MemoryCardDriver.h" +MemoryCardDriver *MakeMemoryCardDriver() +{ + MemoryCardDriver *ret = NULL; + +#ifdef ARCH_MEMORY_CARD_DRIVER + ret = new ARCH_MEMORY_CARD_DRIVER; +#endif + + if( !ret ) + ret = new MemoryCardDriver_Null; + + return ret; +} + +static Preference g_sMovieDrivers( "MovieDrivers", "" ); // "" == default +#include "MovieTexture/Selector_MovieTexture.h" +static void DumpAVIDebugInfo( const RString& fn ); +// Try drivers in order of preference until we find one that works. +static LocalizedString MOVIE_DRIVERS_EMPTY ( "Arch", "Movie Drivers cannot be empty." ); +static LocalizedString COULDNT_CREATE_MOVIE_DRIVER ( "Arch", "Couldn't create a movie driver." ); +RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ) +{ + DumpAVIDebugInfo( ID.filename ); + + RString sDrivers = g_sMovieDrivers; + if( sDrivers.empty() ) + sDrivers = DEFAULT_MOVIE_DRIVER_LIST; + + vector DriversToTry; + split( sDrivers, ",", DriversToTry, true ); + + if( DriversToTry.empty() ) + RageException::Throw( MOVIE_DRIVERS_EMPTY.GetValue() ); + + RString Driver; + RageMovieTexture *ret = NULL; + + for( unsigned i=0; ret==NULL && iTrace( "Initializing driver: %s", Driver.c_str() ); +#ifdef USE_MOVIE_TEXTURE_THEORA + if( !Driver.CompareNoCase("Theora") ) ret = new MovieTexture_Theora(ID); +#endif +#ifdef USE_MOVIE_TEXTURE_DSHOW + if( !Driver.CompareNoCase("DShow") ) ret = new MovieTexture_DShow(ID); +#endif +#ifdef USE_MOVIE_TEXTURE_FFMPEG + if( !Driver.CompareNoCase("FFMpeg") ) ret = new MovieTexture_FFMpeg(ID); +#endif +#ifdef USE_MOVIE_TEXTURE_NULL + if( !Driver.CompareNoCase("Null") ) ret = new MovieTexture_Null(ID); +#endif + if( ret == NULL ) + { + LOG->Trace( "Unknown movie driver name: %s", Driver.c_str() ); + continue; + } + + RString sError = ret->Init(); + if( sError != "" ) + { + LOG->Info( "Couldn't load driver %s: %s", Driver.c_str(), sError.c_str() ); + SAFE_DELETE( ret ); + } + } + if ( !ret ) + RageException::Throw( COULDNT_CREATE_MOVIE_DRIVER.GetValue() ); + + LOG->Trace( "Created movie texture \"%s\" with driver \"%s\"", + ID.filename.c_str(), Driver.c_str() ); + return ret; +} + +#include "Sound/Selector_RageSoundDriver.h" +static LocalizedString SOUND_DRIVERS_CANNOT_EMPTY( "Arch", "Sound Drivers cannot be empty." ); +RageSoundDriver *MakeRageSoundDriver( const RString &drivers ) +{ + vector DriversToTry; + split( drivers, ",", DriversToTry, true ); + + if( DriversToTry.empty() ) + RageException::Throw( SOUND_DRIVERS_CANNOT_EMPTY.GetValue() ); + + RString Driver; + RageSoundDriver *ret = NULL; + + for( unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i ) + { + Driver = DriversToTry[i]; + LOG->Trace( "Initializing driver: %s", DriversToTry[i].c_str() ); + +#ifdef USE_RAGE_SOUND_ALSA9 + if( !DriversToTry[i].CompareNoCase("ALSA") ) ret = new RageSound_ALSA9; +#endif +#ifdef USE_RAGE_SOUND_ALSA9_SOFTWARE + if( !DriversToTry[i].CompareNoCase("ALSA-sw") ) ret = new RageSound_ALSA9_Software; +#endif +#ifdef USE_RAGE_SOUND_AU + if( !DriversToTry[i].CompareNoCase("AudioUnit") ) ret = new RageSoundDriver_AU; +#endif +#ifdef USE_RAGE_SOUND_DSOUND + if( !DriversToTry[i].CompareNoCase("DirectSound") ) ret = new RageSound_DSound; +#endif +#ifdef USE_RAGE_SOUND_DSOUND_SOFTWARE + if( !DriversToTry[i].CompareNoCase("DirectSound-sw") ) ret = new RageSound_DSound_Software; +#endif +#ifdef USE_RAGE_SOUND_NULL + if( !DriversToTry[i].CompareNoCase("Null") ) ret = new RageSound_Null; +#endif +#ifdef USE_RAGE_SOUND_OSS + if( !DriversToTry[i].CompareNoCase("OSS") ) ret = new RageSound_OSS; +#endif +#ifdef USE_RAGE_SOUND_WAVE_OUT + if( !DriversToTry[i].CompareNoCase("WaveOut") ) ret = new RageSound_WaveOut; +#endif + + if( ret == NULL ) + { + LOG->Trace( "Unknown sound driver name: %s", DriversToTry[i].c_str() ); + continue; + } + + RString sError = ret->Init(); + if( sError != "" ) + { + LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() ); + SAFE_DELETE( ret ); + } + } + + if( ret ) + LOG->Info( "Sound driver: %s", Driver.c_str() ); + + return ret; +} + +// Helper for MakeRageMovieTexture() +static void DumpAVIDebugInfo( const RString& fn ) +{ + RString type, handler; + if( !RageMovieTexture::GetFourCC( fn, handler, type ) ) + return; + + LOG->Trace( "Movie %s has handler '%s', type '%s'", fn.c_str(), handler.c_str(), type.c_str() ); +} + +/* + * (c) 2002-2005 Glenn Maynard, Ben Anderson + * 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. + */ diff --git a/src/arch/arch.h b/src/arch/arch.h new file mode 100644 index 0000000000..12ac984c8b --- /dev/null +++ b/src/arch/arch.h @@ -0,0 +1,71 @@ +#ifndef ARCH_H +#define ARCH_H + +#include "RageTextureID.h" + +// Put renderers switch here, makes things cleaner +#if defined(_WINDOWS) +#define SUPPORT_OPENGL +#define SUPPORT_D3D +#elif defined(_XBOX) +#define SUPPORT_D3D +#else +#define SUPPORT_OPENGL +#endif + +// Include this file if you need to create an instance of a driver object. +class ArchHooks; +ArchHooks *MakeArchHooks(); + +class DialogDriver; +DialogDriver *MakeDialogDriver(); + +class InputHandler; +void MakeInputHandlers( const RString &drivers, vector &Add ); + +class LightsDriver; +void MakeLightsDrivers( const RString &drivers, vector &Add ); + +class LoadingWindow; +LoadingWindow *MakeLoadingWindow(); + +#if defined(SUPPORT_OPENGL) +class LowLevelWindow; +LowLevelWindow *MakeLowLevelWindow(); +#endif + +class MemoryCardDriver; +MemoryCardDriver *MakeMemoryCardDriver(); + +class RageMovieTexture; +RageMovieTexture *MakeRageMovieTexture( RageTextureID ID ); + +class RageSoundDriver; +RageSoundDriver *MakeRageSoundDriver( const RString &drivers ); + +#endif + +/* + * (c) 2002-2005 Glenn Maynard, Ben Anderson + * 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. + */ diff --git a/src/arch/arch_platform.h b/src/arch/arch_platform.h new file mode 100644 index 0000000000..b33b0a7e38 --- /dev/null +++ b/src/arch/arch_platform.h @@ -0,0 +1,36 @@ +#ifndef ARCH_PLATFORM_H +#define ARCH_PLATFORM_H + +// In here, you define which APIs are guaranteed to be available on which OSes. +// Don't ever actually #include anything here -- that's for */Selector_*.h. +#if defined(_WINDOWS) +#define HAVE_DIRECTX +#define HAVE_FFMPEG +#endif + +#endif + +/* + * (c) 2002-2005 Glenn Maynard, Ben Anderson + * 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. + */ diff --git a/src/archutils/Darwin/SMMain.mm b/src/archutils/Darwin/SMMain.mm index 975c6b1587..6fd9df2f8a 100644 --- a/src/archutils/Darwin/SMMain.mm +++ b/src/archutils/Darwin/SMMain.mm @@ -1,6 +1,8 @@ #include "global.h" #include "RageUtil.h" #include "RageThreads.h" +#include "RageLog.h" +#include "CommandLineActions.h" #import #include "ProductInfo.h" @@ -69,11 +71,34 @@ exit( SM_main(m_iArgc, m_pArgv) ); } +/* From here: + * http://www.cocoadev.com/index.pl?HowToRegisterURLHandler */ +- (void) getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + const char *url = [[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String]; + + LOG->Info("Parsing URL: %s", url); + + // I'm not sure this handles everything it needs to. - Colby + CommandLineActions::CommandLineArgs args; + args.argv.push_back(url); + + CommandLineActions::ToProcess.push_back(args); +} + // Called when the internal event loop has just started running. - (void) applicationDidFinishLaunching:(NSNotification *)note { m_bApplicationLaunched = YES; [NSThread detachNewThreadSelector:@selector(startGame:) toTarget:self withObject:nil]; + + // Register ourselves as a URL handler. + [ + [NSAppleEventManager sharedAppleEventManager] setEventHandler:self + andSelector:@selector(getUrl:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL + ]; } - (BOOL) application:(NSApplication *)app openFile:(NSString *)file diff --git a/src/archutils/Win32/CrashHandlerChild.cpp b/src/archutils/Win32/CrashHandlerChild.cpp index e13fc881ce..b6156eba3a 100644 --- a/src/archutils/Win32/CrashHandlerChild.cpp +++ b/src/archutils/Win32/CrashHandlerChild.cpp @@ -311,8 +311,8 @@ namespace SymbolLookup if( obuf[0] == '_' ) { - strcat( obuf, "()" ); /* _main -> _main() */ - return obuf+1; /* _main -> main */ + strcat( obuf, "()" ); // _main -> _main() + return obuf+1; // _main -> main } return obuf; @@ -487,7 +487,7 @@ static void DoSave( const RString &sReport ) fclose( pFile ); - /* Discourage changing crashinfo.txt. */ + // Discourage changing crashinfo.txt. SetFileAttributes( sName, FILE_ATTRIBUTE_READONLY ); } @@ -522,15 +522,15 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) { _setmode( _fileno(stdin), O_BINARY ); - /* 0. Read the parent handle. */ + // 0. Read the parent handle. if( !ReadFromParent(iFD, &SymbolLookup::g_hParent, sizeof(SymbolLookup::g_hParent)) ) return false; - /* 1. Read the CrashData. */ + // 1. Read the CrashData. if( !ReadFromParent(iFD, &Data.m_CrashInfo, sizeof(Data.m_CrashInfo)) ) return false; - /* 2. Read info. */ + // 2. Read info. int iSize; if( !ReadFromParent(iFD, &iSize, sizeof(iSize)) ) return false; @@ -540,7 +540,7 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) return false; Data.m_sInfo.ReleaseBuffer( iSize ); - /* 3. Read AdditionalLog. */ + // 3. Read AdditionalLog. if( !ReadFromParent(iFD, &iSize, sizeof(iSize)) ) return false; @@ -549,7 +549,7 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) return false; Data.m_sAdditionalLog.ReleaseBuffer( iSize ); - /* 4. Read RecentLogs. */ + // 4. Read RecentLogs. int iCnt = 0; if( !ReadFromParent(iFD, &iCnt, sizeof(iCnt)) ) return false; @@ -565,7 +565,7 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) sBuf.ReleaseBuffer( iSize ); } - /* 5. Read CHECKPOINTs. */ + // 5. Read CHECKPOINTs. if( !ReadFromParent(iFD, &iSize, sizeof(iSize)) ) return false; @@ -577,7 +577,7 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) split( sBuf, "$$", Data.m_asCheckpoints ); sBuf.ReleaseBuffer( iSize ); - /* 6. Read the crashed thread's name. */ + // 6. Read the crashed thread's name. if( !ReadFromParent(iFD, &iSize, sizeof(iSize)) ) return false; pBuf = Data.m_sCrashedThread.GetBuffer( iSize ); @@ -588,13 +588,11 @@ bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) return true; } -/* - * Localization for the crash handler is different, and a little tricky. We don't - * have ThemeManager loaded, so we have to localize it ourself. We can supply - * translations with our own substitution function. We need to figure out which - * language to use. Since these strings won't be pulled from the theme, defer - * loading them until we use them. XXX - */ +/* Localization for the crash handler is different, and a little tricky. We don't + * have ThemeManager loaded, so we have to localize it ourself. We can supply + * translations with our own substitution function. We need to figure out which + * language to use. Since these strings won't be pulled from the theme, defer + * loading them until we use them. XXX */ static LocalizedString A_CRASH_HAS_OCCURRED; static LocalizedString REPORTING_THE_PROBLEM; static LocalizedString CLOSE; @@ -688,7 +686,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) HWND hwndStatic = (HWND)lParam; HBRUSH hbr = NULL; - // TODO: Change any attributes of the DC here + // TODO: Change any attributes of the DC here switch( GetDlgCtrlID(hwndStatic) ) { case IDC_STATIC_HEADER_TEXT: @@ -699,7 +697,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) break; } - // TODO: Return a different brush if the default is not desired + // TODO: Return a different brush if the default is not desired return (BOOL)hbr; } @@ -709,7 +707,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) case IDC_BUTTON_CLOSE: if( m_pPost != NULL ) { - /* Cancel reporting, and revert the dialog as if "report" had not been pressed. */ + // Cancel reporting, and revert the dialog as if "report" had not been pressed. m_pPost->Cancel(); KillTimer( hDlg, 0 ); @@ -718,11 +716,11 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) return TRUE; } - /* Close the dialog. */ + // Close the dialog. EndDialog(hDlg, FALSE); return TRUE; case IDOK: - // EndDialog(hDlg, TRUE); /* don't always exit on ENTER */ + // EndDialog(hDlg, TRUE); // don't always exit on ENTER return TRUE; case IDC_VIEW_LOG: ViewWithNotepad("../log.txt"); @@ -740,8 +738,8 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) case IDC_BUTTON_AUTO_REPORT: if( !m_sUpdateURL.empty() ) { - /* We already sent the report, were told that there's an update, and - * substituted the URL. */ + /* We already sent the report, were told that there's an update, + * and substituted the URL. */ GotoURL( m_sUpdateURL ); break; } @@ -753,7 +751,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) SendDlgItemMessage( hDlg, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0,100) ); SendDlgItemMessage( hDlg, IDC_PROGRESS, PBM_SETPOS, 0, 0 ); - /* Create the form data to send. */ + // Create the form data to send. m_pPost = new NetworkPostData; m_pPost->SetData( "Product", PRODUCT_ID ); m_pPost->SetData( "Version", PRODUCT_VER ); @@ -779,8 +777,8 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { KillTimer( hDlg, 0 ); - /* Grab the result, which is the data output from the HTTP request. It's - * simple XML. */ + /* Grab the result, which is the data output from the HTTP request. + * It's simple XML. */ RString sResult = m_pPost->GetResult(); RString sError = m_pPost->GetError(); if( sError.empty() && sResult.empty() ) @@ -803,18 +801,18 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) int iID; if( !sError.empty() ) { - /* On error, don't show the "report" button again. If the submission was actually + /* On error, don't show the "report" button again. If the submission was actually * successful, then it'd be too easy to accidentally spam the server by holding * down the button. */ SetWindowText( GetDlgItem(hDlg, IDC_MAIN_TEXT), ERROR_SENDING_REPORT.GetValue() ); } - else if( xml.GetAttrValue("UpdateAvailable", m_sUpdateURL) ) + else if( xml.GetChildValue("UpdateAvailable", m_sUpdateURL) ) { SetWindowText( GetDlgItem(hDlg, IDC_MAIN_TEXT), UPDATE_IS_AVAILABLE.GetValue() ); SetWindowText( GetDlgItem(hDlg, IDC_BUTTON_AUTO_REPORT), VIEW_UPDATE.GetValue() ); ShowWindow( GetDlgItem(hDlg, IDC_BUTTON_AUTO_REPORT), true ); } - else if( xml.GetAttrValue("ReportId", iID) ) + else if( xml.GetChildValue("ReportId", iID) ) { SetWindowText( GetDlgItem(hDlg, IDC_MAIN_TEXT), UPDATE_IS_NOT_AVAILABLE.GetValue() ); } @@ -823,7 +821,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) SetWindowText( GetDlgItem(hDlg, IDC_MAIN_TEXT), ERROR_SENDING_REPORT.GetValue() ); } - if( xml.GetAttrValue("ReportId", iID) ) + if( xml.GetChildValue("ReportId", iID) ) { char sBuf[1024]; GetWindowText( hDlg, sBuf, 1024 ); @@ -841,7 +839,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) void ChildProcess() { - /* Read the crash data from the crashed parent. */ + // Read the crash data from the crashed parent. CompleteCrashData Data; ReadCrashDataFromParent( fileno(stdin), Data ); @@ -852,10 +850,10 @@ void ChildProcess() DoSave( sCrashReport ); - /* Tell the crashing process that it can exit. Be sure to write crashinfo.txt first. */ + // Tell the crashing process that it can exit. Be sure to write crashinfo.txt first. fclose( stdout ); - /* Now that we've done that, the process is gone. Don't use g_hParent. */ + // Now that we've done that, the process is gone. Don't use g_hParent. CloseHandle( SymbolLookup::g_hParent ); SymbolLookup::g_hParent = NULL; diff --git a/src/archutils/Win32/DialogUtil.cpp b/src/archutils/Win32/DialogUtil.cpp index c534da05de..5971d8a23d 100644 --- a/src/archutils/Win32/DialogUtil.cpp +++ b/src/archutils/Win32/DialogUtil.cpp @@ -81,7 +81,6 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg ) } } - /* * (c) 2002-2004 Chris Danford * All rights reserved. diff --git a/src/archutils/Win32/GraphicsWindow.cpp b/src/archutils/Win32/GraphicsWindow.cpp index 0de1571f0b..bc7c906a7b 100644 --- a/src/archutils/Win32/GraphicsWindow.cpp +++ b/src/archutils/Win32/GraphicsWindow.cpp @@ -11,6 +11,7 @@ #include "archutils/Win32/ErrorStrings.h" #include "archutils/Win32/WindowIcon.h" #include "archutils/Win32/GetFileInformation.h" +#include "CommandLineActions.h" #include @@ -25,7 +26,7 @@ static HICON g_hIcon = NULL; static bool m_bWideWindowClass; static bool g_bD3D = false; -/* If we're fullscreen, this is the mode we set. */ +// If we're fullscreen, this is the mode we set. static DEVMODE g_FullScreenDevMode; static bool g_bRecreatingVideoMode = false; @@ -58,108 +59,117 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar switch( msg ) { - case WM_ACTIVATE: - { - const bool bInactive = (LOWORD(wParam) == WA_INACTIVE); - const bool bMinimized = (HIWORD(wParam) != 0); - const bool bHadFocus = g_bHasFocus; - g_bHasFocus = !bInactive && !bMinimized; - LOG->Trace( "WM_ACTIVATE (%i, %i): %s", bInactive, bMinimized, g_bHasFocus? "has focus":"doesn't have focus" ); - if( !g_bHasFocus ) + case WM_ACTIVATE: { - RString sName = GetNewWindow(); - static set sLostFocusTo; - sLostFocusTo.insert( sName ); - RString sStr; - for( set::const_iterator it = sLostFocusTo.begin(); it != sLostFocusTo.end(); ++it ) - sStr += (sStr.size()?", ":"") + *it; - - LOG->MapLog( "LOST_FOCUS", "Lost focus to: %s", sStr.c_str() ); - } - - if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) - { - /* In OpenGL (not D3D), it's our job to unset and reset the full-screen video mode - * when we focus changes, and to hide and show the window. Hiding is done in WM_KILLFOCUS, - * because that's where most other apps seem to do it. */ - if( g_bHasFocus && !bHadFocus ) + const bool bInactive = (LOWORD(wParam) == WA_INACTIVE); + const bool bMinimized = (HIWORD(wParam) != 0); + const bool bHadFocus = g_bHasFocus; + g_bHasFocus = !bInactive && !bMinimized; + LOG->Trace( "WM_ACTIVATE (%i, %i): %s", bInactive, bMinimized, g_bHasFocus? "has focus":"doesn't have focus" ); + if( !g_bHasFocus ) { - ChangeDisplaySettings( &g_FullScreenDevMode, CDS_FULLSCREEN ); - ShowWindow( g_hWndMain, SW_SHOWNORMAL ); + RString sName = GetNewWindow(); + static set sLostFocusTo; + sLostFocusTo.insert( sName ); + RString sStr; + for( set::const_iterator it = sLostFocusTo.begin(); it != sLostFocusTo.end(); ++it ) + sStr += (sStr.size()?", ":"") + *it; + + LOG->MapLog( "LOST_FOCUS", "Lost focus to: %s", sStr.c_str() ); } - else if( !g_bHasFocus && bHadFocus ) + + if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) { - ChangeDisplaySettings( NULL, 0 ); + /* In OpenGL (not D3D), it's our job to unset and reset the full-screen video mode + * when we focus changes, and to hide and show the window. Hiding is done in WM_KILLFOCUS, + * because that's where most other apps seem to do it. */ + if( g_bHasFocus && !bHadFocus ) + { + ChangeDisplaySettings( &g_FullScreenDevMode, CDS_FULLSCREEN ); + ShowWindow( g_hWndMain, SW_SHOWNORMAL ); + } + else if( !g_bHasFocus && bHadFocus ) + { + ChangeDisplaySettings( NULL, 0 ); + } } - } - return 0; - } - case WM_KILLFOCUS: - if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) - ShowWindow( g_hWndMain, SW_SHOWMINNOACTIVE ); - break; - - /* Is there any reason we should care what size the user resizes the window to? */ -// case WM_GETMINMAXINFO: - - case WM_SETCURSOR: - if( !g_CurrentParams.windowed ) - { - SetCursor( NULL ); - return 1; - } - break; - - case WM_SYSCOMMAND: - switch( wParam&0xFFF0 ) - { - case SC_MONITORPOWER: - case SC_SCREENSAVE: return 0; } - break; - - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint( hWnd, &ps ); - EndPaint( hWnd, &ps ); - break; - } - - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - /* We handle all input ourself, via DirectInput. */ - return 0; - - case WM_CLOSE: - LOG->Trace("WM_CLOSE: shutting down"); - ArchHooks::SetUserQuit(); - return 0; - - case WM_WINDOWPOSCHANGED: - { - /* If we're fullscreen and don't have focus, our window is hidden, so GetClientRect - * isn't meaningful. */ - if( !g_CurrentParams.windowed && !g_bHasFocus ) + case WM_KILLFOCUS: + if( !g_bD3D && !g_CurrentParams.windowed && !g_bRecreatingVideoMode ) + ShowWindow( g_hWndMain, SW_SHOWMINNOACTIVE ); break; - RECT rect; - GetClientRect( hWnd, &rect ); + /* Is there any reason we should care what size the user resizes the window to? */ + // case WM_GETMINMAXINFO: - int iWidth = rect.right - rect.left; - int iHeight = rect.bottom - rect.top; - if( g_CurrentParams.width != iWidth || g_CurrentParams.height != iHeight ) + case WM_SETCURSOR: + if( !g_CurrentParams.windowed ) + { + SetCursor( NULL ); + return 1; + } + break; + + case WM_SYSCOMMAND: + switch( wParam&0xFFF0 ) + { + case SC_MONITORPOWER: + case SC_SCREENSAVE: + return 0; + } + break; + + case WM_PAINT: { - g_CurrentParams.width = iWidth; - g_CurrentParams.height = iHeight; - g_bResolutionChanged = true; + PAINTSTRUCT ps; + BeginPaint( hWnd, &ps ); + EndPaint( hWnd, &ps ); + break; + } + + case WM_KEYDOWN: + case WM_KEYUP: + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + /* We handle all input ourself, via DirectInput. */ + return 0; + + case WM_CLOSE: + LOG->Trace("WM_CLOSE: shutting down"); + ArchHooks::SetUserQuit(); + return 0; + + case WM_WINDOWPOSCHANGED: + { + /* If we're fullscreen and don't have focus, our window is hidden, so GetClientRect + * isn't meaningful. */ + if( !g_CurrentParams.windowed && !g_bHasFocus ) + break; + + RECT rect; + GetClientRect( hWnd, &rect ); + + int iWidth = rect.right - rect.left; + int iHeight = rect.bottom - rect.top; + if( g_CurrentParams.width != iWidth || g_CurrentParams.height != iHeight ) + { + g_CurrentParams.width = iWidth; + g_CurrentParams.height = iHeight; + g_bResolutionChanged = true; + } + break; + } + case WM_COPYDATA: + { + PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam; + RString sCommandLine( (char*)pMyCDS->lpData, pMyCDS->cbData ); + CommandLineActions::CommandLineArgs args; + split( sCommandLine, "|", args.argv, false ); + CommandLineActions::ToProcess.push_back( args ); + break; } - break; - } } CHECKPOINT_M( ssprintf("%p, %u, %08x, %08x", hWnd, msg, wParam, lParam) ); diff --git a/src/config.h.in b/src/config.h.in deleted file mode 100644 index 4d1f6a7202..0000000000 --- a/src/config.h.in +++ /dev/null @@ -1,258 +0,0 @@ -/* src/config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Define demangle type */ -#undef BACKTRACE_DEMANGLE_METHOD_TEXT - -/* Define symbol lookup type */ -#undef BACKTRACE_LOOKUP_METHOD_BACKTRACE_SYMBOLS - -/* Define symbol lookup type */ -#undef BACKTRACE_LOOKUP_METHOD_DLADDR - -/* Define backtrace type */ -#undef BACKTRACE_LOOKUP_METHOD_TEXT - -/* Define backtrace type */ -#undef BACKTRACE_METHOD_PPC_LINUX - -/* Define backtrace type */ -#undef BACKTRACE_METHOD_TEXT - -/* Define backtrace type */ -#undef BACKTRACE_METHOD_X86_LINUX - -/* BSD */ -#undef BSD - -/* PPC */ -#undef CPU_PPC - -/* x86 */ -#undef CPU_X86 - -/* x86-64 */ -#undef CPU_X86_64 - -/* Define if using crash handler */ -#undef CRASH_HANDLER - -/* Big endian */ -#undef ENDIAN_BIG - -/* Little endian */ -#undef ENDIAN_LITTLE - -/* Force OSS Usage */ -#undef FORCE_OSS - -/* Define to 1 if you have the header file. */ -#undef HAVE_ALLOCA_H - -/* Define presence of ALSA */ -#undef HAVE_ALSA - -/* abi::__cxa_demangle available */ -#undef HAVE_CXA_DEMANGLE - -/* Define to 1 if you have the declaration of `SIGPWR', and to 0 if you don't. - */ -#undef HAVE_DECL_SIGPWR - -/* Define to 1 if you have the declaration of `SIGUSR1', and to 0 if you - don't. */ -#undef HAVE_DECL_SIGUSR1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_ENDIAN_H - -/* FFMPEG support available */ -#undef HAVE_FFMPEG - -/* Define presence of GTK */ -#undef HAVE_GTK - -/* Define if you have the iconv() function. */ -#undef HAVE_ICONV - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `asound' library (-lasound). */ -#undef HAVE_LIBASOUND - -/* Liberty available */ -#undef HAVE_LIBIBERTY - -/* libpthread is available */ -#undef HAVE_LIBPTHREAD - -/* libXtst available */ -#undef HAVE_LIBXTST - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACHINE_ENDIAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* OSS support available */ -#undef HAVE_OSS - -/* OSS_GETVERSION is defined */ -#undef HAVE_OSS_GETVERSION - -/* pthreads has pthread_cond_timedwait() */ -#undef HAVE_PTHREAD_COND_TIMEDWAIT - -/* pthreads has pthread_mutex_timedlock() */ -#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK - -/* pulseaudio support available */ -#undef HAVE_PULSE - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Theora support available */ -#undef HAVE_THEORA - -/* Define if the compiler supports __thread */ -#undef HAVE_TLS - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* X11 libraries present */ -#undef HAVE_X11 - -/* Define as const if the declaration of iconv() needs const. */ -#undef ICONV_CONST - -/* Integer Vorbis decoding */ -#undef INTEGER_VORBIS - -/* Linux */ -#undef LINUX - -/* Linux for Lua */ -#undef LUA_USE_LINUX - -/* stdint.h is missing */ -#undef MISSING_STDINT_H - -/* Need acosf */ -#undef NEED_ACOSF - -/* Need tanf */ -#undef NEED_COSF - -/* cstdlib breaks llabs */ -#undef NEED_CSTDLIB_WORKAROUND - -/* Need powf */ -#undef NEED_POWF - -/* Need roundf */ -#undef NEED_ROUNDF - -/* Need sinf */ -#undef NEED_SINF - -/* Need sqrtf */ -#undef NEED_SQRTF - -/* Need strtof */ -#undef NEED_STRTOF - -/* Need cosf */ -#undef NEED_TANF - -/* Need truncf */ -#undef NEED_TRUNCF - -/* JPEG support not available */ -#undef NO_JPEG_SUPPORT - -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - -/* MP3 support not available */ -#undef NO_MP3_SUPPORT - -/* Vorbis support not available */ -#undef NO_VORBIS_SUPPORT - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Unix */ -#undef UNIX - -/* Networking support not available */ -#undef WITHOUT_NETWORKING - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* STL debug */ -#undef _GLIBCXX_DEBUG - -/* STL pedantic debug */ -#undef _GLIBCXX_DEBUG_PEDANTIC - -/* Use GNU extensions */ -#undef _GNU_SOURCE - -/* Use PRId64 and similar */ -#undef __STDC_FORMAT_MACROS - -/* Define to the compiler TLS keyword */ -#undef thread_local diff --git a/src/jsoncpp/AUTHORS b/src/jsoncpp/AUTHORS new file mode 100644 index 0000000000..333e120d6e --- /dev/null +++ b/src/jsoncpp/AUTHORS @@ -0,0 +1 @@ +Baptiste Lepilleur diff --git a/src/jsoncpp/LICENSE b/src/jsoncpp/LICENSE new file mode 100644 index 0000000000..d20fb29a7e --- /dev/null +++ b/src/jsoncpp/LICENSE @@ -0,0 +1 @@ +The json-cpp library and this documentation are in Public Domain. diff --git a/src/jsoncpp/README.txt b/src/jsoncpp/README.txt new file mode 100644 index 0000000000..ed7ef8ff91 --- /dev/null +++ b/src/jsoncpp/README.txt @@ -0,0 +1,117 @@ +* Introduction: + ============= + +JSON (JavaScript Object Notation) is a lightweight data-interchange format. +It can represent integer, real number, string, an ordered sequence of +value, and a collection of name/value pairs. + +JsonCpp is a simple API to manipulate JSON value, handle serialization +and unserialization to string. + +It can also preserve existing comment in unserialization/serialization steps, +making it a convenient format to store user input files. + +Unserialization parsing is user friendly and provides precise error reports. + + +* Building/Testing: + ================= + +JsonCpp uses Scons (http://www.scons.org) as a build system. Scons requires +python to be installed (http://www.python.org). + +You download scons-local distribution from the following url: +http://sourceforge.net/project/showfiles.php?group_id=30337&package_id=67375 + +Unzip it in the directory where you found this README file. scons.py Should be +at the same level as README. + +python scons.py platform=PLTFRM [TARGET] +where PLTFRM may be one of: + suncc Sun C++ (Solaris) + vacpp Visual Age C++ (AIX) + mingw + msvc6 Microsoft Visual Studio 6 service pack 5-6 + msvc70 Microsoft Visual Studio 2002 + msvc71 Microsoft Visual Studio 2003 + msvc80 Microsoft Visual Studio 2005 + linux-gcc Gnu C++ (linux, also reported to work for Mac OS X) + +adding platform is fairly simple. You need to change the Sconstruct file +to do so. + +and TARGET may be: + check: build library and run unit tests. + + +* Running the test manually: + ========================== + +cd test +# This will run the Reader/Writer tests +python runjsontests.py "path to jsontest.exe" + +# This will run the Reader/Writer tests, using JSONChecker test suite +# (http://www.json.org/JSON_checker/). +# Notes: not all tests pass: JsonCpp is too lenient (for example, +# it allows an integer to start with '0'). The goal is to improve +# strict mode parsing to get all tests to pass. +python runjsontests.py --with-json-checker "path to jsontest.exe" + +# This will run the unit tests (mostly Value) +python rununittests.py "path to test_lib_json.exe" + +You can run the tests using valgrind: +python rununittests.py --valgrind "path to test_lib_json.exe" + + +* Building the documentation: + =========================== + +Run the python script doxybuild.py from the top directory: + +python doxybuild.py --open --with-dot + +See doxybuild.py --help for options. + + +* Adding a reader/writer test: + ============================ + +To add a test, you need to create two files in test/data: +- a TESTNAME.json file, that contains the input document in JSON format. +- a TESTNAME.expected file, that contains a flatened representation of + the input document. + +TESTNAME.expected file format: +- each line represents a JSON element of the element tree represented + by the input document. +- each line has two parts: the path to access the element separated from + the element value by '='. Array and object values are always empty + (e.g. represented by either [] or {}). +- element path: '.' represented the root element, and is used to separate + object members. [N] is used to specify the value of an array element + at index N. +See test_complex_01.json and test_complex_01.expected to better understand +element path. + + +* Understanding reader/writer test output: + ======================================== + +When a test is run, output files are generated aside the input test files. +Below is a short description of the content of each file: + +- test_complex_01.json: input JSON document +- test_complex_01.expected: flattened JSON element tree used to check if + parsing was corrected. + +- test_complex_01.actual: flattened JSON element tree produced by + jsontest.exe from reading test_complex_01.json +- test_complex_01.rewrite: JSON document written by jsontest.exe using the + Json::Value parsed from test_complex_01.json and serialized using + Json::StyledWritter. +- test_complex_01.actual-rewrite: flattened JSON element tree produced by + jsontest.exe from reading test_complex_01.rewrite. +test_complex_01.process-output: jsontest.exe output, typically useful to + understand parsing error. diff --git a/src/jsoncpp/doc/doxyfile.in b/src/jsoncpp/doc/doxyfile.in new file mode 100644 index 0000000000..48861d2385 --- /dev/null +++ b/src/jsoncpp/doc/doxyfile.in @@ -0,0 +1,1534 @@ +# Doxyfile 1.5.9 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "JsonCpp" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = %JSONCPP_VERSION% + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = %DOC_TOPDIR% + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = %TOPDIR% + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = %TOPDIR%/include + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 3 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = "testCaseSetup=\link CppUT::TestCase::setUp() setUp()\endlink" \ + "testCaseRun=\link CppUT::TestCase::run() run()\endlink" \ + "testCaseTearDown=\link CppUT::TestCase::tearDown() tearDown()\endlink" \ + "json_ref=JSON (JavaScript Object Notation)" + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = YES + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = YES + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = NO + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = NO + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = %WARNING_LOG_PATH% + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../include ../src/lib_json . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.h \ + *.cpp \ + *.inl \ + *.dox + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = %HTML_OUTPUT% + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = %HTML_HELP% + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = jsoncpp-%JSONCPP_VERSION%.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = "c:\Program Files\HTML Help Workshop\hhc.exe" + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = YES + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = YES + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = ../include + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = *.h + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = "_MSC_VER=1400" \ + _CPPRTTI \ + _WIN32 \ + JSONCPP_DOC_EXCLUDE_IMPLEMENTATION \ + JSON_VALUE_USE_INTERNAL_MAP + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = NO + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = %HAVE_DOT% + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = %UML_LOOK% + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = %DOT_PATH% + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 1000 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/src/jsoncpp/doc/footer.html b/src/jsoncpp/doc/footer.html new file mode 100644 index 0000000000..a61d9528a1 --- /dev/null +++ b/src/jsoncpp/doc/footer.html @@ -0,0 +1,23 @@ +
+ + + + + + + +
+ + SourceForge Logo + + hosts this site. + + + Send comments to:
+ Json-cpp Developers +
+ + + diff --git a/src/jsoncpp/doc/header.html b/src/jsoncpp/doc/header.html new file mode 100644 index 0000000000..d56ea59c69 --- /dev/null +++ b/src/jsoncpp/doc/header.html @@ -0,0 +1,24 @@ + + + +JsonCpp - JSON data format manipulation library + + + + + + + + + + + +
+ + JsonCpp project page + + + JsonCpp home page +
+ +
diff --git a/src/jsoncpp/doc/jsoncpp.dox b/src/jsoncpp/doc/jsoncpp.dox new file mode 100644 index 0000000000..abaac6c7de --- /dev/null +++ b/src/jsoncpp/doc/jsoncpp.dox @@ -0,0 +1,116 @@ +/** +\mainpage +\section _intro Introduction + +JSON (JavaScript Object Notation) + is a lightweight data-interchange format. +It can represent integer, real number, string, an ordered sequence of value, and +a collection of name/value pairs. + +Here is an example of JSON data: +\verbatim +// Configuration options +{ + // Default encoding for text + "encoding" : "UTF-8", + + // Plug-ins loaded at start-up + "plug-ins" : [ + "python", + "c++", + "ruby" + ], + + // Tab indent size + "indent" : { "length" : 3, "use_space" = true } +} +\endverbatim + +\section _features Features +- read and write JSON document +- attach C and C++ style comments to element during parsing +- rewrite JSON document preserving original comments + +Notes: Comments used to be supported in JSON but where removed for +portability (C like comments are not supported in Python). Since +comments are useful in configuration/input file, this feature was +preserved. + +\section _example Code example + +\code +Json::Value root; // will contains the root value after parsing. +Json::Reader reader; +bool parsingSuccessful = reader.parse( config_doc, root ); +if ( !parsingSuccessful ) +{ + // report to the user the failure and their locations in the document. + std::cout << "Failed to parse configuration\n" + << reader.getFormatedErrorMessages(); + return; +} + +// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no +// such member. +std::string encoding = root.get("encoding", "UTF-8" ).asString(); +// Get the value of the member of root named 'encoding', return a 'null' value if +// there is no such member. +const Json::Value plugins = root["plug-ins"]; +for ( int index = 0; index < plugins.size(); ++index ) // Iterates over the sequence elements. + loadPlugIn( plugins[index].asString() ); + +setIndentLength( root["indent"].get("length", 3).asInt() ); +setIndentUseSpace( root["indent"].get("use_space", true).asBool() ); + +// ... +// At application shutdown to make the new configuration document: +// Since Json::Value has implicit constructor for all value types, it is not +// necessary to explicitly construct the Json::Value object: +root["encoding"] = getCurrentEncoding(); +root["indent"]["length"] = getCurrentIndentLength(); +root["indent"]["use_space"] = getCurrentIndentUseSpace(); + +Json::StyledWriter writer; +// Make a new JSON document for the configuration. Preserve original comments. +std::string outputConfig = writer.write( root ); + +// You can also use streams. This will put the contents of any JSON +// stream at a particular sub-value, if you'd like. +std::cin >> root["subtree"]; + +// And you can write to a stream, using the StyledWriter automatically. +std::cout << root; +\endcode + +\section _plinks Build instructions +The build instructions are located in the file +README.txt in the top-directory of the project. + +Permanent link to the latest revision of the file in subversion: +latest README.txt + +\section _pdownload Download +The sources can be downloaded from +SourceForge download page. + +The latest version of the source is available in the project's subversion repository: + +http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/ + +To checkout the source, see the following +instructions. + +\section _plinks Project links +- json-cpp home +- json-cpp sourceforge project + +\section _rlinks Related links +- JSON Specification and alternate language implementations. +- YAML A data format designed for human readability. +- UTF-8 and Unicode FAQ. + +\section _license License +The json-cpp library and this documentation are in Public Domain. + +\author Baptiste Lepilleur +*/ diff --git a/src/jsoncpp/doc/readme.txt b/src/jsoncpp/doc/readme.txt new file mode 100644 index 0000000000..0e42cdfb4c --- /dev/null +++ b/src/jsoncpp/doc/readme.txt @@ -0,0 +1 @@ +The documentation is generated using doxygen (http://www.doxygen.org). diff --git a/src/jsoncpp/doc/roadmap.dox b/src/jsoncpp/doc/roadmap.dox new file mode 100644 index 0000000000..7f3aa1af8c --- /dev/null +++ b/src/jsoncpp/doc/roadmap.dox @@ -0,0 +1,32 @@ +/*! \page roadmap JsonCpp roadmap + \section ms_release Makes JsonCpp ready for release + - Build system clean-up: + - Fix build on Windows (shared-library build is broken) + - Add enable/disable flag for static and shared library build + - Enhance help + - Platform portability check: (Notes: was ok on last check) + - linux/gcc, + - solaris/cc, + - windows/msvc678, + - aix/vacpp + - Add JsonCpp version to header as numeric for use in preprocessor test + - Remove buggy experimental hash stuff + - Release on sourceforge download + \section ms_strict Adds a strict mode to reader/parser + Strict JSON support as specific in RFC 4627 (http://www.ietf.org/rfc/rfc4627.txt?number=4627). + - Enforce only object or array as root element + - Disable comment support + - Get jsonchecker failing tests to pass in strict mode + \section ms_separation Expose json reader/writer API that do not impose using Json::Value. + Some typical use-case involve an application specific structure to/from a JSON document. + - Event base parser to allow unserializing a Json document directly in datastructure instead of + using the intermediate Json::Value. + - "Stream" based parser to serialized a Json document without using Json::Value as input. + - Performance oriented parser/writer: + - Provides an event based parser. Should allow pulling & skipping events for ease of use. + - Provides a JSON document builder: fast only. + \section ms_perfo Performance tuning + - Provides support for static property name definition avoiding allocation + - Static property dictionnary can be provided to JSON reader + - Performance scenario & benchmarking +*/ diff --git a/src/jsoncpp/include/json/autolink.h b/src/jsoncpp/include/json/autolink.h new file mode 100644 index 0000000000..37c9258ed5 --- /dev/null +++ b/src/jsoncpp/include/json/autolink.h @@ -0,0 +1,19 @@ +#ifndef JSON_AUTOLINK_H_INCLUDED +# define JSON_AUTOLINK_H_INCLUDED + +# include "config.h" + +# ifdef JSON_IN_CPPTL +# include +# endif + +# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL) +# define CPPTL_AUTOLINK_NAME "json" +# undef CPPTL_AUTOLINK_DLL +# ifdef JSON_DLL +# define CPPTL_AUTOLINK_DLL +# endif +# include "autolink.h" +# endif + +#endif // JSON_AUTOLINK_H_INCLUDED diff --git a/src/jsoncpp/include/json/config.h b/src/jsoncpp/include/json/config.h new file mode 100644 index 0000000000..5d334cbc5e --- /dev/null +++ b/src/jsoncpp/include/json/config.h @@ -0,0 +1,43 @@ +#ifndef JSON_CONFIG_H_INCLUDED +# define JSON_CONFIG_H_INCLUDED + +/// If defined, indicates that json library is embedded in CppTL library. +//# define JSON_IN_CPPTL 1 + +/// If defined, indicates that json may leverage CppTL library +//# define JSON_USE_CPPTL 1 +/// If defined, indicates that cpptl vector based map should be used instead of std::map +/// as Value container. +//# define JSON_USE_CPPTL_SMALLMAP 1 +/// If defined, indicates that Json specific container should be used +/// (hash table & simple deque container with customizable allocator). +/// THIS FEATURE IS STILL EXPERIMENTAL! +//# define JSON_VALUE_USE_INTERNAL_MAP 1 +/// Force usage of standard new/malloc based allocator instead of memory pool based allocator. +/// The memory pools allocator used optimization (initializing Value and ValueInternalLink +/// as if it was a POD) that may cause some validation tool to report errors. +/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined. +//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1 + +/// If defined, indicates that Json use exception to report invalid type manipulation +/// instead of C assert macro. +# define JSON_USE_EXCEPTION 1 + +# ifdef JSON_IN_CPPTL +# include +# ifndef JSON_USE_CPPTL +# define JSON_USE_CPPTL 1 +# endif +# endif + +# ifdef JSON_IN_CPPTL +# define JSON_API CPPTL_API +# elif defined(JSON_DLL_BUILD) +# define JSON_API __declspec(dllexport) +# elif defined(JSON_DLL) +# define JSON_API __declspec(dllimport) +# else +# define JSON_API +# endif + +#endif // JSON_CONFIG_H_INCLUDED diff --git a/src/jsoncpp/include/json/features.h b/src/jsoncpp/include/json/features.h new file mode 100644 index 0000000000..5a9adec118 --- /dev/null +++ b/src/jsoncpp/include/json/features.h @@ -0,0 +1,42 @@ +#ifndef CPPTL_JSON_FEATURES_H_INCLUDED +# define CPPTL_JSON_FEATURES_H_INCLUDED + +# include "forwards.h" + +namespace Json { + + /** \brief Configuration passed to reader and writer. + * This configuration object can be used to force the Reader or Writer + * to behave in a standard conforming way. + */ + class JSON_API Features + { + public: + /** \brief A configuration that allows all features and assumes all strings are UTF-8. + * - C & C++ comments are allowed + * - Root object can be any JSON value + * - Assumes Value strings are encoded in UTF-8 + */ + static Features all(); + + /** \brief A configuration that is strictly compatible with the JSON specification. + * - Comments are forbidden. + * - Root object must be either an array or an object value. + * - Assumes Value strings are encoded in UTF-8 + */ + static Features strictMode(); + + /** \brief Initialize the configuration like JsonConfig::allFeatures; + */ + Features(); + + /// \c true if comments are allowed. Default: \c true. + bool allowComments_; + + /// \c true if root must be either an array or an object value. Default: \c false. + bool strictRoot_; + }; + +} // namespace Json + +#endif // CPPTL_JSON_FEATURES_H_INCLUDED diff --git a/src/jsoncpp/include/json/forwards.h b/src/jsoncpp/include/json/forwards.h new file mode 100644 index 0000000000..d0ce8300ce --- /dev/null +++ b/src/jsoncpp/include/json/forwards.h @@ -0,0 +1,39 @@ +#ifndef JSON_FORWARDS_H_INCLUDED +# define JSON_FORWARDS_H_INCLUDED + +# include "config.h" + +namespace Json { + + // writer.h + class FastWriter; + class StyledWriter; + + // reader.h + class Reader; + + // features.h + class Features; + + // value.h + typedef int Int; + typedef unsigned int UInt; + class StaticString; + class Path; + class PathArgument; + class Value; + class ValueIteratorBase; + class ValueIterator; + class ValueConstIterator; +#ifdef JSON_VALUE_USE_INTERNAL_MAP + class ValueAllocator; + class ValueMapAllocator; + class ValueInternalLink; + class ValueInternalArray; + class ValueInternalMap; +#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP + +} // namespace Json + + +#endif // JSON_FORWARDS_H_INCLUDED diff --git a/src/jsoncpp/include/json/json.h b/src/jsoncpp/include/json/json.h new file mode 100644 index 0000000000..c71ed65abf --- /dev/null +++ b/src/jsoncpp/include/json/json.h @@ -0,0 +1,10 @@ +#ifndef JSON_JSON_H_INCLUDED +# define JSON_JSON_H_INCLUDED + +# include "autolink.h" +# include "value.h" +# include "reader.h" +# include "writer.h" +# include "features.h" + +#endif // JSON_JSON_H_INCLUDED diff --git a/src/jsoncpp/include/json/reader.h b/src/jsoncpp/include/json/reader.h new file mode 100644 index 0000000000..ee1d6a2444 --- /dev/null +++ b/src/jsoncpp/include/json/reader.h @@ -0,0 +1,196 @@ +#ifndef CPPTL_JSON_READER_H_INCLUDED +# define CPPTL_JSON_READER_H_INCLUDED + +# include "features.h" +# include "value.h" +# include +# include +# include +# include + +namespace Json { + + /** \brief Unserialize a JSON document into a Value. + * + */ + class JSON_API Reader + { + public: + typedef char Char; + typedef const Char *Location; + + /** \brief Constructs a Reader allowing all features + * for parsing. + */ + Reader(); + + /** \brief Constructs a Reader allowing the specified feature set + * for parsing. + */ + Reader( const Features &features ); + + /** \brief Read a Value from a JSON document. + * \param document UTF-8 encoded string containing the document to read. + * \param root [out] Contains the root value of the document if it was + * successfully parsed. + * \param collectComments \c true to collect comment and allow writing them back during + * serialization, \c false to discard comments. + * This parameter is ignored if Features::allowComments_ + * is \c false. + * \return \c true if the document was successfully parsed, \c false if an error occurred. + */ + bool parse( const std::string &document, + Value &root, + bool collectComments = true ); + + /** \brief Read a Value from a JSON document. + * \param document UTF-8 encoded string containing the document to read. + * \param root [out] Contains the root value of the document if it was + * successfully parsed. + * \param collectComments \c true to collect comment and allow writing them back during + * serialization, \c false to discard comments. + * This parameter is ignored if Features::allowComments_ + * is \c false. + * \return \c true if the document was successfully parsed, \c false if an error occurred. + */ + bool parse( const char *beginDoc, const char *endDoc, + Value &root, + bool collectComments = true ); + + /// \brief Parse from input stream. + /// \see Json::operator>>(std::istream&, Json::Value&). + bool parse( std::istream &is, + Value &root, + bool collectComments = true ); + + /** \brief Returns a user friendly string that list errors in the parsed document. + * \return Formatted error message with the list of errors with their location in + * the parsed document. An empty string is returned if no error occurred + * during parsing. + */ + std::string getFormatedErrorMessages() const; + + private: + enum TokenType + { + tokenEndOfStream = 0, + tokenObjectBegin, + tokenObjectEnd, + tokenArrayBegin, + tokenArrayEnd, + tokenString, + tokenNumber, + tokenTrue, + tokenFalse, + tokenNull, + tokenArraySeparator, + tokenMemberSeparator, + tokenComment, + tokenError + }; + + class Token + { + public: + TokenType type_; + Location start_; + Location end_; + }; + + class ErrorInfo + { + public: + Token token_; + std::string message_; + Location extra_; + }; + + typedef std::deque Errors; + + bool expectToken( TokenType type, Token &token, const char *message ); + bool readToken( Token &token ); + void skipSpaces(); + bool match( Location pattern, + int patternLength ); + bool readComment(); + bool readCStyleComment(); + bool readCppStyleComment(); + bool readString(); + void readNumber(); + bool readValue(); + bool readObject( Token &token ); + bool readArray( Token &token ); + bool decodeNumber( Token &token ); + bool decodeString( Token &token ); + bool decodeString( Token &token, std::string &decoded ); + bool decodeDouble( Token &token ); + bool decodeUnicodeCodePoint( Token &token, + Location ¤t, + Location end, + unsigned int &unicode ); + bool decodeUnicodeEscapeSequence( Token &token, + Location ¤t, + Location end, + unsigned int &unicode ); + bool addError( const std::string &message, + Token &token, + Location extra = 0 ); + bool recoverFromError( TokenType skipUntilToken ); + bool addErrorAndRecover( const std::string &message, + Token &token, + TokenType skipUntilToken ); + void skipUntilSpace(); + Value ¤tValue(); + Char getNextChar(); + void getLocationLineAndColumn( Location location, + int &line, + int &column ) const; + std::string getLocationLineAndColumn( Location location ) const; + void addComment( Location begin, + Location end, + CommentPlacement placement ); + void skipCommentTokens( Token &token ); + + typedef std::stack Nodes; + Nodes nodes_; + Errors errors_; + std::string document_; + Location begin_; + Location end_; + Location current_; + Location lastValueEnd_; + Value *lastValue_; + std::string commentsBefore_; + Features features_; + bool collectComments_; + }; + + /** \brief Read from 'sin' into 'root'. + + Always keep comments from the input JSON. + + This can be used to read a file into a particular sub-object. + For example: + \code + Json::Value root; + cin >> root["dir"]["file"]; + cout << root; + \endcode + Result: + \verbatim + { + "dir": { + "file": { + // The input stream JSON would be nested here. + } + } + } + \endverbatim + \throw std::exception on parse error. + \see Json::operator<<() + */ + std::istream& operator>>( std::istream&, Value& ); + +} // namespace Json + +#endif // CPPTL_JSON_READER_H_INCLUDED diff --git a/src/jsoncpp/include/json/value.h b/src/jsoncpp/include/json/value.h new file mode 100644 index 0000000000..58bfd88e7a --- /dev/null +++ b/src/jsoncpp/include/json/value.h @@ -0,0 +1,1069 @@ +#ifndef CPPTL_JSON_H_INCLUDED +# define CPPTL_JSON_H_INCLUDED + +# include "forwards.h" +# include +# include + +# ifndef JSON_USE_CPPTL_SMALLMAP +# include +# else +# include +# endif +# ifdef JSON_USE_CPPTL +# include +# endif + +/** \brief JSON (JavaScript Object Notation). + */ +namespace Json { + + /** \brief Type of the value held by a Value object. + */ + enum ValueType + { + nullValue = 0, ///< 'null' value + intValue, ///< signed integer value + uintValue, ///< unsigned integer value + realValue, ///< double value + stringValue, ///< UTF-8 string value + booleanValue, ///< bool value + arrayValue, ///< array value (ordered list) + objectValue ///< object value (collection of name/value pairs). + }; + + enum CommentPlacement + { + commentBefore = 0, ///< a comment placed on the line before a value + commentAfterOnSameLine, ///< a comment just after a value on the same line + commentAfter, ///< a comment on the line after a value (only make sense for root value) + numberOfCommentPlacement + }; + +//# ifdef JSON_USE_CPPTL +// typedef CppTL::AnyEnumerator EnumMemberNames; +// typedef CppTL::AnyEnumerator EnumValues; +//# endif + + /** \brief Lightweight wrapper to tag static string. + * + * Value constructor and objectValue member assignement takes advantage of the + * StaticString and avoid the cost of string duplication when storing the + * string or the member name. + * + * Example of usage: + * \code + * Json::Value aValue( StaticString("some text") ); + * Json::Value object; + * static const StaticString code("code"); + * object[code] = 1234; + * \endcode + */ + class JSON_API StaticString + { + public: + explicit StaticString( const char *czstring ) + : str_( czstring ) + { + } + + operator const char *() const + { + return str_; + } + + const char *c_str() const + { + return str_; + } + + private: + const char *str_; + }; + + /** \brief Represents a JSON value. + * + * This class is a discriminated union wrapper that can represents a: + * - signed integer [range: Value::minInt - Value::maxInt] + * - unsigned integer (range: 0 - Value::maxUInt) + * - double + * - UTF-8 string + * - boolean + * - 'null' + * - an ordered list of Value + * - collection of name/value pairs (javascript object) + * + * The type of the held value is represented by a #ValueType and + * can be obtained using type(). + * + * values of an #objectValue or #arrayValue can be accessed using operator[]() methods. + * Non const methods will automatically create the a #nullValue element + * if it does not exist. + * The sequence of an #arrayValue will be automatically resize and initialized + * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue. + * + * The get() methods can be used to obtanis default value in the case the required element + * does not exist. + * + * It is possible to iterate over the list of a #objectValue values using + * the getMemberNames() method. + */ + class JSON_API Value + { + friend class ValueIteratorBase; +# ifdef JSON_VALUE_USE_INTERNAL_MAP + friend class ValueInternalLink; + friend class ValueInternalMap; +# endif + public: + typedef std::vector Members; + typedef ValueIterator iterator; + typedef ValueConstIterator const_iterator; + typedef Json::UInt UInt; + typedef Json::Int Int; + typedef UInt ArrayIndex; + + static const Value null; + static const Int minInt; + static const Int maxInt; + static const UInt maxUInt; + + private: +#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION +# ifndef JSON_VALUE_USE_INTERNAL_MAP + class CZString + { + public: + enum DuplicationPolicy + { + noDuplication = 0, + duplicate, + duplicateOnCopy + }; + CZString( int index ); + CZString( const char *cstr, DuplicationPolicy allocate ); + CZString( const CZString &other ); + ~CZString(); + CZString &operator =( const CZString &other ); + bool operator<( const CZString &other ) const; + bool operator==( const CZString &other ) const; + int index() const; + const char *c_str() const; + bool isStaticString() const; + private: + void swap( CZString &other ); + const char *cstr_; + int index_; + }; + + public: +# ifndef JSON_USE_CPPTL_SMALLMAP + typedef std::map ObjectValues; +# else + typedef CppTL::SmallMap ObjectValues; +# endif // ifndef JSON_USE_CPPTL_SMALLMAP +# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP +#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + + public: + /** \brief Create a default Value of the given type. + + This is a very useful constructor. + To create an empty array, pass arrayValue. + To create an empty object, pass objectValue. + Another Value can then be set to this one by assignment. + This is useful since clear() and resize() will not alter types. + + Examples: + \code + Json::Value null_value; // null + Json::Value arr_value(Json::arrayValue); // [] + Json::Value obj_value(Json::objectValue); // {} + \endcode + */ + Value( ValueType type = nullValue ); + Value( Int value ); + Value( UInt value ); + Value( double value ); + Value( const char *value ); + Value( const char *beginValue, const char *endValue ); + /** \brief Constructs a value from a static string. + + * Like other value string constructor but do not duplicate the string for + * internal storage. The given string must remain alive after the call to this + * constructor. + * Example of usage: + * \code + * Json::Value aValue( StaticString("some text") ); + * \endcode + */ + Value( const StaticString &value ); + Value( const std::string &value ); +# ifdef JSON_USE_CPPTL + Value( const CppTL::ConstString &value ); +# endif + Value( bool value ); + Value( const Value &other ); + ~Value(); + + Value &operator=( const Value &other ); + /// Swap values. + /// \note Currently, comments are intentionally not swapped, for + /// both logic and efficiency. + void swap( Value &other ); + + ValueType type() const; + + bool operator <( const Value &other ) const; + bool operator <=( const Value &other ) const; + bool operator >=( const Value &other ) const; + bool operator >( const Value &other ) const; + + bool operator ==( const Value &other ) const; + bool operator !=( const Value &other ) const; + + int compare( const Value &other ); + + const char *asCString() const; + std::string asString() const; +# ifdef JSON_USE_CPPTL + CppTL::ConstString asConstString() const; +# endif + Int asInt() const; + UInt asUInt() const; + double asDouble() const; + bool asBool() const; + + bool isNull() const; + bool isBool() const; + bool isInt() const; + bool isUInt() const; + bool isIntegral() const; + bool isDouble() const; + bool isNumeric() const; + bool isString() const; + bool isArray() const; + bool isObject() const; + + bool isConvertibleTo( ValueType other ) const; + + /// Number of values in array or object + UInt size() const; + + /// \brief Return true if empty array, empty object, or null; + /// otherwise, false. + bool empty() const; + + /// Return isNull() + bool operator!() const; + + /// Remove all object members and array elements. + /// \pre type() is arrayValue, objectValue, or nullValue + /// \post type() is unchanged + void clear(); + + /// Resize the array to size elements. + /// New elements are initialized to null. + /// May only be called on nullValue or arrayValue. + /// \pre type() is arrayValue or nullValue + /// \post type() is arrayValue + void resize( UInt size ); + + /// Access an array element (zero based index ). + /// If the array contains less than index element, then null value are inserted + /// in the array so that its size is index+1. + /// (You may need to say 'value[0u]' to get your compiler to distinguish + /// this from the operator[] which takes a string.) + Value &operator[]( UInt index ); + /// Access an array element (zero based index ) + /// (You may need to say 'value[0u]' to get your compiler to distinguish + /// this from the operator[] which takes a string.) + const Value &operator[]( UInt index ) const; + /// If the array contains at least index+1 elements, returns the element value, + /// otherwise returns defaultValue. + Value get( UInt index, + const Value &defaultValue ) const; + /// Return true if index < size(). + bool isValidIndex( UInt index ) const; + /// \brief Append value to array at the end. + /// + /// Equivalent to jsonvalue[jsonvalue.size()] = value; + Value &append( const Value &value ); + + /// Access an object value by name, create a null member if it does not exist. + Value &operator[]( const char *key ); + /// Access an object value by name, returns null if there is no member with that name. + const Value &operator[]( const char *key ) const; + /// Access an object value by name, create a null member if it does not exist. + Value &operator[]( const std::string &key ); + /// Access an object value by name, returns null if there is no member with that name. + const Value &operator[]( const std::string &key ) const; + /** \brief Access an object value by name, create a null member if it does not exist. + + * If the object as no entry for that name, then the member name used to store + * the new entry is not duplicated. + * Example of use: + * \code + * Json::Value object; + * static const StaticString code("code"); + * object[code] = 1234; + * \endcode + */ + Value &operator[]( const StaticString &key ); +# ifdef JSON_USE_CPPTL + /// Access an object value by name, create a null member if it does not exist. + Value &operator[]( const CppTL::ConstString &key ); + /// Access an object value by name, returns null if there is no member with that name. + const Value &operator[]( const CppTL::ConstString &key ) const; +# endif + /// Return the member named key if it exist, defaultValue otherwise. + Value get( const char *key, + const Value &defaultValue ) const; + /// Return the member named key if it exist, defaultValue otherwise. + Value get( const std::string &key, + const Value &defaultValue ) const; +# ifdef JSON_USE_CPPTL + /// Return the member named key if it exist, defaultValue otherwise. + Value get( const CppTL::ConstString &key, + const Value &defaultValue ) const; +# endif + /// \brief Remove and return the named member. + /// + /// Do nothing if it did not exist. + /// \return the removed Value, or null. + /// \pre type() is objectValue or nullValue + /// \post type() is unchanged + Value removeMember( const char* key ); + /// Same as removeMember(const char*) + Value removeMember( const std::string &key ); + + /// Return true if the object has a member named key. + bool isMember( const char *key ) const; + /// Return true if the object has a member named key. + bool isMember( const std::string &key ) const; +# ifdef JSON_USE_CPPTL + /// Return true if the object has a member named key. + bool isMember( const CppTL::ConstString &key ) const; +# endif + + /// \brief Return a list of the member names. + /// + /// If null, return an empty list. + /// \pre type() is objectValue or nullValue + /// \post if type() was nullValue, it remains nullValue + Members getMemberNames() const; + +//# ifdef JSON_USE_CPPTL +// EnumMemberNames enumMemberNames() const; +// EnumValues enumValues() const; +//# endif + + /// Comments must be //... or /* ... */ + void setComment( const char *comment, + CommentPlacement placement ); + /// Comments must be //... or /* ... */ + void setComment( const std::string &comment, + CommentPlacement placement ); + bool hasComment( CommentPlacement placement ) const; + /// Include delimiters and embedded newlines. + std::string getComment( CommentPlacement placement ) const; + + std::string toStyledString() const; + + const_iterator begin() const; + const_iterator end() const; + + iterator begin(); + iterator end(); + + private: + Value &resolveReference( const char *key, + bool isStatic ); + +# ifdef JSON_VALUE_USE_INTERNAL_MAP + inline bool isItemAvailable() const + { + return itemIsUsed_ == 0; + } + + inline void setItemUsed( bool isUsed = true ) + { + itemIsUsed_ = isUsed ? 1 : 0; + } + + inline bool isMemberNameStatic() const + { + return memberNameIsStatic_ == 0; + } + + inline void setMemberNameIsStatic( bool isStatic ) + { + memberNameIsStatic_ = isStatic ? 1 : 0; + } +# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP + + private: + struct CommentInfo + { + CommentInfo(); + ~CommentInfo(); + + void setComment( const char *text ); + + char *comment_; + }; + + //struct MemberNamesTransform + //{ + // typedef const char *result_type; + // const char *operator()( const CZString &name ) const + // { + // return name.c_str(); + // } + //}; + + union ValueHolder + { + Int int_; + UInt uint_; + double real_; + bool bool_; + char *string_; +# ifdef JSON_VALUE_USE_INTERNAL_MAP + ValueInternalArray *array_; + ValueInternalMap *map_; +#else + ObjectValues *map_; +# endif + } value_; + ValueType type_ : 8; + int allocated_ : 1; // Notes: if declared as bool, bitfield is useless. +# ifdef JSON_VALUE_USE_INTERNAL_MAP + unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container. + int memberNameIsStatic_ : 1; // used by the ValueInternalMap container. +# endif + CommentInfo *comments_; + }; + + + /** \brief Experimental and untested: represents an element of the "path" to access a node. + */ + class PathArgument + { + public: + friend class Path; + + PathArgument(); + PathArgument( UInt index ); + PathArgument( const char *key ); + PathArgument( const std::string &key ); + + private: + enum Kind + { + kindNone = 0, + kindIndex, + kindKey + }; + std::string key_; + UInt index_; + Kind kind_; + }; + + /** \brief Experimental and untested: represents a "path" to access a node. + * + * Syntax: + * - "." => root node + * - ".[n]" => elements at index 'n' of root node (an array value) + * - ".name" => member named 'name' of root node (an object value) + * - ".name1.name2.name3" + * - ".[0][1][2].name1[3]" + * - ".%" => member name is provided as parameter + * - ".[%]" => index is provied as parameter + */ + class Path + { + public: + Path( const std::string &path, + const PathArgument &a1 = PathArgument(), + const PathArgument &a2 = PathArgument(), + const PathArgument &a3 = PathArgument(), + const PathArgument &a4 = PathArgument(), + const PathArgument &a5 = PathArgument() ); + + const Value &resolve( const Value &root ) const; + Value resolve( const Value &root, + const Value &defaultValue ) const; + /// Creates the "path" to access the specified node and returns a reference on the node. + Value &make( Value &root ) const; + + private: + typedef std::vector InArgs; + typedef std::vector Args; + + void makePath( const std::string &path, + const InArgs &in ); + void addPathInArg( const std::string &path, + const InArgs &in, + InArgs::const_iterator &itInArg, + PathArgument::Kind kind ); + void invalidPath( const std::string &path, + int location ); + + Args args_; + }; + + /** \brief Experimental do not use: Allocator to customize member name and string value memory management done by Value. + * + * - makeMemberName() and releaseMemberName() are called to respectively duplicate and + * free an Json::objectValue member name. + * - duplicateStringValue() and releaseStringValue() are called similarly to + * duplicate and free a Json::stringValue value. + */ + class ValueAllocator + { + public: + enum { unknown = (unsigned)-1 }; + + virtual ~ValueAllocator(); + + virtual char *makeMemberName( const char *memberName ) = 0; + virtual void releaseMemberName( char *memberName ) = 0; + virtual char *duplicateStringValue( const char *value, + unsigned int length = unknown ) = 0; + virtual void releaseStringValue( char *value ) = 0; + }; + +#ifdef JSON_VALUE_USE_INTERNAL_MAP + /** \brief Allocator to customize Value internal map. + * Below is an example of a simple implementation (default implementation actually + * use memory pool for speed). + * \code + class DefaultValueMapAllocator : public ValueMapAllocator + { + public: // overridden from ValueMapAllocator + virtual ValueInternalMap *newMap() + { + return new ValueInternalMap(); + } + + virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) + { + return new ValueInternalMap( other ); + } + + virtual void destructMap( ValueInternalMap *map ) + { + delete map; + } + + virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) + { + return new ValueInternalLink[size]; + } + + virtual void releaseMapBuckets( ValueInternalLink *links ) + { + delete [] links; + } + + virtual ValueInternalLink *allocateMapLink() + { + return new ValueInternalLink(); + } + + virtual void releaseMapLink( ValueInternalLink *link ) + { + delete link; + } + }; + * \endcode + */ + class JSON_API ValueMapAllocator + { + public: + virtual ~ValueMapAllocator(); + virtual ValueInternalMap *newMap() = 0; + virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0; + virtual void destructMap( ValueInternalMap *map ) = 0; + virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0; + virtual void releaseMapBuckets( ValueInternalLink *links ) = 0; + virtual ValueInternalLink *allocateMapLink() = 0; + virtual void releaseMapLink( ValueInternalLink *link ) = 0; + }; + + /** \brief ValueInternalMap hash-map bucket chain link (for internal use only). + * \internal previous_ & next_ allows for bidirectional traversal. + */ + class JSON_API ValueInternalLink + { + public: + enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture. + enum InternalFlags { + flagAvailable = 0, + flagUsed = 1 + }; + + ValueInternalLink(); + + ~ValueInternalLink(); + + Value items_[itemPerLink]; + char *keys_[itemPerLink]; + ValueInternalLink *previous_; + ValueInternalLink *next_; + }; + + + /** \brief A linked page based hash-table implementation used internally by Value. + * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked + * list in each bucket to handle collision. There is an addional twist in that + * each node of the collision linked list is a page containing a fixed amount of + * value. This provides a better compromise between memory usage and speed. + * + * Each bucket is made up of a chained list of ValueInternalLink. The last + * link of a given bucket can be found in the 'previous_' field of the following bucket. + * The last link of the last bucket is stored in tailLink_ as it has no following bucket. + * Only the last link of a bucket may contains 'available' item. The last link always + * contains at least one element unless is it the bucket one very first link. + */ + class JSON_API ValueInternalMap + { + friend class ValueIteratorBase; + friend class Value; + public: + typedef unsigned int HashKey; + typedef unsigned int BucketIndex; + +# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + struct IteratorState + { + IteratorState() + : map_(0) + , link_(0) + , itemIndex_(0) + , bucketIndex_(0) + { + } + ValueInternalMap *map_; + ValueInternalLink *link_; + BucketIndex itemIndex_; + BucketIndex bucketIndex_; + }; +# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + + ValueInternalMap(); + ValueInternalMap( const ValueInternalMap &other ); + ValueInternalMap &operator =( const ValueInternalMap &other ); + ~ValueInternalMap(); + + void swap( ValueInternalMap &other ); + + BucketIndex size() const; + + void clear(); + + bool reserveDelta( BucketIndex growth ); + + bool reserve( BucketIndex newItemCount ); + + const Value *find( const char *key ) const; + + Value *find( const char *key ); + + Value &resolveReference( const char *key, + bool isStatic ); + + void remove( const char *key ); + + void doActualRemove( ValueInternalLink *link, + BucketIndex index, + BucketIndex bucketIndex ); + + ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex ); + + Value &setNewItem( const char *key, + bool isStatic, + ValueInternalLink *link, + BucketIndex index ); + + Value &unsafeAdd( const char *key, + bool isStatic, + HashKey hashedKey ); + + HashKey hash( const char *key ) const; + + int compare( const ValueInternalMap &other ) const; + + private: + void makeBeginIterator( IteratorState &it ) const; + void makeEndIterator( IteratorState &it ) const; + static bool equals( const IteratorState &x, const IteratorState &other ); + static void increment( IteratorState &iterator ); + static void incrementBucket( IteratorState &iterator ); + static void decrement( IteratorState &iterator ); + static const char *key( const IteratorState &iterator ); + static const char *key( const IteratorState &iterator, bool &isStatic ); + static Value &value( const IteratorState &iterator ); + static int distance( const IteratorState &x, const IteratorState &y ); + + private: + ValueInternalLink *buckets_; + ValueInternalLink *tailLink_; + BucketIndex bucketsSize_; + BucketIndex itemCount_; + }; + + /** \brief A simplified deque implementation used internally by Value. + * \internal + * It is based on a list of fixed "page", each page contains a fixed number of items. + * Instead of using a linked-list, a array of pointer is used for fast item look-up. + * Look-up for an element is as follow: + * - compute page index: pageIndex = itemIndex / itemsPerPage + * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage] + * + * Insertion is amortized constant time (only the array containing the index of pointers + * need to be reallocated when items are appended). + */ + class JSON_API ValueInternalArray + { + friend class Value; + friend class ValueIteratorBase; + public: + enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo. + typedef Value::ArrayIndex ArrayIndex; + typedef unsigned int PageIndex; + +# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + struct IteratorState // Must be a POD + { + IteratorState() + : array_(0) + , currentPageIndex_(0) + , currentItemIndex_(0) + { + } + ValueInternalArray *array_; + Value **currentPageIndex_; + unsigned int currentItemIndex_; + }; +# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + + ValueInternalArray(); + ValueInternalArray( const ValueInternalArray &other ); + ValueInternalArray &operator =( const ValueInternalArray &other ); + ~ValueInternalArray(); + void swap( ValueInternalArray &other ); + + void clear(); + void resize( ArrayIndex newSize ); + + Value &resolveReference( ArrayIndex index ); + + Value *find( ArrayIndex index ) const; + + ArrayIndex size() const; + + int compare( const ValueInternalArray &other ) const; + + private: + static bool equals( const IteratorState &x, const IteratorState &other ); + static void increment( IteratorState &iterator ); + static void decrement( IteratorState &iterator ); + static Value &dereference( const IteratorState &iterator ); + static Value &unsafeDereference( const IteratorState &iterator ); + static int distance( const IteratorState &x, const IteratorState &y ); + static ArrayIndex indexOf( const IteratorState &iterator ); + void makeBeginIterator( IteratorState &it ) const; + void makeEndIterator( IteratorState &it ) const; + void makeIterator( IteratorState &it, ArrayIndex index ) const; + + void makeIndexValid( ArrayIndex index ); + + Value **pages_; + ArrayIndex size_; + PageIndex pageCount_; + }; + + /** \brief Experimental: do not use. Allocator to customize Value internal array. + * Below is an example of a simple implementation (actual implementation use + * memory pool). + \code +class DefaultValueArrayAllocator : public ValueArrayAllocator +{ +public: // overridden from ValueArrayAllocator + virtual ~DefaultValueArrayAllocator() + { + } + + virtual ValueInternalArray *newArray() + { + return new ValueInternalArray(); + } + + virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) + { + return new ValueInternalArray( other ); + } + + virtual void destruct( ValueInternalArray *array ) + { + delete array; + } + + virtual void reallocateArrayPageIndex( Value **&indexes, + ValueInternalArray::PageIndex &indexCount, + ValueInternalArray::PageIndex minNewIndexCount ) + { + ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; + if ( minNewIndexCount > newIndexCount ) + newIndexCount = minNewIndexCount; + void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); + if ( !newIndexes ) + throw std::bad_alloc(); + indexCount = newIndexCount; + indexes = static_cast( newIndexes ); + } + virtual void releaseArrayPageIndex( Value **indexes, + ValueInternalArray::PageIndex indexCount ) + { + if ( indexes ) + free( indexes ); + } + + virtual Value *allocateArrayPage() + { + return static_cast( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) ); + } + + virtual void releaseArrayPage( Value *value ) + { + if ( value ) + free( value ); + } +}; + \endcode + */ + class JSON_API ValueArrayAllocator + { + public: + virtual ~ValueArrayAllocator(); + virtual ValueInternalArray *newArray() = 0; + virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0; + virtual void destructArray( ValueInternalArray *array ) = 0; + /** \brief Reallocate array page index. + * Reallocates an array of pointer on each page. + * \param indexes [input] pointer on the current index. May be \c NULL. + * [output] pointer on the new index of at least + * \a minNewIndexCount pages. + * \param indexCount [input] current number of pages in the index. + * [output] number of page the reallocated index can handle. + * \b MUST be >= \a minNewIndexCount. + * \param minNewIndexCount Minimum number of page the new index must be able to + * handle. + */ + virtual void reallocateArrayPageIndex( Value **&indexes, + ValueInternalArray::PageIndex &indexCount, + ValueInternalArray::PageIndex minNewIndexCount ) = 0; + virtual void releaseArrayPageIndex( Value **indexes, + ValueInternalArray::PageIndex indexCount ) = 0; + virtual Value *allocateArrayPage() = 0; + virtual void releaseArrayPage( Value *value ) = 0; + }; +#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP + + + /** \brief base class for Value iterators. + * + */ + class ValueIteratorBase + { + public: + typedef unsigned int size_t; + typedef int difference_type; + typedef ValueIteratorBase SelfType; + + ValueIteratorBase(); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + explicit ValueIteratorBase( const Value::ObjectValues::iterator ¤t ); +#else + ValueIteratorBase( const ValueInternalArray::IteratorState &state ); + ValueIteratorBase( const ValueInternalMap::IteratorState &state ); +#endif + + bool operator ==( const SelfType &other ) const + { + return isEqual( other ); + } + + bool operator !=( const SelfType &other ) const + { + return !isEqual( other ); + } + + difference_type operator -( const SelfType &other ) const + { + return computeDistance( other ); + } + + /// Return either the index or the member name of the referenced value as a Value. + Value key() const; + + /// Return the index of the referenced Value. -1 if it is not an arrayValue. + UInt index() const; + + /// Return the member name of the referenced Value. "" if it is not an objectValue. + const char *memberName() const; + + protected: + Value &deref() const; + + void increment(); + + void decrement(); + + difference_type computeDistance( const SelfType &other ) const; + + bool isEqual( const SelfType &other ) const; + + void copy( const SelfType &other ); + + private: +#ifndef JSON_VALUE_USE_INTERNAL_MAP + Value::ObjectValues::iterator current_; + // Indicates that iterator is for a null value. + bool isNull_; +#else + union + { + ValueInternalArray::IteratorState array_; + ValueInternalMap::IteratorState map_; + } iterator_; + bool isArray_; +#endif + }; + + /** \brief const iterator for object and array value. + * + */ + class ValueConstIterator : public ValueIteratorBase + { + friend class Value; + public: + typedef unsigned int size_t; + typedef int difference_type; + typedef const Value &reference; + typedef const Value *pointer; + typedef ValueConstIterator SelfType; + + ValueConstIterator(); + private: + /*! \internal Use by Value to create an iterator. + */ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + explicit ValueConstIterator( const Value::ObjectValues::iterator ¤t ); +#else + ValueConstIterator( const ValueInternalArray::IteratorState &state ); + ValueConstIterator( const ValueInternalMap::IteratorState &state ); +#endif + public: + SelfType &operator =( const ValueIteratorBase &other ); + + SelfType operator++( int ) + { + SelfType temp( *this ); + ++*this; + return temp; + } + + SelfType operator--( int ) + { + SelfType temp( *this ); + --*this; + return temp; + } + + SelfType &operator--() + { + decrement(); + return *this; + } + + SelfType &operator++() + { + increment(); + return *this; + } + + reference operator *() const + { + return deref(); + } + }; + + + /** \brief Iterator for object and array value. + */ + class ValueIterator : public ValueIteratorBase + { + friend class Value; + public: + typedef unsigned int size_t; + typedef int difference_type; + typedef Value &reference; + typedef Value *pointer; + typedef ValueIterator SelfType; + + ValueIterator(); + ValueIterator( const ValueConstIterator &other ); + ValueIterator( const ValueIterator &other ); + private: + /*! \internal Use by Value to create an iterator. + */ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + explicit ValueIterator( const Value::ObjectValues::iterator ¤t ); +#else + ValueIterator( const ValueInternalArray::IteratorState &state ); + ValueIterator( const ValueInternalMap::IteratorState &state ); +#endif + public: + + SelfType &operator =( const SelfType &other ); + + SelfType operator++( int ) + { + SelfType temp( *this ); + ++*this; + return temp; + } + + SelfType operator--( int ) + { + SelfType temp( *this ); + --*this; + return temp; + } + + SelfType &operator--() + { + decrement(); + return *this; + } + + SelfType &operator++() + { + increment(); + return *this; + } + + reference operator *() const + { + return deref(); + } + }; + + +} // namespace Json + + +#endif // CPPTL_JSON_H_INCLUDED diff --git a/src/jsoncpp/include/json/writer.h b/src/jsoncpp/include/json/writer.h new file mode 100644 index 0000000000..5f4b83be41 --- /dev/null +++ b/src/jsoncpp/include/json/writer.h @@ -0,0 +1,174 @@ +#ifndef JSON_WRITER_H_INCLUDED +# define JSON_WRITER_H_INCLUDED + +# include "value.h" +# include +# include +# include + +namespace Json { + + class Value; + + /** \brief Abstract class for writers. + */ + class JSON_API Writer + { + public: + virtual ~Writer(); + + virtual std::string write( const Value &root ) = 0; + }; + + /** \brief Outputs a Value in JSON format without formatting (not human friendly). + * + * The JSON document is written in a single line. It is not intended for 'human' consumption, + * but may be usefull to support feature such as RPC where bandwith is limited. + * \sa Reader, Value + */ + class JSON_API FastWriter : public Writer + { + public: + FastWriter(); + virtual ~FastWriter(){} + + void enableYAMLCompatibility(); + + public: // overridden from Writer + virtual std::string write( const Value &root ); + + private: + void writeValue( const Value &value ); + + std::string document_; + bool yamlCompatiblityEnabled_; + }; + + /** \brief Writes a Value in JSON format in a human friendly way. + * + * The rules for line break and indent are as follow: + * - Object value: + * - if empty then print {} without indent and line break + * - if not empty the print '{', line break & indent, print one value per line + * and then unindent and line break and print '}'. + * - Array value: + * - if empty then print [] without indent and line break + * - if the array contains no object value, empty array or some other value types, + * and all the values fit on one lines, then print the array on a single line. + * - otherwise, it the values do not fit on one line, or the array contains + * object or non empty array, then print one value per line. + * + * If the Value have comments then they are outputed according to their #CommentPlacement. + * + * \sa Reader, Value, Value::setComment() + */ + class JSON_API StyledWriter: public Writer + { + public: + StyledWriter(); + virtual ~StyledWriter(){} + + public: // overridden from Writer + /** \brief Serialize a Value in JSON format. + * \param root Value to serialize. + * \return String containing the JSON document that represents the root value. + */ + virtual std::string write( const Value &root ); + + private: + void writeValue( const Value &value ); + void writeArrayValue( const Value &value ); + bool isMultineArray( const Value &value ); + void pushValue( const std::string &value ); + void writeIndent(); + void writeWithIndent( const std::string &value ); + void indent(); + void unindent(); + void writeCommentBeforeValue( const Value &root ); + void writeCommentAfterValueOnSameLine( const Value &root ); + bool hasCommentForValue( const Value &value ); + static std::string normalizeEOL( const std::string &text ); + + typedef std::vector ChildValues; + + ChildValues childValues_; + std::string document_; + std::string indentString_; + int rightMargin_; + int indentSize_; + bool addChildValues_; + }; + + /** \brief Writes a Value in JSON format in a human friendly way, + to a stream rather than to a string. + * + * The rules for line break and indent are as follow: + * - Object value: + * - if empty then print {} without indent and line break + * - if not empty the print '{', line break & indent, print one value per line + * and then unindent and line break and print '}'. + * - Array value: + * - if empty then print [] without indent and line break + * - if the array contains no object value, empty array or some other value types, + * and all the values fit on one lines, then print the array on a single line. + * - otherwise, it the values do not fit on one line, or the array contains + * object or non empty array, then print one value per line. + * + * If the Value have comments then they are outputed according to their #CommentPlacement. + * + * \param indentation Each level will be indented by this amount extra. + * \sa Reader, Value, Value::setComment() + */ + class JSON_API StyledStreamWriter + { + public: + StyledStreamWriter( std::string indentation="\t" ); + ~StyledStreamWriter(){} + + public: + /** \brief Serialize a Value in JSON format. + * \param out Stream to write to. (Can be ostringstream, e.g.) + * \param root Value to serialize. + * \note There is no point in deriving from Writer, since write() should not return a value. + */ + void write( std::ostream &out, const Value &root ); + + private: + void writeValue( const Value &value ); + void writeArrayValue( const Value &value ); + bool isMultineArray( const Value &value ); + void pushValue( const std::string &value ); + void writeIndent(); + void writeWithIndent( const std::string &value ); + void indent(); + void unindent(); + void writeCommentBeforeValue( const Value &root ); + void writeCommentAfterValueOnSameLine( const Value &root ); + bool hasCommentForValue( const Value &value ); + static std::string normalizeEOL( const std::string &text ); + + typedef std::vector ChildValues; + + ChildValues childValues_; + std::ostream* document_; + std::string indentString_; + int rightMargin_; + std::string indentation_; + bool addChildValues_; + }; + + std::string JSON_API valueToString( Int value ); + std::string JSON_API valueToString( UInt value ); + std::string JSON_API valueToString( double value ); + std::string JSON_API valueToString( bool value ); + std::string JSON_API valueToQuotedString( const char *value ); + + /// \brief Output using the StyledStreamWriter. + /// \see Json::operator>>() + std::ostream& operator<<( std::ostream&, const Value &root ); + +} // namespace Json + + + +#endif // JSON_WRITER_H_INCLUDED diff --git a/src/jsoncpp/src/lib_json/json_batchallocator.h b/src/jsoncpp/src/lib_json/json_batchallocator.h new file mode 100644 index 0000000000..87ea5ed807 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_batchallocator.h @@ -0,0 +1,125 @@ +#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED +# define JSONCPP_BATCHALLOCATOR_H_INCLUDED + +# include +# include + +# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION + +namespace Json { + +/* Fast memory allocator. + * + * This memory allocator allocates memory for a batch of object (specified by + * the page size, the number of object in each page). + * + * It does not allow the destruction of a single object. All the allocated objects + * can be destroyed at once. The memory can be either released or reused for future + * allocation. + * + * The in-place new operator must be used to construct the object using the pointer + * returned by allocate. + */ +template +class BatchAllocator +{ +public: + typedef AllocatedType Type; + + BatchAllocator( unsigned int objectsPerPage = 255 ) + : freeHead_( 0 ) + , objectsPerPage_( objectsPerPage ) + { +// printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() ); + assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space. + assert( objectsPerPage >= 16 ); + batches_ = allocateBatch( 0 ); // allocated a dummy page + currentBatch_ = batches_; + } + + ~BatchAllocator() + { + for ( BatchInfo *batch = batches_; batch; ) + { + BatchInfo *nextBatch = batch->next_; + free( batch ); + batch = nextBatch; + } + } + + /// allocate space for an array of objectPerAllocation object. + /// @warning it is the responsability of the caller to call objects constructors. + AllocatedType *allocate() + { + if ( freeHead_ ) // returns node from free list. + { + AllocatedType *object = freeHead_; + freeHead_ = *(AllocatedType **)object; + return object; + } + if ( currentBatch_->used_ == currentBatch_->end_ ) + { + currentBatch_ = currentBatch_->next_; + while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ ) + currentBatch_ = currentBatch_->next_; + + if ( !currentBatch_ ) // no free batch found, allocate a new one + { + currentBatch_ = allocateBatch( objectsPerPage_ ); + currentBatch_->next_ = batches_; // insert at the head of the list + batches_ = currentBatch_; + } + } + AllocatedType *allocated = currentBatch_->used_; + currentBatch_->used_ += objectPerAllocation; + return allocated; + } + + /// Release the object. + /// @warning it is the responsability of the caller to actually destruct the object. + void release( AllocatedType *object ) + { + assert( object != 0 ); + *(AllocatedType **)object = freeHead_; + freeHead_ = object; + } + +private: + struct BatchInfo + { + BatchInfo *next_; + AllocatedType *used_; + AllocatedType *end_; + AllocatedType buffer_[objectPerAllocation]; + }; + + // disabled copy constructor and assignement operator. + BatchAllocator( const BatchAllocator & ); + void operator =( const BatchAllocator &); + + static BatchInfo *allocateBatch( unsigned int objectsPerPage ) + { + const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation + + sizeof(AllocatedType) * objectPerAllocation * objectsPerPage; + BatchInfo *batch = static_cast( malloc( mallocSize ) ); + batch->next_ = 0; + batch->used_ = batch->buffer_; + batch->end_ = batch->buffer_ + objectsPerPage; + return batch; + } + + BatchInfo *batches_; + BatchInfo *currentBatch_; + /// Head of a single linked list within the allocated space of freeed object + AllocatedType *freeHead_; + unsigned int objectsPerPage_; +}; + + +} // namespace Json + +# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION + +#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED + diff --git a/src/jsoncpp/src/lib_json/json_internalarray.inl b/src/jsoncpp/src/lib_json/json_internalarray.inl new file mode 100644 index 0000000000..9b985d2585 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_internalarray.inl @@ -0,0 +1,448 @@ +// included by json_value.cpp +// everything is within Json namespace + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class ValueInternalArray +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +ValueArrayAllocator::~ValueArrayAllocator() +{ +} + +// ////////////////////////////////////////////////////////////////// +// class DefaultValueArrayAllocator +// ////////////////////////////////////////////////////////////////// +#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR +class DefaultValueArrayAllocator : public ValueArrayAllocator +{ +public: // overridden from ValueArrayAllocator + virtual ~DefaultValueArrayAllocator() + { + } + + virtual ValueInternalArray *newArray() + { + return new ValueInternalArray(); + } + + virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) + { + return new ValueInternalArray( other ); + } + + virtual void destructArray( ValueInternalArray *array ) + { + delete array; + } + + virtual void reallocateArrayPageIndex( Value **&indexes, + ValueInternalArray::PageIndex &indexCount, + ValueInternalArray::PageIndex minNewIndexCount ) + { + ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; + if ( minNewIndexCount > newIndexCount ) + newIndexCount = minNewIndexCount; + void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); + if ( !newIndexes ) + throw std::bad_alloc(); + indexCount = newIndexCount; + indexes = static_cast( newIndexes ); + } + virtual void releaseArrayPageIndex( Value **indexes, + ValueInternalArray::PageIndex indexCount ) + { + if ( indexes ) + free( indexes ); + } + + virtual Value *allocateArrayPage() + { + return static_cast( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) ); + } + + virtual void releaseArrayPage( Value *value ) + { + if ( value ) + free( value ); + } +}; + +#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR +/// @todo make this thread-safe (lock when accessign batch allocator) +class DefaultValueArrayAllocator : public ValueArrayAllocator +{ +public: // overridden from ValueArrayAllocator + virtual ~DefaultValueArrayAllocator() + { + } + + virtual ValueInternalArray *newArray() + { + ValueInternalArray *array = arraysAllocator_.allocate(); + new (array) ValueInternalArray(); // placement new + return array; + } + + virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) + { + ValueInternalArray *array = arraysAllocator_.allocate(); + new (array) ValueInternalArray( other ); // placement new + return array; + } + + virtual void destructArray( ValueInternalArray *array ) + { + if ( array ) + { + array->~ValueInternalArray(); + arraysAllocator_.release( array ); + } + } + + virtual void reallocateArrayPageIndex( Value **&indexes, + ValueInternalArray::PageIndex &indexCount, + ValueInternalArray::PageIndex minNewIndexCount ) + { + ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1; + if ( minNewIndexCount > newIndexCount ) + newIndexCount = minNewIndexCount; + void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount ); + if ( !newIndexes ) + throw std::bad_alloc(); + indexCount = newIndexCount; + indexes = static_cast( newIndexes ); + } + virtual void releaseArrayPageIndex( Value **indexes, + ValueInternalArray::PageIndex indexCount ) + { + if ( indexes ) + free( indexes ); + } + + virtual Value *allocateArrayPage() + { + return static_cast( pagesAllocator_.allocate() ); + } + + virtual void releaseArrayPage( Value *value ) + { + if ( value ) + pagesAllocator_.release( value ); + } +private: + BatchAllocator arraysAllocator_; + BatchAllocator pagesAllocator_; +}; +#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR + +static ValueArrayAllocator *&arrayAllocator() +{ + static DefaultValueArrayAllocator defaultAllocator; + static ValueArrayAllocator *arrayAllocator = &defaultAllocator; + return arrayAllocator; +} + +static struct DummyArrayAllocatorInitializer { + DummyArrayAllocatorInitializer() + { + arrayAllocator(); // ensure arrayAllocator() statics are initialized before main(). + } +} dummyArrayAllocatorInitializer; + +// ////////////////////////////////////////////////////////////////// +// class ValueInternalArray +// ////////////////////////////////////////////////////////////////// +bool +ValueInternalArray::equals( const IteratorState &x, + const IteratorState &other ) +{ + return x.array_ == other.array_ + && x.currentItemIndex_ == other.currentItemIndex_ + && x.currentPageIndex_ == other.currentPageIndex_; +} + + +void +ValueInternalArray::increment( IteratorState &it ) +{ + JSON_ASSERT_MESSAGE( it.array_ && + (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_ + != it.array_->size_, + "ValueInternalArray::increment(): moving iterator beyond end" ); + ++(it.currentItemIndex_); + if ( it.currentItemIndex_ == itemsPerPage ) + { + it.currentItemIndex_ = 0; + ++(it.currentPageIndex_); + } +} + + +void +ValueInternalArray::decrement( IteratorState &it ) +{ + JSON_ASSERT_MESSAGE( it.array_ && it.currentPageIndex_ == it.array_->pages_ + && it.currentItemIndex_ == 0, + "ValueInternalArray::decrement(): moving iterator beyond end" ); + if ( it.currentItemIndex_ == 0 ) + { + it.currentItemIndex_ = itemsPerPage-1; + --(it.currentPageIndex_); + } + else + { + --(it.currentItemIndex_); + } +} + + +Value & +ValueInternalArray::unsafeDereference( const IteratorState &it ) +{ + return (*(it.currentPageIndex_))[it.currentItemIndex_]; +} + + +Value & +ValueInternalArray::dereference( const IteratorState &it ) +{ + JSON_ASSERT_MESSAGE( it.array_ && + (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_ + < it.array_->size_, + "ValueInternalArray::dereference(): dereferencing invalid iterator" ); + return unsafeDereference( it ); +} + +void +ValueInternalArray::makeBeginIterator( IteratorState &it ) const +{ + it.array_ = const_cast( this ); + it.currentItemIndex_ = 0; + it.currentPageIndex_ = pages_; +} + + +void +ValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const +{ + it.array_ = const_cast( this ); + it.currentItemIndex_ = index % itemsPerPage; + it.currentPageIndex_ = pages_ + index / itemsPerPage; +} + + +void +ValueInternalArray::makeEndIterator( IteratorState &it ) const +{ + makeIterator( it, size_ ); +} + + +ValueInternalArray::ValueInternalArray() + : pages_( 0 ) + , size_( 0 ) + , pageCount_( 0 ) +{ +} + + +ValueInternalArray::ValueInternalArray( const ValueInternalArray &other ) + : pages_( 0 ) + , pageCount_( 0 ) + , size_( other.size_ ) +{ + PageIndex minNewPages = other.size_ / itemsPerPage; + arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages ); + JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, + "ValueInternalArray::reserve(): bad reallocation" ); + IteratorState itOther; + other.makeBeginIterator( itOther ); + Value *value; + for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) ) + { + if ( index % itemsPerPage == 0 ) + { + PageIndex pageIndex = index / itemsPerPage; + value = arrayAllocator()->allocateArrayPage(); + pages_[pageIndex] = value; + } + new (value) Value( dereference( itOther ) ); + } +} + + +ValueInternalArray & +ValueInternalArray::operator =( const ValueInternalArray &other ) +{ + ValueInternalArray temp( other ); + swap( temp ); + return *this; +} + + +ValueInternalArray::~ValueInternalArray() +{ + // destroy all constructed items + IteratorState it; + IteratorState itEnd; + makeBeginIterator( it); + makeEndIterator( itEnd ); + for ( ; !equals(it,itEnd); increment(it) ) + { + Value *value = &dereference(it); + value->~Value(); + } + // release all pages + PageIndex lastPageIndex = size_ / itemsPerPage; + for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex ) + arrayAllocator()->releaseArrayPage( pages_[pageIndex] ); + // release pages index + arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ ); +} + + +void +ValueInternalArray::swap( ValueInternalArray &other ) +{ + Value **tempPages = pages_; + pages_ = other.pages_; + other.pages_ = tempPages; + ArrayIndex tempSize = size_; + size_ = other.size_; + other.size_ = tempSize; + PageIndex tempPageCount = pageCount_; + pageCount_ = other.pageCount_; + other.pageCount_ = tempPageCount; +} + +void +ValueInternalArray::clear() +{ + ValueInternalArray dummy; + swap( dummy ); +} + + +void +ValueInternalArray::resize( ArrayIndex newSize ) +{ + if ( newSize == 0 ) + clear(); + else if ( newSize < size_ ) + { + IteratorState it; + IteratorState itEnd; + makeIterator( it, newSize ); + makeIterator( itEnd, size_ ); + for ( ; !equals(it,itEnd); increment(it) ) + { + Value *value = &dereference(it); + value->~Value(); + } + PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage; + PageIndex lastPageIndex = size_ / itemsPerPage; + for ( ; pageIndex < lastPageIndex; ++pageIndex ) + arrayAllocator()->releaseArrayPage( pages_[pageIndex] ); + size_ = newSize; + } + else if ( newSize > size_ ) + resolveReference( newSize ); +} + + +void +ValueInternalArray::makeIndexValid( ArrayIndex index ) +{ + // Need to enlarge page index ? + if ( index >= pageCount_ * itemsPerPage ) + { + PageIndex minNewPages = (index + 1) / itemsPerPage; + arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages ); + JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, "ValueInternalArray::reserve(): bad reallocation" ); + } + + // Need to allocate new pages ? + ArrayIndex nextPageIndex = + (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage + : size_; + if ( nextPageIndex <= index ) + { + PageIndex pageIndex = nextPageIndex / itemsPerPage; + PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1; + for ( ; pageToAllocate-- > 0; ++pageIndex ) + pages_[pageIndex] = arrayAllocator()->allocateArrayPage(); + } + + // Initialize all new entries + IteratorState it; + IteratorState itEnd; + makeIterator( it, size_ ); + size_ = index + 1; + makeIterator( itEnd, size_ ); + for ( ; !equals(it,itEnd); increment(it) ) + { + Value *value = &dereference(it); + new (value) Value(); // Construct a default value using placement new + } +} + +Value & +ValueInternalArray::resolveReference( ArrayIndex index ) +{ + if ( index >= size_ ) + makeIndexValid( index ); + return pages_[index/itemsPerPage][index%itemsPerPage]; +} + +Value * +ValueInternalArray::find( ArrayIndex index ) const +{ + if ( index >= size_ ) + return 0; + return &(pages_[index/itemsPerPage][index%itemsPerPage]); +} + +ValueInternalArray::ArrayIndex +ValueInternalArray::size() const +{ + return size_; +} + +int +ValueInternalArray::distance( const IteratorState &x, const IteratorState &y ) +{ + return indexOf(y) - indexOf(x); +} + + +ValueInternalArray::ArrayIndex +ValueInternalArray::indexOf( const IteratorState &iterator ) +{ + if ( !iterator.array_ ) + return ArrayIndex(-1); + return ArrayIndex( + (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage + + iterator.currentItemIndex_ ); +} + + +int +ValueInternalArray::compare( const ValueInternalArray &other ) const +{ + int sizeDiff( size_ - other.size_ ); + if ( sizeDiff != 0 ) + return sizeDiff; + + for ( ArrayIndex index =0; index < size_; ++index ) + { + int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( + other.pages_[index/itemsPerPage][index%itemsPerPage] ); + if ( diff != 0 ) + return diff; + } + return 0; +} diff --git a/src/jsoncpp/src/lib_json/json_internalmap.inl b/src/jsoncpp/src/lib_json/json_internalmap.inl new file mode 100644 index 0000000000..19771488d6 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_internalmap.inl @@ -0,0 +1,607 @@ +// included by json_value.cpp +// everything is within Json namespace + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class ValueInternalMap +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +/** \internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) ); + * This optimization is used by the fast allocator. + */ +ValueInternalLink::ValueInternalLink() + : previous_( 0 ) + , next_( 0 ) +{ +} + +ValueInternalLink::~ValueInternalLink() +{ + for ( int index =0; index < itemPerLink; ++index ) + { + if ( !items_[index].isItemAvailable() ) + { + if ( !items_[index].isMemberNameStatic() ) + free( keys_[index] ); + } + else + break; + } +} + + + +ValueMapAllocator::~ValueMapAllocator() +{ +} + +#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR +class DefaultValueMapAllocator : public ValueMapAllocator +{ +public: // overridden from ValueMapAllocator + virtual ValueInternalMap *newMap() + { + return new ValueInternalMap(); + } + + virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) + { + return new ValueInternalMap( other ); + } + + virtual void destructMap( ValueInternalMap *map ) + { + delete map; + } + + virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) + { + return new ValueInternalLink[size]; + } + + virtual void releaseMapBuckets( ValueInternalLink *links ) + { + delete [] links; + } + + virtual ValueInternalLink *allocateMapLink() + { + return new ValueInternalLink(); + } + + virtual void releaseMapLink( ValueInternalLink *link ) + { + delete link; + } +}; +#else +/// @todo make this thread-safe (lock when accessign batch allocator) +class DefaultValueMapAllocator : public ValueMapAllocator +{ +public: // overridden from ValueMapAllocator + virtual ValueInternalMap *newMap() + { + ValueInternalMap *map = mapsAllocator_.allocate(); + new (map) ValueInternalMap(); // placement new + return map; + } + + virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) + { + ValueInternalMap *map = mapsAllocator_.allocate(); + new (map) ValueInternalMap( other ); // placement new + return map; + } + + virtual void destructMap( ValueInternalMap *map ) + { + if ( map ) + { + map->~ValueInternalMap(); + mapsAllocator_.release( map ); + } + } + + virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) + { + return new ValueInternalLink[size]; + } + + virtual void releaseMapBuckets( ValueInternalLink *links ) + { + delete [] links; + } + + virtual ValueInternalLink *allocateMapLink() + { + ValueInternalLink *link = linksAllocator_.allocate(); + memset( link, 0, sizeof(ValueInternalLink) ); + return link; + } + + virtual void releaseMapLink( ValueInternalLink *link ) + { + link->~ValueInternalLink(); + linksAllocator_.release( link ); + } +private: + BatchAllocator mapsAllocator_; + BatchAllocator linksAllocator_; +}; +#endif + +static ValueMapAllocator *&mapAllocator() +{ + static DefaultValueMapAllocator defaultAllocator; + static ValueMapAllocator *mapAllocator = &defaultAllocator; + return mapAllocator; +} + +static struct DummyMapAllocatorInitializer { + DummyMapAllocatorInitializer() + { + mapAllocator(); // ensure mapAllocator() statics are initialized before main(). + } +} dummyMapAllocatorInitializer; + + + +// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32. + +/* +use linked list hash map. +buckets array is a container. +linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124) +value have extra state: valid, available, deleted +*/ + + +ValueInternalMap::ValueInternalMap() + : buckets_( 0 ) + , tailLink_( 0 ) + , bucketsSize_( 0 ) + , itemCount_( 0 ) +{ +} + + +ValueInternalMap::ValueInternalMap( const ValueInternalMap &other ) + : buckets_( 0 ) + , tailLink_( 0 ) + , bucketsSize_( 0 ) + , itemCount_( 0 ) +{ + reserve( other.itemCount_ ); + IteratorState it; + IteratorState itEnd; + other.makeBeginIterator( it ); + other.makeEndIterator( itEnd ); + for ( ; !equals(it,itEnd); increment(it) ) + { + bool isStatic; + const char *memberName = key( it, isStatic ); + const Value &aValue = value( it ); + resolveReference(memberName, isStatic) = aValue; + } +} + + +ValueInternalMap & +ValueInternalMap::operator =( const ValueInternalMap &other ) +{ + ValueInternalMap dummy( other ); + swap( dummy ); + return *this; +} + + +ValueInternalMap::~ValueInternalMap() +{ + if ( buckets_ ) + { + for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex ) + { + ValueInternalLink *link = buckets_[bucketIndex].next_; + while ( link ) + { + ValueInternalLink *linkToRelease = link; + link = link->next_; + mapAllocator()->releaseMapLink( linkToRelease ); + } + } + mapAllocator()->releaseMapBuckets( buckets_ ); + } +} + + +void +ValueInternalMap::swap( ValueInternalMap &other ) +{ + ValueInternalLink *tempBuckets = buckets_; + buckets_ = other.buckets_; + other.buckets_ = tempBuckets; + ValueInternalLink *tempTailLink = tailLink_; + tailLink_ = other.tailLink_; + other.tailLink_ = tempTailLink; + BucketIndex tempBucketsSize = bucketsSize_; + bucketsSize_ = other.bucketsSize_; + other.bucketsSize_ = tempBucketsSize; + BucketIndex tempItemCount = itemCount_; + itemCount_ = other.itemCount_; + other.itemCount_ = tempItemCount; +} + + +void +ValueInternalMap::clear() +{ + ValueInternalMap dummy; + swap( dummy ); +} + + +ValueInternalMap::BucketIndex +ValueInternalMap::size() const +{ + return itemCount_; +} + +bool +ValueInternalMap::reserveDelta( BucketIndex growth ) +{ + return reserve( itemCount_ + growth ); +} + +bool +ValueInternalMap::reserve( BucketIndex newItemCount ) +{ + if ( !buckets_ && newItemCount > 0 ) + { + buckets_ = mapAllocator()->allocateMapBuckets( 1 ); + bucketsSize_ = 1; + tailLink_ = &buckets_[0]; + } +// BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink; + return true; +} + + +const Value * +ValueInternalMap::find( const char *key ) const +{ + if ( !bucketsSize_ ) + return 0; + HashKey hashedKey = hash( key ); + BucketIndex bucketIndex = hashedKey % bucketsSize_; + for ( const ValueInternalLink *current = &buckets_[bucketIndex]; + current != 0; + current = current->next_ ) + { + for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index ) + { + if ( current->items_[index].isItemAvailable() ) + return 0; + if ( strcmp( key, current->keys_[index] ) == 0 ) + return ¤t->items_[index]; + } + } + return 0; +} + + +Value * +ValueInternalMap::find( const char *key ) +{ + const ValueInternalMap *constThis = this; + return const_cast( constThis->find( key ) ); +} + + +Value & +ValueInternalMap::resolveReference( const char *key, + bool isStatic ) +{ + HashKey hashedKey = hash( key ); + if ( bucketsSize_ ) + { + BucketIndex bucketIndex = hashedKey % bucketsSize_; + ValueInternalLink **previous = 0; + BucketIndex index; + for ( ValueInternalLink *current = &buckets_[bucketIndex]; + current != 0; + previous = ¤t->next_, current = current->next_ ) + { + for ( index=0; index < ValueInternalLink::itemPerLink; ++index ) + { + if ( current->items_[index].isItemAvailable() ) + return setNewItem( key, isStatic, current, index ); + if ( strcmp( key, current->keys_[index] ) == 0 ) + return current->items_[index]; + } + } + } + + reserveDelta( 1 ); + return unsafeAdd( key, isStatic, hashedKey ); +} + + +void +ValueInternalMap::remove( const char *key ) +{ + HashKey hashedKey = hash( key ); + if ( !bucketsSize_ ) + return; + BucketIndex bucketIndex = hashedKey % bucketsSize_; + for ( ValueInternalLink *link = &buckets_[bucketIndex]; + link != 0; + link = link->next_ ) + { + BucketIndex index; + for ( index =0; index < ValueInternalLink::itemPerLink; ++index ) + { + if ( link->items_[index].isItemAvailable() ) + return; + if ( strcmp( key, link->keys_[index] ) == 0 ) + { + doActualRemove( link, index, bucketIndex ); + return; + } + } + } +} + +void +ValueInternalMap::doActualRemove( ValueInternalLink *link, + BucketIndex index, + BucketIndex bucketIndex ) +{ + // find last item of the bucket and swap it with the 'removed' one. + // set removed items flags to 'available'. + // if last page only contains 'available' items, then desallocate it (it's empty) + ValueInternalLink *&lastLink = getLastLinkInBucket( index ); + BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1 + for ( ; + lastItemIndex < ValueInternalLink::itemPerLink; + ++lastItemIndex ) // may be optimized with dicotomic search + { + if ( lastLink->items_[lastItemIndex].isItemAvailable() ) + break; + } + + BucketIndex lastUsedIndex = lastItemIndex - 1; + Value *valueToDelete = &link->items_[index]; + Value *valueToPreserve = &lastLink->items_[lastUsedIndex]; + if ( valueToDelete != valueToPreserve ) + valueToDelete->swap( *valueToPreserve ); + if ( lastUsedIndex == 0 ) // page is now empty + { // remove it from bucket linked list and delete it. + ValueInternalLink *linkPreviousToLast = lastLink->previous_; + if ( linkPreviousToLast != 0 ) // can not deleted bucket link. + { + mapAllocator()->releaseMapLink( lastLink ); + linkPreviousToLast->next_ = 0; + lastLink = linkPreviousToLast; + } + } + else + { + Value dummy; + valueToPreserve->swap( dummy ); // restore deleted to default Value. + valueToPreserve->setItemUsed( false ); + } + --itemCount_; +} + + +ValueInternalLink *& +ValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex ) +{ + if ( bucketIndex == bucketsSize_ - 1 ) + return tailLink_; + ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_; + if ( !previous ) + previous = &buckets_[bucketIndex]; + return previous; +} + + +Value & +ValueInternalMap::setNewItem( const char *key, + bool isStatic, + ValueInternalLink *link, + BucketIndex index ) +{ + char *duplicatedKey = valueAllocator()->makeMemberName( key ); + ++itemCount_; + link->keys_[index] = duplicatedKey; + link->items_[index].setItemUsed(); + link->items_[index].setMemberNameIsStatic( isStatic ); + return link->items_[index]; // items already default constructed. +} + + +Value & +ValueInternalMap::unsafeAdd( const char *key, + bool isStatic, + HashKey hashedKey ) +{ + JSON_ASSERT_MESSAGE( bucketsSize_ > 0, "ValueInternalMap::unsafeAdd(): internal logic error." ); + BucketIndex bucketIndex = hashedKey % bucketsSize_; + ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex ); + ValueInternalLink *link = previousLink; + BucketIndex index; + for ( index =0; index < ValueInternalLink::itemPerLink; ++index ) + { + if ( link->items_[index].isItemAvailable() ) + break; + } + if ( index == ValueInternalLink::itemPerLink ) // need to add a new page + { + ValueInternalLink *newLink = mapAllocator()->allocateMapLink(); + index = 0; + link->next_ = newLink; + previousLink = newLink; + link = newLink; + } + return setNewItem( key, isStatic, link, index ); +} + + +ValueInternalMap::HashKey +ValueInternalMap::hash( const char *key ) const +{ + HashKey hash = 0; + while ( *key ) + hash += *key++ * 37; + return hash; +} + + +int +ValueInternalMap::compare( const ValueInternalMap &other ) const +{ + int sizeDiff( itemCount_ - other.itemCount_ ); + if ( sizeDiff != 0 ) + return sizeDiff; + // Strict order guaranty is required. Compare all keys FIRST, then compare values. + IteratorState it; + IteratorState itEnd; + makeBeginIterator( it ); + makeEndIterator( itEnd ); + for ( ; !equals(it,itEnd); increment(it) ) + { + if ( !other.find( key( it ) ) ) + return 1; + } + + // All keys are equals, let's compare values + makeBeginIterator( it ); + for ( ; !equals(it,itEnd); increment(it) ) + { + const Value *otherValue = other.find( key( it ) ); + int valueDiff = value(it).compare( *otherValue ); + if ( valueDiff != 0 ) + return valueDiff; + } + return 0; +} + + +void +ValueInternalMap::makeBeginIterator( IteratorState &it ) const +{ + it.map_ = const_cast( this ); + it.bucketIndex_ = 0; + it.itemIndex_ = 0; + it.link_ = buckets_; +} + + +void +ValueInternalMap::makeEndIterator( IteratorState &it ) const +{ + it.map_ = const_cast( this ); + it.bucketIndex_ = bucketsSize_; + it.itemIndex_ = 0; + it.link_ = 0; +} + + +bool +ValueInternalMap::equals( const IteratorState &x, const IteratorState &other ) +{ + return x.map_ == other.map_ + && x.bucketIndex_ == other.bucketIndex_ + && x.link_ == other.link_ + && x.itemIndex_ == other.itemIndex_; +} + + +void +ValueInternalMap::incrementBucket( IteratorState &iterator ) +{ + ++iterator.bucketIndex_; + JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_, + "ValueInternalMap::increment(): attempting to iterate beyond end." ); + if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ ) + iterator.link_ = 0; + else + iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]); + iterator.itemIndex_ = 0; +} + + +void +ValueInternalMap::increment( IteratorState &iterator ) +{ + JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterator using invalid iterator." ); + ++iterator.itemIndex_; + if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink ) + { + JSON_ASSERT_MESSAGE( iterator.link_ != 0, + "ValueInternalMap::increment(): attempting to iterate beyond end." ); + iterator.link_ = iterator.link_->next_; + if ( iterator.link_ == 0 ) + incrementBucket( iterator ); + } + else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() ) + { + incrementBucket( iterator ); + } +} + + +void +ValueInternalMap::decrement( IteratorState &iterator ) +{ + if ( iterator.itemIndex_ == 0 ) + { + JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterate using invalid iterator." ); + if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] ) + { + JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, "Attempting to iterate beyond beginning." ); + --(iterator.bucketIndex_); + } + iterator.link_ = iterator.link_->previous_; + iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1; + } +} + + +const char * +ValueInternalMap::key( const IteratorState &iterator ) +{ + JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); + return iterator.link_->keys_[iterator.itemIndex_]; +} + +const char * +ValueInternalMap::key( const IteratorState &iterator, bool &isStatic ) +{ + JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); + isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic(); + return iterator.link_->keys_[iterator.itemIndex_]; +} + + +Value & +ValueInternalMap::value( const IteratorState &iterator ) +{ + JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." ); + return iterator.link_->items_[iterator.itemIndex_]; +} + + +int +ValueInternalMap::distance( const IteratorState &x, const IteratorState &y ) +{ + int offset = 0; + IteratorState it = x; + while ( !equals( it, y ) ) + increment( it ); + return offset; +} diff --git a/src/jsoncpp/src/lib_json/json_reader.cpp b/src/jsoncpp/src/lib_json/json_reader.cpp new file mode 100644 index 0000000000..cefcc8c198 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_reader.cpp @@ -0,0 +1,886 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER >= 1400 // VC++ 8.0 +#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. +#endif + +namespace Json { + +// Implementation of class Features +// //////////////////////////////// + +Features::Features() + : allowComments_( true ) + , strictRoot_( false ) +{ +} + + +Features +Features::all() +{ + return Features(); +} + + +Features +Features::strictMode() +{ + Features features; + features.allowComments_ = false; + features.strictRoot_ = true; + return features; +} + +// Implementation of class Reader +// //////////////////////////////// + + +static inline bool +in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4 ) +{ + return c == c1 || c == c2 || c == c3 || c == c4; +} + +static inline bool +in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4, Reader::Char c5 ) +{ + return c == c1 || c == c2 || c == c3 || c == c4 || c == c5; +} + + +static bool +containsNewLine( Reader::Location begin, + Reader::Location end ) +{ + for ( ;begin < end; ++begin ) + if ( *begin == '\n' || *begin == '\r' ) + return true; + return false; +} + +static std::string codePointToUTF8(unsigned int cp) +{ + std::string result; + + // based on description from http://en.wikipedia.org/wiki/UTF-8 + + if (cp <= 0x7f) + { + result.resize(1); + result[0] = static_cast(cp); + } + else if (cp <= 0x7FF) + { + result.resize(2); + result[1] = static_cast(0x80 | (0x3f & cp)); + result[0] = static_cast(0xC0 | (0x1f & (cp >> 6))); + } + else if (cp <= 0xFFFF) + { + result.resize(3); + result[2] = static_cast(0x80 | (0x3f & cp)); + result[1] = 0x80 | static_cast((0x3f & (cp >> 6))); + result[0] = 0xE0 | static_cast((0xf & (cp >> 12))); + } + else if (cp <= 0x10FFFF) + { + result.resize(4); + result[3] = static_cast(0x80 | (0x3f & cp)); + result[2] = static_cast(0x80 | (0x3f & (cp >> 6))); + result[1] = static_cast(0x80 | (0x3f & (cp >> 12))); + result[0] = static_cast(0xF0 | (0x7 & (cp >> 18))); + } + + return result; +} + + +// Class Reader +// ////////////////////////////////////////////////////////////////// + +Reader::Reader() + : features_( Features::all() ) +{ +} + + +Reader::Reader( const Features &features ) + : features_( features ) +{ +} + + +bool +Reader::parse( const std::string &document, + Value &root, + bool collectComments ) +{ + document_ = document; + const char *begin = document_.c_str(); + const char *end = begin + document_.length(); + return parse( begin, end, root, collectComments ); +} + + +bool +Reader::parse( std::istream& sin, + Value &root, + bool collectComments ) +{ + //std::istream_iterator begin(sin); + //std::istream_iterator end; + // Those would allow streamed input from a file, if parse() were a + // template function. + + // Since std::string is reference-counted, this at least does not + // create an extra copy. + std::string doc; + std::getline(sin, doc, (char)EOF); + return parse( doc, root, collectComments ); +} + +bool +Reader::parse( const char *beginDoc, const char *endDoc, + Value &root, + bool collectComments ) +{ + if ( !features_.allowComments_ ) + { + collectComments = false; + } + + begin_ = beginDoc; + end_ = endDoc; + collectComments_ = collectComments; + current_ = begin_; + lastValueEnd_ = 0; + lastValue_ = 0; + commentsBefore_ = ""; + errors_.clear(); + while ( !nodes_.empty() ) + nodes_.pop(); + nodes_.push( &root ); + + bool successful = readValue(); + Token token; + skipCommentTokens( token ); + if ( collectComments_ && !commentsBefore_.empty() ) + root.setComment( commentsBefore_, commentAfter ); + if ( features_.strictRoot_ ) + { + if ( !root.isArray() && !root.isObject() ) + { + // Set error location to start of doc, ideally should be first token found in doc + token.type_ = tokenError; + token.start_ = beginDoc; + token.end_ = endDoc; + addError( "A valid JSON document must be either an array or an object value.", + token ); + return false; + } + } + return successful; +} + + +bool +Reader::readValue() +{ + Token token; + skipCommentTokens( token ); + bool successful = true; + + if ( collectComments_ && !commentsBefore_.empty() ) + { + currentValue().setComment( commentsBefore_, commentBefore ); + commentsBefore_ = ""; + } + + + switch ( token.type_ ) + { + case tokenObjectBegin: + successful = readObject( token ); + break; + case tokenArrayBegin: + successful = readArray( token ); + break; + case tokenNumber: + successful = decodeNumber( token ); + break; + case tokenString: + successful = decodeString( token ); + break; + case tokenTrue: + currentValue() = true; + break; + case tokenFalse: + currentValue() = false; + break; + case tokenNull: + currentValue() = Value(); + break; + default: + return addError( "Syntax error: value, object or array expected.", token ); + } + + if ( collectComments_ ) + { + lastValueEnd_ = current_; + lastValue_ = ¤tValue(); + } + + return successful; +} + + +void +Reader::skipCommentTokens( Token &token ) +{ + if ( features_.allowComments_ ) + { + do + { + readToken( token ); + } + while ( token.type_ == tokenComment ); + } + else + { + readToken( token ); + } +} + + +bool +Reader::expectToken( TokenType type, Token &token, const char *message ) +{ + readToken( token ); + if ( token.type_ != type ) + return addError( message, token ); + return true; +} + + +bool +Reader::readToken( Token &token ) +{ + skipSpaces(); + token.start_ = current_; + Char c = getNextChar(); + bool ok = true; + switch ( c ) + { + case '{': + token.type_ = tokenObjectBegin; + break; + case '}': + token.type_ = tokenObjectEnd; + break; + case '[': + token.type_ = tokenArrayBegin; + break; + case ']': + token.type_ = tokenArrayEnd; + break; + case '"': + token.type_ = tokenString; + ok = readString(); + break; + case '/': + token.type_ = tokenComment; + ok = readComment(); + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + token.type_ = tokenNumber; + readNumber(); + break; + case 't': + token.type_ = tokenTrue; + ok = match( "rue", 3 ); + break; + case 'f': + token.type_ = tokenFalse; + ok = match( "alse", 4 ); + break; + case 'n': + token.type_ = tokenNull; + ok = match( "ull", 3 ); + break; + case ',': + token.type_ = tokenArraySeparator; + break; + case ':': + token.type_ = tokenMemberSeparator; + break; + case 0: + token.type_ = tokenEndOfStream; + break; + default: + ok = false; + break; + } + if ( !ok ) + token.type_ = tokenError; + token.end_ = current_; + return true; +} + + +void +Reader::skipSpaces() +{ + while ( current_ != end_ ) + { + Char c = *current_; + if ( c == ' ' || c == '\t' || c == '\r' || c == '\n' ) + ++current_; + else + break; + } +} + + +bool +Reader::match( Location pattern, + int patternLength ) +{ + if ( end_ - current_ < patternLength ) + return false; + int index = patternLength; + while ( index-- ) + if ( current_[index] != pattern[index] ) + return false; + current_ += patternLength; + return true; +} + + +bool +Reader::readComment() +{ + Location commentBegin = current_ - 1; + Char c = getNextChar(); + bool successful = false; + if ( c == '*' ) + successful = readCStyleComment(); + else if ( c == '/' ) + successful = readCppStyleComment(); + if ( !successful ) + return false; + + if ( collectComments_ ) + { + CommentPlacement placement = commentBefore; + if ( lastValueEnd_ && !containsNewLine( lastValueEnd_, commentBegin ) ) + { + if ( c != '*' || !containsNewLine( commentBegin, current_ ) ) + placement = commentAfterOnSameLine; + } + + addComment( commentBegin, current_, placement ); + } + return true; +} + + +void +Reader::addComment( Location begin, + Location end, + CommentPlacement placement ) +{ + assert( collectComments_ ); + if ( placement == commentAfterOnSameLine ) + { + assert( lastValue_ != 0 ); + lastValue_->setComment( std::string( begin, end ), placement ); + } + else + { + if ( !commentsBefore_.empty() ) + commentsBefore_ += "\n"; + commentsBefore_ += std::string( begin, end ); + } +} + + +bool +Reader::readCStyleComment() +{ + while ( current_ != end_ ) + { + Char c = getNextChar(); + if ( c == '*' && *current_ == '/' ) + break; + } + return getNextChar() == '/'; +} + + +bool +Reader::readCppStyleComment() +{ + while ( current_ != end_ ) + { + Char c = getNextChar(); + if ( c == '\r' || c == '\n' ) + break; + } + return true; +} + + +void +Reader::readNumber() +{ + while ( current_ != end_ ) + { + if ( !(*current_ >= '0' && *current_ <= '9') && + !in( *current_, '.', 'e', 'E', '+', '-' ) ) + break; + ++current_; + } +} + +bool +Reader::readString() +{ + Char c = 0; + while ( current_ != end_ ) + { + c = getNextChar(); + if ( c == '\\' ) + getNextChar(); + else if ( c == '"' ) + break; + } + return c == '"'; +} + + +bool +Reader::readObject( Token &tokenStart ) +{ + Token tokenName; + std::string name; + currentValue() = Value( objectValue ); + while ( readToken( tokenName ) ) + { + bool initialTokenOk = true; + while ( tokenName.type_ == tokenComment && initialTokenOk ) + initialTokenOk = readToken( tokenName ); + if ( !initialTokenOk ) + break; + if ( tokenName.type_ == tokenObjectEnd && name.empty() ) // empty object + return true; + if ( tokenName.type_ != tokenString ) + break; + + name = ""; + if ( !decodeString( tokenName, name ) ) + return recoverFromError( tokenObjectEnd ); + + Token colon; + if ( !readToken( colon ) || colon.type_ != tokenMemberSeparator ) + { + return addErrorAndRecover( "Missing ':' after object member name", + colon, + tokenObjectEnd ); + } + Value &value = currentValue()[ name ]; + nodes_.push( &value ); + bool ok = readValue(); + nodes_.pop(); + if ( !ok ) // error already set + return recoverFromError( tokenObjectEnd ); + + Token comma; + if ( !readToken( comma ) + || ( comma.type_ != tokenObjectEnd && + comma.type_ != tokenArraySeparator && + comma.type_ != tokenComment ) ) + { + return addErrorAndRecover( "Missing ',' or '}' in object declaration", + comma, + tokenObjectEnd ); + } + bool finalizeTokenOk = true; + while ( comma.type_ == tokenComment && + finalizeTokenOk ) + finalizeTokenOk = readToken( comma ); + if ( comma.type_ == tokenObjectEnd ) + return true; + } + return addErrorAndRecover( "Missing '}' or object member name", + tokenName, + tokenObjectEnd ); +} + + +bool +Reader::readArray( Token &tokenStart ) +{ + currentValue() = Value( arrayValue ); + skipSpaces(); + if ( *current_ == ']' ) // empty array + { + Token endArray; + readToken( endArray ); + return true; + } + int index = 0; + while ( true ) + { + Value &value = currentValue()[ index++ ]; + nodes_.push( &value ); + bool ok = readValue(); + nodes_.pop(); + if ( !ok ) // error already set + return recoverFromError( tokenArrayEnd ); + + Token token; + // Accept Comment after last item in the array. + ok = readToken( token ); + while ( token.type_ == tokenComment && ok ) + { + ok = readToken( token ); + } + bool badTokenType = ( token.type_ == tokenArraySeparator && + token.type_ == tokenArrayEnd ); + if ( !ok || badTokenType ) + { + return addErrorAndRecover( "Missing ',' or ']' in array declaration", + token, + tokenArrayEnd ); + } + if ( token.type_ == tokenArrayEnd ) + break; + } + return true; +} + + +bool +Reader::decodeNumber( Token &token ) +{ + bool isDouble = false; + for ( Location inspect = token.start_; inspect != token.end_; ++inspect ) + { + isDouble = isDouble + || in( *inspect, '.', 'e', 'E', '+' ) + || ( *inspect == '-' && inspect != token.start_ ); + } + if ( isDouble ) + return decodeDouble( token ); + Location current = token.start_; + bool isNegative = *current == '-'; + if ( isNegative ) + ++current; + Value::UInt threshold = (isNegative ? Value::UInt(-Value::minInt) + : Value::maxUInt) / 10; + Value::UInt value = 0; + while ( current < token.end_ ) + { + Char c = *current++; + if ( c < '0' || c > '9' ) + return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token ); + if ( value >= threshold ) + return decodeDouble( token ); + value = value * 10 + Value::UInt(c - '0'); + } + if ( isNegative ) + currentValue() = -Value::Int( value ); + else if ( value <= Value::UInt(Value::maxInt) ) + currentValue() = Value::Int( value ); + else + currentValue() = value; + return true; +} + + +bool +Reader::decodeDouble( Token &token ) +{ + double value = 0; + const int bufferSize = 32; + int count; + int length = int(token.end_ - token.start_); + if ( length <= bufferSize ) + { + Char buffer[bufferSize]; + memcpy( buffer, token.start_, length ); + buffer[length] = 0; + count = sscanf( buffer, "%lf", &value ); + } + else + { + std::string buffer( token.start_, token.end_ ); + count = sscanf( buffer.c_str(), "%lf", &value ); + } + + if ( count != 1 ) + return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token ); + currentValue() = value; + return true; +} + + +bool +Reader::decodeString( Token &token ) +{ + std::string decoded; + if ( !decodeString( token, decoded ) ) + return false; + currentValue() = decoded; + return true; +} + + +bool +Reader::decodeString( Token &token, std::string &decoded ) +{ + decoded.reserve( token.end_ - token.start_ - 2 ); + Location current = token.start_ + 1; // skip '"' + Location end = token.end_ - 1; // do not include '"' + while ( current != end ) + { + Char c = *current++; + if ( c == '"' ) + break; + else if ( c == '\\' ) + { + if ( current == end ) + return addError( "Empty escape sequence in string", token, current ); + Char escape = *current++; + switch ( escape ) + { + case '"': decoded += '"'; break; + case '/': decoded += '/'; break; + case '\\': decoded += '\\'; break; + case 'b': decoded += '\b'; break; + case 'f': decoded += '\f'; break; + case 'n': decoded += '\n'; break; + case 'r': decoded += '\r'; break; + case 't': decoded += '\t'; break; + case 'u': + { + unsigned int unicode; + if ( !decodeUnicodeCodePoint( token, current, end, unicode ) ) + return false; + decoded += codePointToUTF8(unicode); + } + break; + default: + return addError( "Bad escape sequence in string", token, current ); + } + } + else + { + decoded += c; + } + } + return true; +} + +bool +Reader::decodeUnicodeCodePoint( Token &token, + Location ¤t, + Location end, + unsigned int &unicode ) +{ + + if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) ) + return false; + if (unicode >= 0xD800 && unicode <= 0xDBFF) + { + // surrogate pairs + if (end - current < 6) + return addError( "additional six characters expected to parse unicode surrogate pair.", token, current ); + unsigned int surrogatePair; + if (*(current++) == '\\' && *(current++)== 'u') + { + if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair )) + { + unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF); + } + else + return false; + } + else + return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current ); + } + return true; +} + +bool +Reader::decodeUnicodeEscapeSequence( Token &token, + Location ¤t, + Location end, + unsigned int &unicode ) +{ + if ( end - current < 4 ) + return addError( "Bad unicode escape sequence in string: four digits expected.", token, current ); + unicode = 0; + for ( int index =0; index < 4; ++index ) + { + Char c = *current++; + unicode *= 16; + if ( c >= '0' && c <= '9' ) + unicode += c - '0'; + else if ( c >= 'a' && c <= 'f' ) + unicode += c - 'a' + 10; + else if ( c >= 'A' && c <= 'F' ) + unicode += c - 'A' + 10; + else + return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current ); + } + return true; +} + + +bool +Reader::addError( const std::string &message, + Token &token, + Location extra ) +{ + ErrorInfo info; + info.token_ = token; + info.message_ = message; + info.extra_ = extra; + errors_.push_back( info ); + return false; +} + + +bool +Reader::recoverFromError( TokenType skipUntilToken ) +{ + int errorCount = int(errors_.size()); + Token skip; + while ( true ) + { + if ( !readToken(skip) ) + errors_.resize( errorCount ); // discard errors caused by recovery + if ( skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream ) + break; + } + errors_.resize( errorCount ); + return false; +} + + +bool +Reader::addErrorAndRecover( const std::string &message, + Token &token, + TokenType skipUntilToken ) +{ + addError( message, token ); + return recoverFromError( skipUntilToken ); +} + + +Value & +Reader::currentValue() +{ + return *(nodes_.top()); +} + + +Reader::Char +Reader::getNextChar() +{ + if ( current_ == end_ ) + return 0; + return *current_++; +} + + +void +Reader::getLocationLineAndColumn( Location location, + int &line, + int &column ) const +{ + Location current = begin_; + Location lastLineStart = current; + line = 0; + while ( current < location && current != end_ ) + { + Char c = *current++; + if ( c == '\r' ) + { + if ( *current == '\n' ) + ++current; + lastLineStart = current; + ++line; + } + else if ( c == '\n' ) + { + lastLineStart = current; + ++line; + } + } + // column & line start at 1 + column = int(location - lastLineStart) + 1; + ++line; +} + + +std::string +Reader::getLocationLineAndColumn( Location location ) const +{ + int line, column; + getLocationLineAndColumn( location, line, column ); + char buffer[18+16+16+1]; + sprintf( buffer, "Line %d, Column %d", line, column ); + return buffer; +} + + +std::string +Reader::getFormatedErrorMessages() const +{ + std::string formattedMessage; + for ( Errors::const_iterator itError = errors_.begin(); + itError != errors_.end(); + ++itError ) + { + const ErrorInfo &error = *itError; + formattedMessage += "* " + getLocationLineAndColumn( error.token_.start_ ) + "\n"; + formattedMessage += " " + error.message_ + "\n"; + if ( error.extra_ ) + formattedMessage += "See " + getLocationLineAndColumn( error.extra_ ) + " for detail.\n"; + } + return formattedMessage; +} + + +std::istream& operator>>( std::istream &sin, Value &root ) +{ + Json::Reader reader; + bool ok = reader.parse(sin, root, true); + //JSON_ASSERT( ok ); +// if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages()); + assert(ok); + return sin; +} + + +} // namespace Json diff --git a/src/jsoncpp/src/lib_json/json_value.cpp b/src/jsoncpp/src/lib_json/json_value.cpp new file mode 100644 index 0000000000..fd773ec119 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_value.cpp @@ -0,0 +1,1718 @@ +#include +#include +#include +#include +#include +#include +#include +#ifdef JSON_USE_CPPTL +# include +#endif +#include // size_t +#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR +# include "json_batchallocator.h" +#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR + +#define JSON_ASSERT_UNREACHABLE assert( false ) +#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw +#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) assert(false); /* throw std::runtime_error( message ); */ + +namespace Json { + +const Value Value::null; +const Int Value::minInt = Int( ~(UInt(-1)/2) ); +const Int Value::maxInt = Int( UInt(-1)/2 ); +const UInt Value::maxUInt = UInt(-1); + +// A "safe" implementation of strdup. Allow null pointer to be passed. +// Also avoid warning on msvc80. +// +//inline char *safeStringDup( const char *czstring ) +//{ +// if ( czstring ) +// { +// const size_t length = (unsigned int)( strlen(czstring) + 1 ); +// char *newString = static_cast( malloc( length ) ); +// memcpy( newString, czstring, length ); +// return newString; +// } +// return 0; +//} +// +//inline char *safeStringDup( const std::string &str ) +//{ +// if ( !str.empty() ) +// { +// const size_t length = str.length(); +// char *newString = static_cast( malloc( length + 1 ) ); +// memcpy( newString, str.c_str(), length ); +// newString[length] = 0; +// return newString; +// } +// return 0; +//} + +ValueAllocator::~ValueAllocator() +{ +} + +class DefaultValueAllocator : public ValueAllocator +{ +public: + virtual ~DefaultValueAllocator() + { + } + + virtual char *makeMemberName( const char *memberName ) + { + return duplicateStringValue( memberName ); + } + + virtual void releaseMemberName( char *memberName ) + { + releaseStringValue( memberName ); + } + + virtual char *duplicateStringValue( const char *value, + unsigned int length = unknown ) + { + //@todo invesgate this old optimization + //if ( !value || value[0] == 0 ) + // return 0; + + if ( length == unknown ) + length = (unsigned int)strlen(value); + char *newString = static_cast( malloc( length + 1 ) ); + memcpy( newString, value, length ); + newString[length] = 0; + return newString; + } + + virtual void releaseStringValue( char *value ) + { + if ( value ) + free( value ); + } +}; + +static ValueAllocator *&valueAllocator() +{ + static DefaultValueAllocator defaultAllocator; + static ValueAllocator *valueAllocator = &defaultAllocator; + return valueAllocator; +} + +static struct DummyValueAllocatorInitializer { + DummyValueAllocatorInitializer() + { + valueAllocator(); // ensure valueAllocator() statics are initialized before main(). + } +} dummyValueAllocatorInitializer; + + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ValueInternals... +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +#ifdef JSON_VALUE_USE_INTERNAL_MAP +# include "json_internalarray.inl" +# include "json_internalmap.inl" +#endif // JSON_VALUE_USE_INTERNAL_MAP + +# include "json_valueiterator.inl" + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class Value::CommentInfo +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + + +Value::CommentInfo::CommentInfo() + : comment_( 0 ) +{ +} + +Value::CommentInfo::~CommentInfo() +{ + if ( comment_ ) + valueAllocator()->releaseStringValue( comment_ ); +} + + +void +Value::CommentInfo::setComment( const char *text ) +{ + if ( comment_ ) + valueAllocator()->releaseStringValue( comment_ ); + JSON_ASSERT( text ); + JSON_ASSERT_MESSAGE( text[0]=='\0' || text[0]=='/', "Comments must start with /"); + // It seems that /**/ style comments are acceptable as well. + comment_ = valueAllocator()->duplicateStringValue( text ); +} + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class Value::CZString +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +# ifndef JSON_VALUE_USE_INTERNAL_MAP + +// Notes: index_ indicates if the string was allocated when +// a string is stored. + +Value::CZString::CZString( int index ) + : cstr_( 0 ) + , index_( index ) +{ +} + +Value::CZString::CZString( const char *cstr, DuplicationPolicy allocate ) + : cstr_( allocate == duplicate ? valueAllocator()->makeMemberName(cstr) + : cstr ) + , index_( allocate ) +{ +} + +Value::CZString::CZString( const CZString &other ) +: cstr_( other.index_ != noDuplication && other.cstr_ != 0 + ? valueAllocator()->makeMemberName( other.cstr_ ) + : other.cstr_ ) + , index_( other.cstr_ ? (other.index_ == noDuplication ? noDuplication : duplicate) + : other.index_ ) +{ +} + +Value::CZString::~CZString() +{ + if ( cstr_ && index_ == duplicate ) + valueAllocator()->releaseMemberName( const_cast( cstr_ ) ); +} + +void +Value::CZString::swap( CZString &other ) +{ + std::swap( cstr_, other.cstr_ ); + std::swap( index_, other.index_ ); +} + +Value::CZString & +Value::CZString::operator =( const CZString &other ) +{ + CZString temp( other ); + swap( temp ); + return *this; +} + +bool +Value::CZString::operator<( const CZString &other ) const +{ + if ( cstr_ ) + return strcmp( cstr_, other.cstr_ ) < 0; + return index_ < other.index_; +} + +bool +Value::CZString::operator==( const CZString &other ) const +{ + if ( cstr_ ) + return strcmp( cstr_, other.cstr_ ) == 0; + return index_ == other.index_; +} + + +int +Value::CZString::index() const +{ + return index_; +} + + +const char * +Value::CZString::c_str() const +{ + return cstr_; +} + +bool +Value::CZString::isStaticString() const +{ + return index_ == noDuplication; +} + +#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class Value::Value +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +/*! \internal Default constructor initialization must be equivalent to: + * memset( this, 0, sizeof(Value) ) + * This optimization is used in ValueInternalMap fast allocator. + */ +Value::Value( ValueType type ) + : type_( type ) + , allocated_( 0 ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + switch ( type ) + { + case nullValue: + break; + case intValue: + case uintValue: + value_.int_ = 0; + break; + case realValue: + value_.real_ = 0.0; + break; + case stringValue: + value_.string_ = 0; + break; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + value_.map_ = new ObjectValues(); + break; +#else + case arrayValue: + value_.array_ = arrayAllocator()->newArray(); + break; + case objectValue: + value_.map_ = mapAllocator()->newMap(); + break; +#endif + case booleanValue: + value_.bool_ = false; + break; + default: + JSON_ASSERT_UNREACHABLE; + } +} + + +Value::Value( Int value ) + : type_( intValue ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.int_ = value; +} + + +Value::Value( UInt value ) + : type_( uintValue ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.uint_ = value; +} + +Value::Value( double value ) + : type_( realValue ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.real_ = value; +} + +Value::Value( const char *value ) + : type_( stringValue ) + , allocated_( true ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.string_ = valueAllocator()->duplicateStringValue( value ); +} + + +Value::Value( const char *beginValue, + const char *endValue ) + : type_( stringValue ) + , allocated_( true ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.string_ = valueAllocator()->duplicateStringValue( beginValue, + UInt(endValue - beginValue) ); +} + + +Value::Value( const std::string &value ) + : type_( stringValue ) + , allocated_( true ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.string_ = valueAllocator()->duplicateStringValue( value.c_str(), + (unsigned int)value.length() ); + +} + +Value::Value( const StaticString &value ) + : type_( stringValue ) + , allocated_( false ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.string_ = const_cast( value.c_str() ); +} + + +# ifdef JSON_USE_CPPTL +Value::Value( const CppTL::ConstString &value ) + : type_( stringValue ) + , allocated_( true ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.string_ = valueAllocator()->duplicateStringValue( value, value.length() ); +} +# endif + +Value::Value( bool value ) + : type_( booleanValue ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + value_.bool_ = value; +} + + +Value::Value( const Value &other ) + : type_( other.type_ ) + , comments_( 0 ) +# ifdef JSON_VALUE_USE_INTERNAL_MAP + , itemIsUsed_( 0 ) +#endif +{ + switch ( type_ ) + { + case nullValue: + case intValue: + case uintValue: + case realValue: + case booleanValue: + value_ = other.value_; + break; + case stringValue: + if ( other.value_.string_ ) + { + value_.string_ = valueAllocator()->duplicateStringValue( other.value_.string_ ); + allocated_ = true; + } + else + value_.string_ = 0; + break; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + value_.map_ = new ObjectValues( *other.value_.map_ ); + break; +#else + case arrayValue: + value_.array_ = arrayAllocator()->newArrayCopy( *other.value_.array_ ); + break; + case objectValue: + value_.map_ = mapAllocator()->newMapCopy( *other.value_.map_ ); + break; +#endif + default: + JSON_ASSERT_UNREACHABLE; + } + if ( other.comments_ ) + { + comments_ = new CommentInfo[numberOfCommentPlacement]; + for ( int comment =0; comment < numberOfCommentPlacement; ++comment ) + { + const CommentInfo &otherComment = other.comments_[comment]; + if ( otherComment.comment_ ) + comments_[comment].setComment( otherComment.comment_ ); + } + } +} + + +Value::~Value() +{ + switch ( type_ ) + { + case nullValue: + case intValue: + case uintValue: + case realValue: + case booleanValue: + break; + case stringValue: + if ( allocated_ ) + valueAllocator()->releaseStringValue( value_.string_ ); + break; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + delete value_.map_; + break; +#else + case arrayValue: + arrayAllocator()->destructArray( value_.array_ ); + break; + case objectValue: + mapAllocator()->destructMap( value_.map_ ); + break; +#endif + default: + JSON_ASSERT_UNREACHABLE; + } + + if ( comments_ ) + delete[] comments_; +} + +Value & +Value::operator=( const Value &other ) +{ + Value temp( other ); + swap( temp ); + return *this; +} + +void +Value::swap( Value &other ) +{ + ValueType temp = type_; + type_ = other.type_; + other.type_ = temp; + std::swap( value_, other.value_ ); + int temp2 = allocated_; + allocated_ = other.allocated_; + other.allocated_ = temp2; +} + +ValueType +Value::type() const +{ + return type_; +} + + +int +Value::compare( const Value &other ) +{ + /* + int typeDelta = other.type_ - type_; + switch ( type_ ) + { + case nullValue: + + return other.type_ == type_; + case intValue: + if ( other.type_.isNumeric() + case uintValue: + case realValue: + case booleanValue: + break; + case stringValue, + break; + case arrayValue: + delete value_.array_; + break; + case objectValue: + delete value_.map_; + default: + JSON_ASSERT_UNREACHABLE; + } + */ + return 0; // unreachable +} + +bool +Value::operator <( const Value &other ) const +{ + int typeDelta = type_ - other.type_; + if ( typeDelta ) + return typeDelta < 0 ? true : false; + switch ( type_ ) + { + case nullValue: + return false; + case intValue: + return value_.int_ < other.value_.int_; + case uintValue: + return value_.uint_ < other.value_.uint_; + case realValue: + return value_.real_ < other.value_.real_; + case booleanValue: + return value_.bool_ < other.value_.bool_; + case stringValue: + return ( value_.string_ == 0 && other.value_.string_ ) + || ( other.value_.string_ + && value_.string_ + && strcmp( value_.string_, other.value_.string_ ) < 0 ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + { + int delta = int( value_.map_->size() - other.value_.map_->size() ); + if ( delta ) + return delta < 0; + return (*value_.map_) < (*other.value_.map_); + } +#else + case arrayValue: + return value_.array_->compare( *(other.value_.array_) ) < 0; + case objectValue: + return value_.map_->compare( *(other.value_.map_) ) < 0; +#endif + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable +} + +bool +Value::operator <=( const Value &other ) const +{ + return !(other > *this); +} + +bool +Value::operator >=( const Value &other ) const +{ + return !(*this < other); +} + +bool +Value::operator >( const Value &other ) const +{ + return other < *this; +} + +bool +Value::operator ==( const Value &other ) const +{ + //if ( type_ != other.type_ ) + // GCC 2.95.3 says: + // attempt to take address of bit-field structure member `Json::Value::type_' + // Beats me, but a temp solves the problem. + int temp = other.type_; + if ( type_ != temp ) + return false; + switch ( type_ ) + { + case nullValue: + return true; + case intValue: + return value_.int_ == other.value_.int_; + case uintValue: + return value_.uint_ == other.value_.uint_; + case realValue: + return value_.real_ == other.value_.real_; + case booleanValue: + return value_.bool_ == other.value_.bool_; + case stringValue: + return ( value_.string_ == other.value_.string_ ) + || ( other.value_.string_ + && value_.string_ + && strcmp( value_.string_, other.value_.string_ ) == 0 ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + return value_.map_->size() == other.value_.map_->size() + && (*value_.map_) == (*other.value_.map_); +#else + case arrayValue: + return value_.array_->compare( *(other.value_.array_) ) == 0; + case objectValue: + return value_.map_->compare( *(other.value_.map_) ) == 0; +#endif + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable +} + +bool +Value::operator !=( const Value &other ) const +{ + return !( *this == other ); +} + +const char * +Value::asCString() const +{ + JSON_ASSERT( type_ == stringValue ); + return value_.string_; +} + + +std::string +Value::asString() const +{ + switch ( type_ ) + { + case nullValue: + return ""; + case stringValue: + return value_.string_ ? value_.string_ : ""; + case booleanValue: + return value_.bool_ ? "true" : "false"; + case intValue: + case uintValue: + case realValue: + case arrayValue: + case objectValue: + JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" ); + default: + JSON_ASSERT_UNREACHABLE; + } + return ""; // unreachable +} + +# ifdef JSON_USE_CPPTL +CppTL::ConstString +Value::asConstString() const +{ + return CppTL::ConstString( asString().c_str() ); +} +# endif + +Value::Int +Value::asInt() const +{ + switch ( type_ ) + { + case nullValue: + return 0; + case intValue: + return value_.int_; + case uintValue: + JSON_ASSERT_MESSAGE( value_.uint_ < (unsigned)maxInt, "integer out of signed integer range" ); + return value_.uint_; + case realValue: + JSON_ASSERT_MESSAGE( value_.real_ >= minInt && value_.real_ <= maxInt, "Real out of signed integer range" ); + return Int( value_.real_ ); + case booleanValue: + return value_.bool_ ? 1 : 0; + case stringValue: + case arrayValue: + case objectValue: + JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" ); + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable; +} + +Value::UInt +Value::asUInt() const +{ + switch ( type_ ) + { + case nullValue: + return 0; + case intValue: + JSON_ASSERT_MESSAGE( value_.int_ >= 0, "Negative integer can not be converted to unsigned integer" ); + return value_.int_; + case uintValue: + return value_.uint_; + case realValue: + JSON_ASSERT_MESSAGE( value_.real_ >= 0 && value_.real_ <= maxUInt, "Real out of unsigned integer range" ); + return UInt( value_.real_ ); + case booleanValue: + return value_.bool_ ? 1 : 0; + case stringValue: + case arrayValue: + case objectValue: + JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" ); + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable; +} + +double +Value::asDouble() const +{ + switch ( type_ ) + { + case nullValue: + return 0.0; + case intValue: + return value_.int_; + case uintValue: + return value_.uint_; + case realValue: + return value_.real_; + case booleanValue: + return value_.bool_ ? 1.0 : 0.0; + case stringValue: + case arrayValue: + case objectValue: + JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" ); + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable; +} + +bool +Value::asBool() const +{ + switch ( type_ ) + { + case nullValue: + return false; + case intValue: + case uintValue: + return value_.int_ != 0; + case realValue: + return value_.real_ != 0.0; + case booleanValue: + return value_.bool_; + case stringValue: + return value_.string_ && value_.string_[0] != 0; + case arrayValue: + case objectValue: + return value_.map_->size() != 0; + default: + JSON_ASSERT_UNREACHABLE; + } + return false; // unreachable; +} + + +bool +Value::isConvertibleTo( ValueType other ) const +{ + switch ( type_ ) + { + case nullValue: + return true; + case intValue: + return ( other == nullValue && value_.int_ == 0 ) + || other == intValue + || ( other == uintValue && value_.int_ >= 0 ) + || other == realValue + || other == stringValue + || other == booleanValue; + case uintValue: + return ( other == nullValue && value_.uint_ == 0 ) + || ( other == intValue && value_.uint_ <= (unsigned)maxInt ) + || other == uintValue + || other == realValue + || other == stringValue + || other == booleanValue; + case realValue: + return ( other == nullValue && value_.real_ == 0.0 ) + || ( other == intValue && value_.real_ >= minInt && value_.real_ <= maxInt ) + || ( other == uintValue && value_.real_ >= 0 && value_.real_ <= maxUInt ) + || other == realValue + || other == stringValue + || other == booleanValue; + case booleanValue: + return ( other == nullValue && value_.bool_ == false ) + || other == intValue + || other == uintValue + || other == realValue + || other == stringValue + || other == booleanValue; + case stringValue: + return other == stringValue + || ( other == nullValue && (!value_.string_ || value_.string_[0] == 0) ); + case arrayValue: + return other == arrayValue + || ( other == nullValue && value_.map_->size() == 0 ); + case objectValue: + return other == objectValue + || ( other == nullValue && value_.map_->size() == 0 ); + default: + JSON_ASSERT_UNREACHABLE; + } + return false; // unreachable; +} + + +/// Number of values in array or object +Value::UInt +Value::size() const +{ + switch ( type_ ) + { + case nullValue: + case intValue: + case uintValue: + case realValue: + case booleanValue: + case stringValue: + return 0; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: // size of the array is highest index + 1 + if ( !value_.map_->empty() ) + { + ObjectValues::const_iterator itLast = value_.map_->end(); + --itLast; + return (*itLast).first.index()+1; + } + return 0; + case objectValue: + return Int( value_.map_->size() ); +#else + case arrayValue: + return Int( value_.array_->size() ); + case objectValue: + return Int( value_.map_->size() ); +#endif + default: + JSON_ASSERT_UNREACHABLE; + } + return 0; // unreachable; +} + + +bool +Value::empty() const +{ + if ( isNull() || isArray() || isObject() ) + return size() == 0u; + else + return false; +} + + +bool +Value::operator!() const +{ + return isNull(); +} + + +void +Value::clear() +{ + JSON_ASSERT( type_ == nullValue || type_ == arrayValue || type_ == objectValue ); + + switch ( type_ ) + { +#ifndef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + case objectValue: + value_.map_->clear(); + break; +#else + case arrayValue: + value_.array_->clear(); + break; + case objectValue: + value_.map_->clear(); + break; +#endif + default: + break; + } +} + +void +Value::resize( UInt newSize ) +{ + JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); + if ( type_ == nullValue ) + *this = Value( arrayValue ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + UInt oldSize = size(); + if ( newSize == 0 ) + clear(); + else if ( newSize > oldSize ) + (*this)[ newSize - 1 ]; + else + { + for ( UInt index = newSize; index < oldSize; ++index ) + value_.map_->erase( index ); + assert( size() == newSize ); + } +#else + value_.array_->resize( newSize ); +#endif +} + + +Value & +Value::operator[]( UInt index ) +{ + JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); + if ( type_ == nullValue ) + *this = Value( arrayValue ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + CZString key( index ); + ObjectValues::iterator it = value_.map_->lower_bound( key ); + if ( it != value_.map_->end() && (*it).first == key ) + return (*it).second; + + ObjectValues::value_type defaultValue( key, null ); + it = value_.map_->insert( it, defaultValue ); + return (*it).second; +#else + return value_.array_->resolveReference( index ); +#endif +} + + +const Value & +Value::operator[]( UInt index ) const +{ + JSON_ASSERT( type_ == nullValue || type_ == arrayValue ); + if ( type_ == nullValue ) + return null; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + CZString key( index ); + ObjectValues::const_iterator it = value_.map_->find( key ); + if ( it == value_.map_->end() ) + return null; + return (*it).second; +#else + Value *value = value_.array_->find( index ); + return value ? *value : null; +#endif +} + + +Value & +Value::operator[]( const char *key ) +{ + return resolveReference( key, false ); +} + + +Value & +Value::resolveReference( const char *key, + bool isStatic ) +{ + JSON_ASSERT( type_ == nullValue || type_ == objectValue ); + if ( type_ == nullValue ) + *this = Value( objectValue ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + CZString actualKey( key, isStatic ? CZString::noDuplication + : CZString::duplicateOnCopy ); + ObjectValues::iterator it = value_.map_->lower_bound( actualKey ); + if ( it != value_.map_->end() && (*it).first == actualKey ) + return (*it).second; + + ObjectValues::value_type defaultValue( actualKey, null ); + it = value_.map_->insert( it, defaultValue ); + Value &value = (*it).second; + return value; +#else + return value_.map_->resolveReference( key, isStatic ); +#endif +} + + +Value +Value::get( UInt index, + const Value &defaultValue ) const +{ + const Value *value = &((*this)[index]); + return value == &null ? defaultValue : *value; +} + + +bool +Value::isValidIndex( UInt index ) const +{ + return index < size(); +} + + + +const Value & +Value::operator[]( const char *key ) const +{ + JSON_ASSERT( type_ == nullValue || type_ == objectValue ); + if ( type_ == nullValue ) + return null; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + CZString actualKey( key, CZString::noDuplication ); + ObjectValues::const_iterator it = value_.map_->find( actualKey ); + if ( it == value_.map_->end() ) + return null; + return (*it).second; +#else + const Value *value = value_.map_->find( key ); + return value ? *value : null; +#endif +} + + +Value & +Value::operator[]( const std::string &key ) +{ + return (*this)[ key.c_str() ]; +} + + +const Value & +Value::operator[]( const std::string &key ) const +{ + return (*this)[ key.c_str() ]; +} + +Value & +Value::operator[]( const StaticString &key ) +{ + return resolveReference( key, true ); +} + + +# ifdef JSON_USE_CPPTL +Value & +Value::operator[]( const CppTL::ConstString &key ) +{ + return (*this)[ key.c_str() ]; +} + + +const Value & +Value::operator[]( const CppTL::ConstString &key ) const +{ + return (*this)[ key.c_str() ]; +} +# endif + + +Value & +Value::append( const Value &value ) +{ + return (*this)[size()] = value; +} + + +Value +Value::get( const char *key, + const Value &defaultValue ) const +{ + const Value *value = &((*this)[key]); + return value == &null ? defaultValue : *value; +} + + +Value +Value::get( const std::string &key, + const Value &defaultValue ) const +{ + return get( key.c_str(), defaultValue ); +} + +Value +Value::removeMember( const char* key ) +{ + JSON_ASSERT( type_ == nullValue || type_ == objectValue ); + if ( type_ == nullValue ) + return null; +#ifndef JSON_VALUE_USE_INTERNAL_MAP + CZString actualKey( key, CZString::noDuplication ); + ObjectValues::iterator it = value_.map_->find( actualKey ); + if ( it == value_.map_->end() ) + return null; + Value old(it->second); + value_.map_->erase(it); + return old; +#else + Value *value = value_.map_->find( key ); + if (value){ + Value old(*value); + value_.map_.remove( key ); + return old; + } else { + return null; + } +#endif +} + +Value +Value::removeMember( const std::string &key ) +{ + return removeMember( key.c_str() ); +} + +# ifdef JSON_USE_CPPTL +Value +Value::get( const CppTL::ConstString &key, + const Value &defaultValue ) const +{ + return get( key.c_str(), defaultValue ); +} +# endif + +bool +Value::isMember( const char *key ) const +{ + const Value *value = &((*this)[key]); + return value != &null; +} + + +bool +Value::isMember( const std::string &key ) const +{ + return isMember( key.c_str() ); +} + + +# ifdef JSON_USE_CPPTL +bool +Value::isMember( const CppTL::ConstString &key ) const +{ + return isMember( key.c_str() ); +} +#endif + +Value::Members +Value::getMemberNames() const +{ + JSON_ASSERT( type_ == nullValue || type_ == objectValue ); + if ( type_ == nullValue ) + return Value::Members(); + Members members; + members.reserve( value_.map_->size() ); +#ifndef JSON_VALUE_USE_INTERNAL_MAP + ObjectValues::const_iterator it = value_.map_->begin(); + ObjectValues::const_iterator itEnd = value_.map_->end(); + for ( ; it != itEnd; ++it ) + members.push_back( std::string( (*it).first.c_str() ) ); +#else + ValueInternalMap::IteratorState it; + ValueInternalMap::IteratorState itEnd; + value_.map_->makeBeginIterator( it ); + value_.map_->makeEndIterator( itEnd ); + for ( ; !ValueInternalMap::equals( it, itEnd ); ValueInternalMap::increment(it) ) + members.push_back( std::string( ValueInternalMap::key( it ) ) ); +#endif + return members; +} +// +//# ifdef JSON_USE_CPPTL +//EnumMemberNames +//Value::enumMemberNames() const +//{ +// if ( type_ == objectValue ) +// { +// return CppTL::Enum::any( CppTL::Enum::transform( +// CppTL::Enum::keys( *(value_.map_), CppTL::Type() ), +// MemberNamesTransform() ) ); +// } +// return EnumMemberNames(); +//} +// +// +//EnumValues +//Value::enumValues() const +//{ +// if ( type_ == objectValue || type_ == arrayValue ) +// return CppTL::Enum::anyValues( *(value_.map_), +// CppTL::Type() ); +// return EnumValues(); +//} +// +//# endif + + +bool +Value::isNull() const +{ + return type_ == nullValue; +} + + +bool +Value::isBool() const +{ + return type_ == booleanValue; +} + + +bool +Value::isInt() const +{ + return type_ == intValue; +} + + +bool +Value::isUInt() const +{ + return type_ == uintValue; +} + + +bool +Value::isIntegral() const +{ + return type_ == intValue + || type_ == uintValue + || type_ == booleanValue; +} + + +bool +Value::isDouble() const +{ + return type_ == realValue; +} + + +bool +Value::isNumeric() const +{ + return isIntegral() || isDouble(); +} + + +bool +Value::isString() const +{ + return type_ == stringValue; +} + + +bool +Value::isArray() const +{ + return type_ == nullValue || type_ == arrayValue; +} + + +bool +Value::isObject() const +{ + return type_ == nullValue || type_ == objectValue; +} + + +void +Value::setComment( const char *comment, + CommentPlacement placement ) +{ + if ( !comments_ ) + comments_ = new CommentInfo[numberOfCommentPlacement]; + comments_[placement].setComment( comment ); +} + + +void +Value::setComment( const std::string &comment, + CommentPlacement placement ) +{ + setComment( comment.c_str(), placement ); +} + + +bool +Value::hasComment( CommentPlacement placement ) const +{ + return comments_ != 0 && comments_[placement].comment_ != 0; +} + +std::string +Value::getComment( CommentPlacement placement ) const +{ + if ( hasComment(placement) ) + return comments_[placement].comment_; + return ""; +} + + +std::string +Value::toStyledString() const +{ + StyledWriter writer; + return writer.write( *this ); +} + + +Value::const_iterator +Value::begin() const +{ + switch ( type_ ) + { +#ifdef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + if ( value_.array_ ) + { + ValueInternalArray::IteratorState it; + value_.array_->makeBeginIterator( it ); + return const_iterator( it ); + } + break; + case objectValue: + if ( value_.map_ ) + { + ValueInternalMap::IteratorState it; + value_.map_->makeBeginIterator( it ); + return const_iterator( it ); + } + break; +#else + case arrayValue: + case objectValue: + if ( value_.map_ ) + return const_iterator( value_.map_->begin() ); + break; +#endif + default: + break; + } + return const_iterator(); +} + +Value::const_iterator +Value::end() const +{ + switch ( type_ ) + { +#ifdef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + if ( value_.array_ ) + { + ValueInternalArray::IteratorState it; + value_.array_->makeEndIterator( it ); + return const_iterator( it ); + } + break; + case objectValue: + if ( value_.map_ ) + { + ValueInternalMap::IteratorState it; + value_.map_->makeEndIterator( it ); + return const_iterator( it ); + } + break; +#else + case arrayValue: + case objectValue: + if ( value_.map_ ) + return const_iterator( value_.map_->end() ); + break; +#endif + default: + break; + } + return const_iterator(); +} + + +Value::iterator +Value::begin() +{ + switch ( type_ ) + { +#ifdef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + if ( value_.array_ ) + { + ValueInternalArray::IteratorState it; + value_.array_->makeBeginIterator( it ); + return iterator( it ); + } + break; + case objectValue: + if ( value_.map_ ) + { + ValueInternalMap::IteratorState it; + value_.map_->makeBeginIterator( it ); + return iterator( it ); + } + break; +#else + case arrayValue: + case objectValue: + if ( value_.map_ ) + return iterator( value_.map_->begin() ); + break; +#endif + default: + break; + } + return iterator(); +} + +Value::iterator +Value::end() +{ + switch ( type_ ) + { +#ifdef JSON_VALUE_USE_INTERNAL_MAP + case arrayValue: + if ( value_.array_ ) + { + ValueInternalArray::IteratorState it; + value_.array_->makeEndIterator( it ); + return iterator( it ); + } + break; + case objectValue: + if ( value_.map_ ) + { + ValueInternalMap::IteratorState it; + value_.map_->makeEndIterator( it ); + return iterator( it ); + } + break; +#else + case arrayValue: + case objectValue: + if ( value_.map_ ) + return iterator( value_.map_->end() ); + break; +#endif + default: + break; + } + return iterator(); +} + + +// class PathArgument +// ////////////////////////////////////////////////////////////////// + +PathArgument::PathArgument() + : kind_( kindNone ) +{ +} + + +PathArgument::PathArgument( Value::UInt index ) + : index_( index ) + , kind_( kindIndex ) +{ +} + + +PathArgument::PathArgument( const char *key ) + : key_( key ) + , kind_( kindKey ) +{ +} + + +PathArgument::PathArgument( const std::string &key ) + : key_( key.c_str() ) + , kind_( kindKey ) +{ +} + +// class Path +// ////////////////////////////////////////////////////////////////// + +Path::Path( const std::string &path, + const PathArgument &a1, + const PathArgument &a2, + const PathArgument &a3, + const PathArgument &a4, + const PathArgument &a5 ) +{ + InArgs in; + in.push_back( &a1 ); + in.push_back( &a2 ); + in.push_back( &a3 ); + in.push_back( &a4 ); + in.push_back( &a5 ); + makePath( path, in ); +} + + +void +Path::makePath( const std::string &path, + const InArgs &in ) +{ + const char *current = path.c_str(); + const char *end = current + path.length(); + InArgs::const_iterator itInArg = in.begin(); + while ( current != end ) + { + if ( *current == '[' ) + { + ++current; + if ( *current == '%' ) + addPathInArg( path, in, itInArg, PathArgument::kindIndex ); + else + { + Value::UInt index = 0; + for ( ; current != end && *current >= '0' && *current <= '9'; ++current ) + index = index * 10 + Value::UInt(*current - '0'); + args_.push_back( index ); + } + if ( current == end || *current++ != ']' ) + invalidPath( path, int(current - path.c_str()) ); + } + else if ( *current == '%' ) + { + addPathInArg( path, in, itInArg, PathArgument::kindKey ); + ++current; + } + else if ( *current == '.' ) + { + ++current; + } + else + { + const char *beginName = current; + while ( current != end && !strchr( "[.", *current ) ) + ++current; + args_.push_back( std::string( beginName, current ) ); + } + } +} + + +void +Path::addPathInArg( const std::string &path, + const InArgs &in, + InArgs::const_iterator &itInArg, + PathArgument::Kind kind ) +{ + if ( itInArg == in.end() ) + { + // Error: missing argument %d + } + else if ( (*itInArg)->kind_ != kind ) + { + // Error: bad argument type + } + else + { + args_.push_back( **itInArg ); + } +} + + +void +Path::invalidPath( const std::string &path, + int location ) +{ + // Error: invalid path. +} + + +const Value & +Path::resolve( const Value &root ) const +{ + const Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) + { + // Error: unable to resolve path (array value expected at position... + } + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + { + // Error: unable to resolve path (object value expected at position...) + } + node = &((*node)[arg.key_]); + if ( node == &Value::null ) + { + // Error: unable to resolve path (object has no member named '' at position...) + } + } + } + return *node; +} + + +Value +Path::resolve( const Value &root, + const Value &defaultValue ) const +{ + const Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) + return defaultValue; + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + return defaultValue; + node = &((*node)[arg.key_]); + if ( node == &Value::null ) + return defaultValue; + } + } + return *node; +} + + +Value & +Path::make( Value &root ) const +{ + Value *node = &root; + for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) + { + const PathArgument &arg = *it; + if ( arg.kind_ == PathArgument::kindIndex ) + { + if ( !node->isArray() ) + { + // Error: node is not an array at position ... + } + node = &((*node)[arg.index_]); + } + else if ( arg.kind_ == PathArgument::kindKey ) + { + if ( !node->isObject() ) + { + // Error: node is not an object at position... + } + node = &((*node)[arg.key_]); + } + } + return *node; +} + + +} // namespace Json diff --git a/src/jsoncpp/src/lib_json/json_valueiterator.inl b/src/jsoncpp/src/lib_json/json_valueiterator.inl new file mode 100644 index 0000000000..736e260ea0 --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_valueiterator.inl @@ -0,0 +1,292 @@ +// included by json_value.cpp +// everything is within Json namespace + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class ValueIteratorBase +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +ValueIteratorBase::ValueIteratorBase() +#ifndef JSON_VALUE_USE_INTERNAL_MAP + : current_() + , isNull_( true ) +{ +} +#else + : isArray_( true ) + , isNull_( true ) +{ + iterator_.array_ = ValueInternalArray::IteratorState(); +} +#endif + + +#ifndef JSON_VALUE_USE_INTERNAL_MAP +ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator ¤t ) + : current_( current ) + , isNull_( false ) +{ +} +#else +ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state ) + : isArray_( true ) +{ + iterator_.array_ = state; +} + + +ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state ) + : isArray_( false ) +{ + iterator_.map_ = state; +} +#endif + +Value & +ValueIteratorBase::deref() const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + return current_->second; +#else + if ( isArray_ ) + return ValueInternalArray::dereference( iterator_.array_ ); + return ValueInternalMap::value( iterator_.map_ ); +#endif +} + + +void +ValueIteratorBase::increment() +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + ++current_; +#else + if ( isArray_ ) + ValueInternalArray::increment( iterator_.array_ ); + ValueInternalMap::increment( iterator_.map_ ); +#endif +} + + +void +ValueIteratorBase::decrement() +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + --current_; +#else + if ( isArray_ ) + ValueInternalArray::decrement( iterator_.array_ ); + ValueInternalMap::decrement( iterator_.map_ ); +#endif +} + + +ValueIteratorBase::difference_type +ValueIteratorBase::computeDistance( const SelfType &other ) const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP +# ifdef JSON_USE_CPPTL_SMALLMAP + return current_ - other.current_; +# else + // Iterator for null value are initialized using the default + // constructor, which initialize current_ to the default + // std::map::iterator. As begin() and end() are two instance + // of the default std::map::iterator, they can not be compared. + // To allow this, we handle this comparison specifically. + if ( isNull_ && other.isNull_ ) + { + return 0; + } + + + // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL, + // which is the one used by default). + // Using a portable hand-made version for non random iterator instead: + // return difference_type( std::distance( current_, other.current_ ) ); + difference_type myDistance = 0; + for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it ) + { + ++myDistance; + } + return myDistance; +# endif +#else + if ( isArray_ ) + return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ ); + return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ ); +#endif +} + + +bool +ValueIteratorBase::isEqual( const SelfType &other ) const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + if ( isNull_ ) + { + return other.isNull_; + } + return current_ == other.current_; +#else + if ( isArray_ ) + return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ ); + return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ ); +#endif +} + + +void +ValueIteratorBase::copy( const SelfType &other ) +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + current_ = other.current_; +#else + if ( isArray_ ) + iterator_.array_ = other.iterator_.array_; + iterator_.map_ = other.iterator_.map_; +#endif +} + + +Value +ValueIteratorBase::key() const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + const Value::CZString czstring = (*current_).first; + if ( czstring.c_str() ) + { + if ( czstring.isStaticString() ) + return Value( StaticString( czstring.c_str() ) ); + return Value( czstring.c_str() ); + } + return Value( czstring.index() ); +#else + if ( isArray_ ) + return Value( ValueInternalArray::indexOf( iterator_.array_ ) ); + bool isStatic; + const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic ); + if ( isStatic ) + return Value( StaticString( memberName ) ); + return Value( memberName ); +#endif +} + + +UInt +ValueIteratorBase::index() const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + const Value::CZString czstring = (*current_).first; + if ( !czstring.c_str() ) + return czstring.index(); + return Value::UInt( -1 ); +#else + if ( isArray_ ) + return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) ); + return Value::UInt( -1 ); +#endif +} + + +const char * +ValueIteratorBase::memberName() const +{ +#ifndef JSON_VALUE_USE_INTERNAL_MAP + const char *name = (*current_).first.c_str(); + return name ? name : ""; +#else + if ( !isArray_ ) + return ValueInternalMap::key( iterator_.map_ ); + return ""; +#endif +} + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class ValueConstIterator +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +ValueConstIterator::ValueConstIterator() +{ +} + + +#ifndef JSON_VALUE_USE_INTERNAL_MAP +ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator ¤t ) + : ValueIteratorBase( current ) +{ +} +#else +ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state ) + : ValueIteratorBase( state ) +{ +} + +ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state ) + : ValueIteratorBase( state ) +{ +} +#endif + +ValueConstIterator & +ValueConstIterator::operator =( const ValueIteratorBase &other ) +{ + copy( other ); + return *this; +} + + +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// class ValueIterator +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////////// + +ValueIterator::ValueIterator() +{ +} + + +#ifndef JSON_VALUE_USE_INTERNAL_MAP +ValueIterator::ValueIterator( const Value::ObjectValues::iterator ¤t ) + : ValueIteratorBase( current ) +{ +} +#else +ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state ) + : ValueIteratorBase( state ) +{ +} + +ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state ) + : ValueIteratorBase( state ) +{ +} +#endif + +ValueIterator::ValueIterator( const ValueConstIterator &other ) + : ValueIteratorBase( other ) +{ +} + +ValueIterator::ValueIterator( const ValueIterator &other ) + : ValueIteratorBase( other ) +{ +} + +ValueIterator & +ValueIterator::operator =( const SelfType &other ) +{ + copy( other ); + return *this; +} diff --git a/src/jsoncpp/src/lib_json/json_writer.cpp b/src/jsoncpp/src/lib_json/json_writer.cpp new file mode 100644 index 0000000000..051d0dcbbb --- /dev/null +++ b/src/jsoncpp/src/lib_json/json_writer.cpp @@ -0,0 +1,829 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER >= 1400 // VC++ 8.0 +#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated. +#endif + +namespace Json { + +static bool isControlCharacter(char ch) +{ + return ch > 0 && ch <= 0x1F; +} + +static bool containsControlCharacter( const char* str ) +{ + while ( *str ) + { + if ( isControlCharacter( *(str++) ) ) + return true; + } + return false; +} +static void uintToString( unsigned int value, + char *¤t ) +{ + *--current = 0; + do + { + *--current = (value % 10) + '0'; + value /= 10; + } + while ( value != 0 ); +} + +std::string valueToString( Int value ) +{ + char buffer[32]; + char *current = buffer + sizeof(buffer); + bool isNegative = value < 0; + if ( isNegative ) + value = -value; + uintToString( UInt(value), current ); + if ( isNegative ) + *--current = '-'; + assert( current >= buffer ); + return current; +} + + +std::string valueToString( UInt value ) +{ + char buffer[32]; + char *current = buffer + sizeof(buffer); + uintToString( value, current ); + assert( current >= buffer ); + return current; +} + +std::string valueToString( double value ) +{ + char buffer[32]; +#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005 to avoid warning. + sprintf_s(buffer, sizeof(buffer), "%#.16g", value); +#else + sprintf(buffer, "%#.16g", value); +#endif + char* ch = buffer + strlen(buffer) - 1; + if (*ch != '0') return buffer; // nothing to truncate, so save time + while(ch > buffer && *ch == '0'){ + --ch; + } + char* last_nonzero = ch; + while(ch >= buffer){ + switch(*ch){ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + --ch; + continue; + case '.': + // Truncate zeroes to save bytes in output, but keep one. + *(last_nonzero+2) = '\0'; + return buffer; + default: + return buffer; + } + } + return buffer; +} + + +std::string valueToString( bool value ) +{ + return value ? "true" : "false"; +} + +std::string valueToQuotedString( const char *value ) +{ + // Not sure how to handle unicode... + if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value )) + return std::string("\"") + value + "\""; + // We have to walk value and escape any special characters. + // Appending to std::string is not efficient, but this should be rare. + // (Note: forward slashes are *not* rare, but I am not escaping them.) + unsigned maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL + std::string result; + result.reserve(maxsize); // to avoid lots of mallocs + result += "\""; + for (const char* c=value; *c != 0; ++c) + { + switch(*c) + { + case '\"': + result += "\\\""; + break; + case '\\': + result += "\\\\"; + break; + case '\b': + result += "\\b"; + break; + case '\f': + result += "\\f"; + break; + case '\n': + result += "\\n"; + break; + case '\r': + result += "\\r"; + break; + case '\t': + result += "\\t"; + break; + //case '/': + // Even though \/ is considered a legal escape in JSON, a bare + // slash is also legal, so I see no reason to escape it. + // (I hope I am not misunderstanding something. + // blep notes: actually escaping \/ may be useful in javascript to avoid (*c); + result += oss.str(); + } + else + { + result += *c; + } + break; + } + } + result += "\""; + return result; +} + +// Class Writer +// ////////////////////////////////////////////////////////////////// +Writer::~Writer() +{ +} + + +// Class FastWriter +// ////////////////////////////////////////////////////////////////// + +FastWriter::FastWriter() + : yamlCompatiblityEnabled_( false ) +{ +} + + +void +FastWriter::enableYAMLCompatibility() +{ + yamlCompatiblityEnabled_ = true; +} + + +std::string +FastWriter::write( const Value &root ) +{ + document_ = ""; + writeValue( root ); + document_ += "\n"; + return document_; +} + + +void +FastWriter::writeValue( const Value &value ) +{ + switch ( value.type() ) + { + case nullValue: + document_ += "null"; + break; + case intValue: + document_ += valueToString( value.asInt() ); + break; + case uintValue: + document_ += valueToString( value.asUInt() ); + break; + case realValue: + document_ += valueToString( value.asDouble() ); + break; + case stringValue: + document_ += valueToQuotedString( value.asCString() ); + break; + case booleanValue: + document_ += valueToString( value.asBool() ); + break; + case arrayValue: + { + document_ += "["; + int size = value.size(); + for ( int index =0; index < size; ++index ) + { + if ( index > 0 ) + document_ += ","; + writeValue( value[index] ); + } + document_ += "]"; + } + break; + case objectValue: + { + Value::Members members( value.getMemberNames() ); + document_ += "{"; + for ( Value::Members::iterator it = members.begin(); + it != members.end(); + ++it ) + { + const std::string &name = *it; + if ( it != members.begin() ) + document_ += ","; + document_ += valueToQuotedString( name.c_str() ); + document_ += yamlCompatiblityEnabled_ ? ": " + : ":"; + writeValue( value[name] ); + } + document_ += "}"; + } + break; + } +} + + +// Class StyledWriter +// ////////////////////////////////////////////////////////////////// + +StyledWriter::StyledWriter() + : rightMargin_( 74 ) + , indentSize_( 3 ) +{ +} + + +std::string +StyledWriter::write( const Value &root ) +{ + document_ = ""; + addChildValues_ = false; + indentString_ = ""; + writeCommentBeforeValue( root ); + writeValue( root ); + writeCommentAfterValueOnSameLine( root ); + document_ += "\n"; + return document_; +} + + +void +StyledWriter::writeValue( const Value &value ) +{ + switch ( value.type() ) + { + case nullValue: + pushValue( "null" ); + break; + case intValue: + pushValue( valueToString( value.asInt() ) ); + break; + case uintValue: + pushValue( valueToString( value.asUInt() ) ); + break; + case realValue: + pushValue( valueToString( value.asDouble() ) ); + break; + case stringValue: + pushValue( valueToQuotedString( value.asCString() ) ); + break; + case booleanValue: + pushValue( valueToString( value.asBool() ) ); + break; + case arrayValue: + writeArrayValue( value); + break; + case objectValue: + { + Value::Members members( value.getMemberNames() ); + if ( members.empty() ) + pushValue( "{}" ); + else + { + writeWithIndent( "{" ); + indent(); + Value::Members::iterator it = members.begin(); + while ( true ) + { + const std::string &name = *it; + const Value &childValue = value[name]; + writeCommentBeforeValue( childValue ); + writeWithIndent( valueToQuotedString( name.c_str() ) ); + document_ += " : "; + writeValue( childValue ); + if ( ++it == members.end() ) + { + writeCommentAfterValueOnSameLine( childValue ); + break; + } + document_ += ","; + writeCommentAfterValueOnSameLine( childValue ); + } + unindent(); + writeWithIndent( "}" ); + } + } + break; + } +} + + +void +StyledWriter::writeArrayValue( const Value &value ) +{ + unsigned size = value.size(); + if ( size == 0 ) + pushValue( "[]" ); + else + { + bool isArrayMultiLine = isMultineArray( value ); + if ( isArrayMultiLine ) + { + writeWithIndent( "[" ); + indent(); + bool hasChildValue = !childValues_.empty(); + unsigned index =0; + while ( true ) + { + const Value &childValue = value[index]; + writeCommentBeforeValue( childValue ); + if ( hasChildValue ) + writeWithIndent( childValues_[index] ); + else + { + writeIndent(); + writeValue( childValue ); + } + if ( ++index == size ) + { + writeCommentAfterValueOnSameLine( childValue ); + break; + } + document_ += ","; + writeCommentAfterValueOnSameLine( childValue ); + } + unindent(); + writeWithIndent( "]" ); + } + else // output on a single line + { + assert( childValues_.size() == size ); + document_ += "[ "; + for ( unsigned index =0; index < size; ++index ) + { + if ( index > 0 ) + document_ += ", "; + document_ += childValues_[index]; + } + document_ += " ]"; + } + } +} + + +bool +StyledWriter::isMultineArray( const Value &value ) +{ + int size = value.size(); + bool isMultiLine = size*3 >= rightMargin_ ; + childValues_.clear(); + for ( int index =0; index < size && !isMultiLine; ++index ) + { + const Value &childValue = value[index]; + isMultiLine = isMultiLine || + ( (childValue.isArray() || childValue.isObject()) && + childValue.size() > 0 ); + } + if ( !isMultiLine ) // check if line length > max line length + { + childValues_.reserve( size ); + addChildValues_ = true; + int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]' + for ( int index =0; index < size && !isMultiLine; ++index ) + { + writeValue( value[index] ); + lineLength += int( childValues_[index].length() ); + isMultiLine = isMultiLine && hasCommentForValue( value[index] ); + } + addChildValues_ = false; + isMultiLine = isMultiLine || lineLength >= rightMargin_; + } + return isMultiLine; +} + + +void +StyledWriter::pushValue( const std::string &value ) +{ + if ( addChildValues_ ) + childValues_.push_back( value ); + else + document_ += value; +} + + +void +StyledWriter::writeIndent() +{ + if ( !document_.empty() ) + { + char last = document_[document_.length()-1]; + if ( last == ' ' ) // already indented + return; + if ( last != '\n' ) // Comments may add new-line + document_ += '\n'; + } + document_ += indentString_; +} + + +void +StyledWriter::writeWithIndent( const std::string &value ) +{ + writeIndent(); + document_ += value; +} + + +void +StyledWriter::indent() +{ + indentString_ += std::string( indentSize_, ' ' ); +} + + +void +StyledWriter::unindent() +{ + assert( int(indentString_.size()) >= indentSize_ ); + indentString_.resize( indentString_.size() - indentSize_ ); +} + + +void +StyledWriter::writeCommentBeforeValue( const Value &root ) +{ + if ( !root.hasComment( commentBefore ) ) + return; + document_ += normalizeEOL( root.getComment( commentBefore ) ); + document_ += "\n"; +} + + +void +StyledWriter::writeCommentAfterValueOnSameLine( const Value &root ) +{ + if ( root.hasComment( commentAfterOnSameLine ) ) + document_ += " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) ); + + if ( root.hasComment( commentAfter ) ) + { + document_ += "\n"; + document_ += normalizeEOL( root.getComment( commentAfter ) ); + document_ += "\n"; + } +} + + +bool +StyledWriter::hasCommentForValue( const Value &value ) +{ + return value.hasComment( commentBefore ) + || value.hasComment( commentAfterOnSameLine ) + || value.hasComment( commentAfter ); +} + + +std::string +StyledWriter::normalizeEOL( const std::string &text ) +{ + std::string normalized; + normalized.reserve( text.length() ); + const char *begin = text.c_str(); + const char *end = begin + text.length(); + const char *current = begin; + while ( current != end ) + { + char c = *current++; + if ( c == '\r' ) // mac or dos EOL + { + if ( *current == '\n' ) // convert dos EOL + ++current; + normalized += '\n'; + } + else // handle unix EOL & other char + normalized += c; + } + return normalized; +} + + +// Class StyledStreamWriter +// ////////////////////////////////////////////////////////////////// + +StyledStreamWriter::StyledStreamWriter( std::string indentation ) + : document_(NULL) + , rightMargin_( 74 ) + , indentation_( indentation ) +{ +} + + +void +StyledStreamWriter::write( std::ostream &out, const Value &root ) +{ + document_ = &out; + addChildValues_ = false; + indentString_ = ""; + writeCommentBeforeValue( root ); + writeValue( root ); + writeCommentAfterValueOnSameLine( root ); + *document_ << "\n"; + document_ = NULL; // Forget the stream, for safety. +} + + +void +StyledStreamWriter::writeValue( const Value &value ) +{ + switch ( value.type() ) + { + case nullValue: + pushValue( "null" ); + break; + case intValue: + pushValue( valueToString( value.asInt() ) ); + break; + case uintValue: + pushValue( valueToString( value.asUInt() ) ); + break; + case realValue: + pushValue( valueToString( value.asDouble() ) ); + break; + case stringValue: + pushValue( valueToQuotedString( value.asCString() ) ); + break; + case booleanValue: + pushValue( valueToString( value.asBool() ) ); + break; + case arrayValue: + writeArrayValue( value); + break; + case objectValue: + { + Value::Members members( value.getMemberNames() ); + if ( members.empty() ) + pushValue( "{}" ); + else + { + writeWithIndent( "{" ); + indent(); + Value::Members::iterator it = members.begin(); + while ( true ) + { + const std::string &name = *it; + const Value &childValue = value[name]; + writeCommentBeforeValue( childValue ); + writeWithIndent( valueToQuotedString( name.c_str() ) ); + *document_ << " : "; + writeValue( childValue ); + if ( ++it == members.end() ) + { + writeCommentAfterValueOnSameLine( childValue ); + break; + } + *document_ << ","; + writeCommentAfterValueOnSameLine( childValue ); + } + unindent(); + writeWithIndent( "}" ); + } + } + break; + } +} + + +void +StyledStreamWriter::writeArrayValue( const Value &value ) +{ + unsigned size = value.size(); + if ( size == 0 ) + pushValue( "[]" ); + else + { + bool isArrayMultiLine = isMultineArray( value ); + if ( isArrayMultiLine ) + { + writeWithIndent( "[" ); + indent(); + bool hasChildValue = !childValues_.empty(); + unsigned index =0; + while ( true ) + { + const Value &childValue = value[index]; + writeCommentBeforeValue( childValue ); + if ( hasChildValue ) + writeWithIndent( childValues_[index] ); + else + { + writeIndent(); + writeValue( childValue ); + } + if ( ++index == size ) + { + writeCommentAfterValueOnSameLine( childValue ); + break; + } + *document_ << ","; + writeCommentAfterValueOnSameLine( childValue ); + } + unindent(); + writeWithIndent( "]" ); + } + else // output on a single line + { + assert( childValues_.size() == size ); + *document_ << "[ "; + for ( unsigned index =0; index < size; ++index ) + { + if ( index > 0 ) + *document_ << ", "; + *document_ << childValues_[index]; + } + *document_ << " ]"; + } + } +} + + +bool +StyledStreamWriter::isMultineArray( const Value &value ) +{ + int size = value.size(); + bool isMultiLine = size*3 >= rightMargin_ ; + childValues_.clear(); + for ( int index =0; index < size && !isMultiLine; ++index ) + { + const Value &childValue = value[index]; + isMultiLine = isMultiLine || + ( (childValue.isArray() || childValue.isObject()) && + childValue.size() > 0 ); + } + if ( !isMultiLine ) // check if line length > max line length + { + childValues_.reserve( size ); + addChildValues_ = true; + int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]' + for ( int index =0; index < size && !isMultiLine; ++index ) + { + writeValue( value[index] ); + lineLength += int( childValues_[index].length() ); + isMultiLine = isMultiLine && hasCommentForValue( value[index] ); + } + addChildValues_ = false; + isMultiLine = isMultiLine || lineLength >= rightMargin_; + } + return isMultiLine; +} + + +void +StyledStreamWriter::pushValue( const std::string &value ) +{ + if ( addChildValues_ ) + childValues_.push_back( value ); + else + *document_ << value; +} + + +void +StyledStreamWriter::writeIndent() +{ + /* + Some comments in this method would have been nice. ;-) + + if ( !document_.empty() ) + { + char last = document_[document_.length()-1]; + if ( last == ' ' ) // already indented + return; + if ( last != '\n' ) // Comments may add new-line + *document_ << '\n'; + } + */ + *document_ << '\n' << indentString_; +} + + +void +StyledStreamWriter::writeWithIndent( const std::string &value ) +{ + writeIndent(); + *document_ << value; +} + + +void +StyledStreamWriter::indent() +{ + indentString_ += indentation_; +} + + +void +StyledStreamWriter::unindent() +{ + assert( indentString_.size() >= indentation_.size() ); + indentString_.resize( indentString_.size() - indentation_.size() ); +} + + +void +StyledStreamWriter::writeCommentBeforeValue( const Value &root ) +{ + if ( !root.hasComment( commentBefore ) ) + return; + *document_ << normalizeEOL( root.getComment( commentBefore ) ); + *document_ << "\n"; +} + + +void +StyledStreamWriter::writeCommentAfterValueOnSameLine( const Value &root ) +{ + if ( root.hasComment( commentAfterOnSameLine ) ) + *document_ << " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) ); + + if ( root.hasComment( commentAfter ) ) + { + *document_ << "\n"; + *document_ << normalizeEOL( root.getComment( commentAfter ) ); + *document_ << "\n"; + } +} + + +bool +StyledStreamWriter::hasCommentForValue( const Value &value ) +{ + return value.hasComment( commentBefore ) + || value.hasComment( commentAfterOnSameLine ) + || value.hasComment( commentAfter ); +} + + +std::string +StyledStreamWriter::normalizeEOL( const std::string &text ) +{ + std::string normalized; + normalized.reserve( text.length() ); + const char *begin = text.c_str(); + const char *end = begin + text.length(); + const char *current = begin; + while ( current != end ) + { + char c = *current++; + if ( c == '\r' ) // mac or dos EOL + { + if ( *current == '\n' ) // convert dos EOL + ++current; + normalized += '\n'; + } + else // handle unix EOL & other char + normalized += c; + } + return normalized; +} + + +std::ostream& operator<<( std::ostream &sout, const Value &root ) +{ + Json::StyledStreamWriter writer; + writer.write(sout, root); + return sout; +} + + +} // namespace Json diff --git a/src/jsoncpp/src/lib_json/sconscript b/src/jsoncpp/src/lib_json/sconscript new file mode 100644 index 0000000000..f6520d185a --- /dev/null +++ b/src/jsoncpp/src/lib_json/sconscript @@ -0,0 +1,8 @@ +Import( 'env buildLibrary' ) + +buildLibrary( env, Split( """ + json_reader.cpp + json_value.cpp + json_writer.cpp + """ ), + 'json' ) diff --git a/src/jsoncpp/version b/src/jsoncpp/version new file mode 100644 index 0000000000..79a2734bbf --- /dev/null +++ b/src/jsoncpp/version @@ -0,0 +1 @@ +0.5.0 \ No newline at end of file diff --git a/src/jsonxx/LICENSE b/src/jsonxx/LICENSE deleted file mode 100644 index 4fa4c1dc39..0000000000 --- a/src/jsonxx/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Since a few people have asked me, I figured I'd put a LICENSE file here. I wrote -this small library as an excercise. You are welcome to include jsonxx in your -project and redistributed it with your code in any license, provided that you -don't sue me for anything. Please let me know if you improved it, so that I can -merge your changes. \ No newline at end of file diff --git a/src/jsonxx/README.txt b/src/jsonxx/README.txt deleted file mode 100644 index 11e19fbff1..0000000000 --- a/src/jsonxx/README.txt +++ /dev/null @@ -1,44 +0,0 @@ -h1. Introduction - -JSON++ is a light-weight JSON parser written in C++. - -h2. Why another JSON parser? - -Perhaps because web service clients are usually written in dynamic -languages these days, none of the existing C++ JSON parsers suite my -needs very well, so I wrote one to used in another project. My goals -for JSON++ were: -* Efficient in both memory and speed. -* No third party dependencies. JSON++ only depends on the standard C++ library. -* Cross platform. -* Robust. -* Small and convenient API. Most of the time, you only need to call one function and two function templates. -* Easy to integrate. JSON++ only has one source file and one header file. Just compile the source file and link with your program. - -h3. Usage - -The following snippet is from one of the unit tests. It's quite self-descriptive. - -
-
-string teststr(
-        "{"
-        "  \"foo\" : 1,"
-        "  \"bar\" : false,"
-        "  \"person\" : {\"name\" : \"GWB\", \"age\" : 60},"
-        "  \"data\": [\"abcd\", 42]"
-        "}"
-               );
-istringstream input(teststr);
-Object o;
-assert(o.parse(input));
-assert(1 == o.get("foo"));
-assert(o.has("bar"));
-assert(o.has("person"));
-assert(o.get("person").has("age"));
-assert(o.has("data"));
-assert(o.get("data").get(1) == 42);
-assert(o.get("data").get(0) == "abcd");
-assert(!o.has("data"));
-
-
diff --git a/src/jsonxx/jsonxx.cc b/src/jsonxx/jsonxx.cc
deleted file mode 100644
index a6742dc461..0000000000
--- a/src/jsonxx/jsonxx.cc
+++ /dev/null
@@ -1,264 +0,0 @@
-// Author: Hong Jiang 
-
-#include "jsonxx.h"
-
-#include 
-#include 
-#include 
-
-namespace jsonxx {
-
-void eat_whitespaces(std::istream& input) {
-    char ch;
-    do {
-        input.get(ch);
-    } while(isspace(ch));
-    input.putback(ch);
-}
-
-// Try to consume characters from the input stream and match the
-// pattern string. Leading whitespaces from the input are ignored if
-// ignore_ws is true.
-bool match(const std::string& pattern, std::istream& input,
-           bool ignore_ws = true) {
-    if (ignore_ws) {
-        eat_whitespaces(input);
-    }
-    std::string::const_iterator cur(pattern.begin());
-    char ch(0);
-    while(input && !input.eof() && cur != pattern.end()) {
-        input.get(ch);
-        if (ch != *cur) {
-            input.putback(ch);
-            return false;
-        } else {
-            cur++;
-        }
-    }
-    return cur == pattern.end();
-}
-
-bool parse_string(std::istream& input, std::string* value) {
-    if (!match("\"", input))  {
-        return false;
-    }
-    char ch;
-    while(!input.eof() && input.good()) {
-        input.get(ch);
-        if (ch == '"') {
-            break;
-        }
-        value->push_back(ch);
-    }
-    if (input && ch == '"') {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-bool parse_bool(std::istream& input, bool* value) {
-    if (match("true", input))  {
-        *value = true;
-        return true;
-    }
-    if (match("false", input)) {
-        *value = false;
-        return true;
-    }
-    return false;
-}
-
-bool parse_null(std::istream& input) {
-    if (match("null", input))  {
-        return true;
-    }
-    return false;
-}
-
-bool parse_number(std::istream& input, long* value) {
-    eat_whitespaces(input);
-    char ch;
-    std::string value_str;
-    int sign = 1;
-    if (match("-", input)) {
-        sign = -1;
-    } else {
-        match("+", input);
-    }
-    while(input && !input.eof()) {
-        input.get(ch);
-        if (!isdigit(ch)) {
-            input.putback(ch);
-            break;
-        }
-        value_str.push_back(ch);
-    }
-    if (value_str.size() > 0) {
-        std::istringstream(value_str) >> *value;
-        return true;
-    } else {
-        return false;
-    }
-}
-
-Object::Object() : value_map_() {}
-
-Object::~Object() {
-    std::map::iterator i;
-    for (i = value_map_.begin(); i != value_map_.end(); ++i) {
-        delete i->second;
-    }
-}
-
-bool Object::parse(std::istream& input) {
-    if (!match("{", input)) {
-        return false;
-    }
-
-    do {
-        std::string key;
-        if (!parse_string(input, &key)) {
-            return false;
-        }
-        if (!match(":", input)) {
-            return false;
-        }
-        Value* v = new Value();
-        if (!v->parse(input)) {
-            delete v;
-            break;
-        }
-        value_map_[key] = v;
-    } while (match(",", input));
-
-    if (!match("}", input)) {
-        return false;
-    }
-    return true;
-}
-
-Value::Value() : type_(INVALID_) {}
-
-Value::~Value() {
-    if (type_ == STRING_) {
-        delete string_value_;
-    }
-    if (type_ == OBJECT_) {
-        delete object_value_;
-    }
-    if (type_ == ARRAY_) {
-        delete array_value_;
-    }
-}
-
-bool Value::parse(std::istream& input) {
-    std::string string_value;
-    if (parse_string(input, &string_value)) {
-        string_value_ = new std::string();
-        string_value_->swap(string_value);
-        type_ = STRING_;
-        return true;
-    }
-    if (parse_number(input, &integer_value_)) {
-        type_ = INTEGER_;
-        return true;
-    }
-
-    if (parse_bool(input, &bool_value_)) {
-        type_ = BOOL_;
-        return true;
-    }
-    if (parse_null(input)) {
-        type_ = NULL_;
-        return true;
-    }
-    array_value_ = new Array();
-    if (array_value_->parse(input)) {
-        type_ = ARRAY_;
-        return true;
-    }
-    delete array_value_;
-    object_value_ = new Object();
-    if (object_value_->parse(input)) {
-        type_ = OBJECT_;
-        return true;
-    }
-    delete object_value_;
-    return false;
-}
-
-Array::Array() : values_() {}
-
-Array::~Array() {
-    for (unsigned int i = 0; i < values_.size(); ++i) {
-        delete values_[i];
-    }
-}
-
-bool Array::parse(std::istream& input) {
-    if (!match("[", input)) {
-        return false;
-    }
-
-    do {
-        Value* v = new Value();
-        if (!v->parse(input)) {
-            delete v;
-            break;
-        }
-        values_.push_back(v);
-    } while (match(",", input));
-
-    if (!match("]", input)) {
-        return false;
-    }
-    return true;
-}
-
-}  // namespace jsonxx
-
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Value& v) {
-  if (v.is()) {
-    return stream << v.get();
-  } else if (v.is()) {
-    return stream << '"'  << v.get() << '"';
-  } else if (v.is()) {
-    if (v.get()) {
-      return stream << "true";
-    } else {
-      return stream << "false";
-    }
-  } else if (v.is()) {
-    return stream << "null";
-  } else if (v.is()) {
-    return stream << v.get();
-  } else if (v.is()){
-    return stream << v.get();
-  }
-  // Shouldn't reach here.
-  return stream;
-}
-
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Array& v) {
-  stream << "[";
-  const std::vector& values(v.values());
-  for (unsigned int i = 0; i < values.size()-1; ++i) {
-    stream << *(values[i]) << ", ";
-  }
-  return stream << *(values[values.size()-1]) << "]";
-}
-
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Object& v) {
-  stream << "{";
-  const std::map& kv(v.kv_map());
-  for (std::map::const_iterator i = kv.begin();
-       i != kv.end(); /**/) {
-    stream << i->first << ": " << *(i->second);
-    ++i;
-    if ( i != kv.end()) {
-      stream << ", ";
-    }
-  }
-  return stream << "}";
-}
diff --git a/src/jsonxx/jsonxx.h b/src/jsonxx/jsonxx.h
deleted file mode 100644
index 276548989e..0000000000
--- a/src/jsonxx/jsonxx.h
+++ /dev/null
@@ -1,226 +0,0 @@
-#ifndef JSONXX_H
-#define JSONXX_H
-// Author: Hong Jiang 
-
-#include 
-#include 
-#include 
-#include 
-
-namespace jsonxx {
-
-// TODO: *::parse() should be static functions.
-
-class Value;
-
-// A JSON Object
-class Object {
- public:
-  Object();
-  ~Object();
-  bool parse(std::istream& input);
-
-  template 
-  bool has(const std::string& key) const;
-
-  // Always call has<>() first. If the key doesn't exist, consider
-  // the behavior undefined.
-  template 
-  T& get(const std::string& key) const;
-
-  const std::map& kv_map() const { return value_map_; }
- private:
-  Object(const Object&);
-  Object& operator=(const Object&);
-
-  std::map value_map_;
-};
-
-class Value;
-
-class Array {
- public:
-  Array();
-  ~Array();
-  bool parse(std::istream& input);
-
-  unsigned int size() const { return values_.size(); }
-
-  template 
-  bool has(unsigned int i) const;
-
-  template 
-  T& get(unsigned int i) const;
-
-  const std::vector& values() const {
-    return values_;
-  }
-
- private:
-  Array(const Array&);
-  Array& operator=(const Array&);
-  std::vector values_;
-};
-
-// A value could be a number, an array, a string, an object, a
-// boolean, or null
-class Value {
- public:
-  class Null {};
-
-  Value();
-  ~Value();
-  bool parse(std::istream& input);
-  template
-  bool is() const;
-  template
-  T& get();
-  template
-  const T& get() const;
- private:
-  Value(const Value&);
-  Value& operator=(const Value&);
-  enum {
-    INTEGER_,
-    STRING_,
-    BOOL_,
-    NULL_,
-    ARRAY_,
-    OBJECT_,
-    INVALID_
-  } type_;
-  union {
-    long integer_value_;
-    std::string* string_value_;
-    bool bool_value_;
-    Array* array_value_;
-    Object* object_value_;
-  };
-};
-
-template 
-bool Array::has(unsigned int i) const {
-  if (i >= size()) {
-    return false;
-  } else {
-    Value* v = values_.at(i);
-    return v->is();
-  }
-}
-
-template 
-T& Array::get(unsigned int i) const {
-  assert(i < size());
-  Value* v = values_.at(i);
-  return v->get();
-}
-
-template 
-bool Object::has(const std::string& key) const {
-  std::map::const_iterator it(value_map_.find(key));
-  return it != value_map_.end() && it->second->is();
-}
-
-template 
-T& Object::get(const std::string& key) const {
-  assert(has(key));
-  return value_map_.find(key)->second->get();
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == NULL_;
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == BOOL_;
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == STRING_;
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == INTEGER_;
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == ARRAY_;
-}
-
-template<>
-inline bool Value::is() const {
-  return type_ == OBJECT_;
-}
-
-template<>
-inline bool& Value::get() {
-  assert(is());
-  return bool_value_;
-}
-
-template<>
-inline std::string& Value::get() {
-  assert(is());
-  return *string_value_;
-}
-
-template<>
-inline long& Value::get() {
-  assert(is());
-  return integer_value_;
-}
-
-template<>
-inline Array& Value::get() {
-  assert(is());
-  return *array_value_;
-}
-
-template<>
-inline Object& Value::get() {
-  assert(is());
-  return *object_value_;
-}
-
-template<>
-inline const bool& Value::get() const {
-  assert(is());
-  return bool_value_;
-}
-
-template<>
-inline const std::string& Value::get() const {
-  assert(is());
-  return *string_value_;
-}
-
-template<>
-inline const long& Value::get() const {
-  assert(is());
-  return integer_value_;
-}
-
-template<>
-inline const Array& Value::get() const {
-  assert(is());
-  return *array_value_;
-}
-
-template<>
-inline const Object& Value::get() const {
-  assert(is());
-  return *object_value_;
-}
-
-}  // namespace jsonxx
-
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Value& v);
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Object& v);
-std::ostream& operator<<(std::ostream& stream, const jsonxx::Array& v);
-
-#endif
\ No newline at end of file
diff --git a/src/jsonxx/jsonxx_test.cc b/src/jsonxx/jsonxx_test.cc
deleted file mode 100644
index a357b5ee02..0000000000
--- a/src/jsonxx/jsonxx_test.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-// Author: Hong Jiang 
-
-#include 
-#include 
-#include 
-
-#include "jsonxx.h"
-
-namespace jsonxx {
-bool parse_string(std::istream& input, std::string* value);
-bool parse_number(std::istream& input, long* value);
-bool match(const std::string& pattern, std::istream& input, bool ignore_ws = true);
-}
-
-int main() {
-    using namespace jsonxx;
-    using namespace std;
-    {
-        string teststr("\"field1\"");
-        string value;
-        istringstream input(teststr);
-        assert(parse_string(input, &value));
-    }
-    {
-        string teststr("\"  field1\"");
-        string value;
-        istringstream input(teststr);
-        assert(parse_string(input, &value));
-    }
-    {
-        string teststr("  \"field1\"");
-        string value;
-        istringstream input(teststr);
-        assert(parse_string(input, &value));
-    }
-    {
-        string teststr("6");
-        istringstream input(teststr);
-        long value;
-        assert(parse_number(input, &value));
-    }
-    {
-        string teststr(" }");
-        istringstream input(teststr);
-        assert(match("}", input));
-    }
-    {
-        string teststr("{ \"field1\" : 6 }");
-        istringstream input(teststr);
-        Object o;
-        assert(o.parse(input));
-    }
-    {
-        string teststr("{ \"field1 : 6 }");
-        istringstream input(teststr);
-        Object o;
-        assert(!o.parse(input));
-    }
-    {
-        string teststr("6");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-    }
-    {
-        string teststr("+6");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-    }
-    {
-        string teststr("-6");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-    }
-    {
-        string teststr("asdf");
-        istringstream input(teststr);
-        Value v;
-        assert(!v.parse(input));
-    }
-    {
-        string teststr("true");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-        assert(v.is());
-    }
-    {
-        string teststr("false");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-        assert(v.is());
-        assert(v.get() == false);
-    }
-    {
-        string teststr("null");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-        assert(v.is());
-        assert(!v.is());
-    }
-    {
-        string teststr("\"field1\"");
-        istringstream input(teststr);
-        Value v;
-        assert(v.parse(input));
-        assert(v.is());
-        assert("field1" == v.get());
-        ostringstream stream;
-        stream << v;
-        assert(stream.str() == "\"field1\"");
-    }
-    {
-        string teststr("[\"field1\", 6]");
-        istringstream input(teststr);
-        Array v;
-        assert(v.parse(input));
-        assert(v.has(0));
-        assert("field1" == v.get(0));
-        assert(v.has(1));
-        assert(6 == v.get(1));
-        assert(!v.has(2));
-    }
-    {
-        string teststr(
-                "{"
-                "  \"foo\" : 1,"
-                "  \"bar\" : false,"
-                "  \"person\" : {\"name\" : \"GWB\", \"age\" : 60},"
-                "  \"data\": [\"abcd\", 42]"
-                "}"
-                       );
-        istringstream input(teststr);
-        Object o;
-        assert(o.parse(input));
-        assert(1 == o.get("foo"));
-        assert(o.has("bar"));
-        assert(o.has("person"));
-        assert(o.get("person").has("age"));
-        assert(o.has("data"));
-        assert(o.get("data").get(1) == 42);
-        assert(o.get("data").get(0) == "abcd");
-        assert(!o.has("data"));
-    }
-}
diff --git a/src/jsonxx/source.txt b/src/jsonxx/source.txt
deleted file mode 100644
index 027e6527d3..0000000000
--- a/src/jsonxx/source.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-http://hjiang.net/archives/245
-and
-http://github.com/hjiang/jsonxx
\ No newline at end of file