Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 23, 2009, 7:44:49 PM (14 years ago)
Author:
rgrieder
Message:

Simplified our resource system a bit by working with a single resource group on the user end.
However you can still declare resource groups for separate loading. But accessing the files will always look in all groups.

Location:
code/branches/presentation2/data
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/DataInstallScript.cmake

    r5781 r6404  
    2929
    3030# Write some comment
    31 FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr "\n\n\n <!-- ---------------------------------------- -->")
    32 FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr     "\n <!-- Content from the external data directory -->")
    33 FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr     "\n <!-- ---------------------------------------- -->\n\n")
     31FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr "\n\n\n <!-- ---------------------------------------- -->")
     32FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr     "\n <!-- Content from the external data directory -->")
     33FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr     "\n <!-- ---------------------------------------- -->\n\n")
    3434
    3535# Append the external file
    3636FILE(READ   @EXTERNAL_DATA_DIRECTORY@/resources.oxr _external_file)
    37 FILE(APPEND @DATA_INSTALL_DIRECTORY@/resources.oxr ${_external_file})
     37FILE(APPEND @DATA_INSTALL_DIRECTORY@/DefaultResources.oxr ${_external_file})
  • code/branches/presentation2/data/lua/LuaStateInit.lua

    r6403 r6404  
    1515
    1616-- Redirect dofile in order to load with the resource manager
    17 -- Note: The function does not behave exactly like LuaState::doFile because the
    18 --       default argument here for the group is not "General" but
    19 --       "NoResourceGroupProvided". This resolves to the resource group used to
    20 --       do the current file.
    21 doFile = function(filename, resourceGroup)
    22   local bSearchOtherPaths = (resourceGroup == nil) or false
    23   resourceGroup = resourceGroup or "NoResourceGroupProvided"
    24   luaState:doFile(filename, resourceGroup, bSearchOtherPaths)
     17doFile = function(filename)
     18  luaState:doFile(filename)
    2519  -- Required because the C++ function cannot return whatever might be on the stack
    26   return LuaStateReturnValue
     20  return LuaStateReturnValue -- C-injected global variable
    2721end
    2822original_dofile = dofile
     
    3125-- Create includeFile function that preparses the file according
    3226-- to a function provided to the LuaState constructor (in C++)
    33 -- Note: See the same notes as for doFile
    34 include = function(filename, resourceGroup)
    35   local bSearchOtherPaths = (resourceGroup == nil) or false
    36   resourceGroup = resourceGroup or "NoResourceGroupProvided"
    37   luaState:includeFile(filename, resourceGroup, bSearchOtherPaths)
     27include = function(filename)
     28  luaState:includeFile(filename)
    3829  -- Required because the C++ function cannot return whatever might be on the stack
    39   return LuaStateReturnValue
     30  return LuaStateReturnValue -- C-injected global variable
    4031end
    4132
    4233-- Replace require function with almost similar behaviour
    43 -- The difference is that you need to provide a resource group
    44 -- Default value there is the current one (if present) or else "General"
    45 -- But the loaded modules are then stored with only with the name (where name has no .lua extension)
    46 -- CAUTION: That also means that you need to take care of conflicting filenames among groups
    47 -- Furthermore the moduleName parameters is appended with the .lua extension when looking for the file
     34-- The loaded modules are then stored with their names (where name has no .lua extension)
     35-- Furthermore the ".lua" extension is appended to the moduleName parameter when looking for the file
    4836old_require = require
    49 require = function(moduleName, resourceGroup)
    50   local bSearchOtherPaths = (resourceGroup == nil) or false
    51   resourceGroup = resourceGroup or "NoResourceGroupProvided"
    52   if not luaState:fileExists(moduleName .. ".lua", resourceGroup, bSearchOtherPaths) then
     37require = function(moduleName)
     38  if not luaState:fileExists(moduleName .. ".lua") then
    5339    return nil
    5440  end
     
    6046    _REQUIREDNAME_OLD = _REQUIREDNAME
    6147    _REQUIREDNAME = moduleName
    62     luaState:doFile(moduleName .. ".lua", resourceGroup, bSearchOtherPaths)
     48    luaState:doFile(moduleName .. ".lua")
    6349    _LOADED[moduleName] = LuaStateReturnValue or true
    6450    -- restore old value
Note: See TracChangeset for help on using the changeset viewer.