This commit is contained in:
Birunthan Mohanathas 2012-03-08 15:19:05 +00:00
parent 3905a71af3
commit 04048a6325
6 changed files with 16 additions and 81 deletions

View File

@ -767,14 +767,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="lua\glue\LuaMeterString.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../StdAfx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../../StdAfx.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="lua\glue\LuaMeterWindow.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>

View File

@ -153,9 +153,6 @@
<ClCompile Include="lua\glue\LuaMeter.cpp">
<Filter>Lua\glue</Filter>
</ClCompile>
<ClCompile Include="lua\glue\LuaMeterString.cpp">
<Filter>Lua\glue</Filter>
</ClCompile>
<ClCompile Include="lua\glue\LuaMeterWindow.cpp">
<Filter>Lua\glue</Filter>
</ClCompile>

View File

@ -44,7 +44,6 @@ void LuaManager::Initialize()
RegisterMeasure(c_State);
RegisterMeter(c_State);
RegisterMeterWindow(c_State);
RegisterMeterString(c_State);
tolua_endmodule(c_State);
}

View File

@ -19,6 +19,7 @@
#include "../../StdAfx.h"
#include "../LuaManager.h"
#include "../../Meter.h"
#include "../../MeterString.h"
static int Meter_GetName(lua_State* L)
{
@ -138,6 +139,19 @@ static int Meter_Show(lua_State* L)
return 0;
}
static int Meter_SetText(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
if (CMeterString* stringMeter = dynamic_cast<CMeterString*>(self))
{
std::wstring str = LuaManager::ToWide(L, 2);
stringMeter->SetText(str.c_str());
}
return 0;
}
void LuaManager::RegisterMeter(lua_State* L)
{
tolua_usertype(L, "CMeter");
@ -156,5 +170,6 @@ void LuaManager::RegisterMeter(lua_State* L)
tolua_function(L, "SetY", Meter_SetY);
tolua_function(L, "Hide", Meter_Hide);
tolua_function(L, "Show", Meter_Show);
tolua_function(L, "SetText", Meter_SetText);
tolua_endmodule(L);
}

View File

@ -1,61 +0,0 @@
/*
Copyright (C) 2010 Matt King, Birunthan Mohanathas
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "../../StdAfx.h"
#include "../LuaManager.h"
#include "../../MeterString.h"
static int MeterString_GetX(lua_State* L)
{
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
bool abs = (bool)tolua_toboolean(L, 2, false);
int val = self->GetX(abs);
lua_pushnumber(L, (lua_Number)val);
return 1;
}
static int MeterString_Update(lua_State* L)
{
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
bool val = self->Update();
lua_pushboolean(L, val);
return 1;
}
static int MeterString_SetText(lua_State* L)
{
CMeterString* self = (CMeterString*)tolua_tousertype(L, 1, 0);
std::wstring str = LuaManager::ToWide(L, 2);
self->SetText(str.c_str());
return 0;
}
void LuaManager::RegisterMeterString(lua_State* L)
{
tolua_usertype(L, "CMeterString");
tolua_cclass(L, "CMeterString", "CMeterString", "CMeter", NULL);
tolua_beginmodule(L, "CMeterString");
tolua_function(L, "GetX", MeterString_GetX);
tolua_function(L, "Update", MeterString_Update);
tolua_function(L, "SetText", MeterString_SetText);
tolua_endmodule(L);
}

View File

@ -122,14 +122,7 @@ static int MeterWindow_GetMeter(lua_State* L)
return 0;
}
if (CMeterString* stringMeter = dynamic_cast<CMeterString*>(meter))
{
tolua_pushusertype(L, stringMeter, "CMeterString");
}
else
{
tolua_pushusertype(L, meter, "CMeter");
}
tolua_pushusertype(L, meter, "CMeter");
return 1;
}