Changeset 923 – HoverRace

Changeset 923

Show
Ignore:
Timestamp:
03/16/10 00:50:07 (5 months ago)
Author:
zoogie
Message:

Added "Config" class in Lua (C++ peer: ConfigPeer).

Example (in an init script):

local cfg = game:get_config()
cfg:unlink() -- Prevents accidental writing to disk
local w, h = cfg:get_video_res()
print("Video res from config: ", w, h)

Location:
trunk/client
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/client/client.vcproj

    r919 r923  
    234234            </File> 
    235235            <File 
     236                RelativePath=".\Game2\ConfigPeer.cpp" 
     237                > 
     238            </File> 
     239            <File 
     240                RelativePath=".\Game2\ConfigPeer.h" 
     241                > 
     242            </File> 
     243            <File 
    236244                RelativePath=".\Game2\Console.cpp" 
    237245                > 
     
    740748                        Name="VCCustomBuildTool" 
    741749                        Description="$(InputFileName)" 
    742                         CommandLine="copy &quot;$(InputPath)&quot; $(OutDir)" 
     750                        CommandLine="copy &quot;$(InputPath)&quot; $(OutDir)&#x0D;&#x0A;" 
    743751                        Outputs="$(OutDir)\$(InputFileName)" 
    744752                    /> 
     
    751759                        Name="VCCustomBuildTool" 
    752760                        Description="$(InputFileName)" 
    753                         CommandLine="copy &quot;$(InputPath)&quot; $(OutDir)" 
     761                        CommandLine="copy &quot;$(InputPath)&quot; $(OutDir)&#x0D;&#x0A;" 
    754762                        Outputs="$(OutDir)\$(InputFileName)" 
    755763                    /> 
  • trunk/client/Game2/GameApp.cpp

    r918 r923  
    2626#include "GameApp.h" 
    2727#include "AboutDialog.h" 
     28#include "ConfigPeer.h" 
    2829#include "FirstChoiceDialog.h" 
    2930#include "FullscreenTest.h" 
     
    11471148    // This allows the script to modify the configuration (e.g. for unit tests). 
    11481149    scripting = new Script::Core(); 
     1150    ConfigPeer::Register(scripting); 
    11491151    GamePeer::Register(scripting); 
    11501152    gamePeer = new GamePeer(scripting); 
  • trunk/client/Game2/GamePeer.cpp

    r922 r923  
    2323#include "StdAfx.h" 
    2424 
     25#include <luabind/adopt_policy.hpp> 
     26 
    2527#include "../../engine/Script/Core.h" 
     28#include "ConfigPeer.h" 
    2629 
    2730#include "GamePeer.h" 
     
    5861    module(L) [ 
    5962        class_<GamePeer>("Game") 
     63            .def("get_config", &LGetConfig, adopt(result)) 
    6064            .def("get_on_init", &LGetOnInit) 
    6165            .def("on_init", &LOnInit) 
     
    8488    // table 
    8589    lua_pop(L, 1); 
     90} 
     91 
     92ConfigPeer *GamePeer::LGetConfig() 
     93{ 
     94    // function get_config() 
     95    // Returns the game configuration, so it can be modified. 
     96    return new ConfigPeer(scripting); 
    8697} 
    8798 
  • trunk/client/Game2/GamePeer.h

    r922 r923  
    2727 
    2828namespace HoverRace { 
     29    namespace Client { 
     30        class ConfigPeer; 
     31    } 
    2932    namespace Script { 
    3033        class Core; 
     
    5356 
    5457    public: 
     58        ConfigPeer *LGetConfig(); 
     59 
    5560        void LOnInit(const luabind::object &fn); 
    5661        void LGetOnInit();