- Added !SetOption/!SetOptionGroup bangs.

- Script: Added GetOption() function
This commit is contained in:
Birunthan Mohanathas
2011-07-27 10:42:35 +00:00
parent 23f4a31bf0
commit 822c10060a
19 changed files with 235 additions and 329 deletions

View File

@ -2,12 +2,34 @@
#include "../LuaManager.h"
#include "../../Meter.h"
static int Meter_HasDynamicVariables(lua_State* L)
static int Meter_GetName(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool val = self->HasDynamicVariables();
tolua_pushboolean(L, val);
const WCHAR* val = (const WCHAR*)self->GetName();
push_wchar(L, val);
return 1;
}
static int Meter_GetOption(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
CMeterWindow* meterWindow = self->GetMeterWindow();
CConfigParser& parser = meterWindow->GetParser();
const char* arg = (const char*)tolua_tostring(L, 2, 0);
std::wstring strTmp = ConvertToWide(arg);
strTmp = parser.GetValue(self->GetName(), strTmp, L"");
parser.SetBuiltInVariable(L"CURRENTSECTION", self->GetName()); // Set temporarily
parser.ReplaceVariables(strTmp);
parser.SetBuiltInVariable(L"CURRENTSECTION", L""); // Reset
if (self->HasDynamicVariables())
{
parser.ReplaceMeasures(strTmp);
}
push_wchar(L, strTmp.c_str());
return 1;
}
@ -15,7 +37,7 @@ static int Meter_GetW(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
int val = (int)self->GetW();
tolua_pushnumber(L, (lua_Number)val);
lua_pushnumber(L, (lua_Number)val);
return 1;
}
@ -24,7 +46,7 @@ static int Meter_GetH(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
int val = (int)self->GetH();
tolua_pushnumber(L, (lua_Number)val);
lua_pushnumber(L, (lua_Number)val);
return 1;
@ -35,7 +57,7 @@ static int Meter_GetX(lua_State* L)
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool abs = ((bool)tolua_toboolean(L, 2, false));
int val = (int)self->GetX(abs);
tolua_pushnumber(L, (lua_Number)val);
lua_pushnumber(L, (lua_Number)val);
return 1;
}
@ -45,7 +67,7 @@ static int Meter_GetY(lua_State* L)
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool abs = ((bool)tolua_toboolean(L, 2, false));
int val = (int)self->GetY(abs);
tolua_pushnumber(L, (lua_Number)val);
lua_pushnumber(L, (lua_Number)val);
return 1;
}
@ -86,60 +108,6 @@ static int Meter_SetY(lua_State* L)
return 0;
}
static int Meter_GetToolTipText(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
const std::wstring& val = self->GetToolTipText();
push_wchar(L, val.c_str());
return 1;
}
static int Meter_HasToolTip(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool val = self->HasToolTip();
tolua_pushboolean(L, val);
return 1;
}
static int Meter_SetToolTipHidden(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool b = (bool)tolua_toboolean(L, 2, 0);
self->SetToolTipHidden(b);
return 0;
}
static int Meter_HasMouseAction(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool val = self->HasMouseAction();
tolua_pushboolean(L, val);
return 1;
}
static int Meter_HasMouseActionCursor(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool val = self->HasMouseActionCursor();
tolua_pushboolean(L, val);
return 1;
}
static int Meter_SetMouseActionCursor(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool b = (bool)tolua_toboolean(L, 2, 0);
self->SetMouseActionCursor(b);
return 0;
}
static int Meter_Hide(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
@ -156,30 +124,14 @@ static int Meter_Show(lua_State* L)
return 0;
}
static int Meter_IsHidden(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
bool val = self->IsHidden();
tolua_pushboolean(L, val);
return 1;
}
static int Meter_GetName(lua_State* L)
{
CMeter* self = (CMeter*)tolua_tousertype(L, 1, 0);
const WCHAR* val = (const WCHAR*)self->GetName();
push_wchar(L, val);
return 1;
}
void LuaManager::RegisterMeter(lua_State* L)
{
tolua_usertype(L, "CMeter");
tolua_cclass(L, "CMeter", "CMeter", "CGroup", NULL);
tolua_beginmodule(L, "CMeter");
tolua_function(L, "HasDynamicVariables", Meter_HasDynamicVariables);
tolua_function(L, "GetName", Meter_GetName);
tolua_function(L, "GetOption", Meter_GetOption);
tolua_function(L, "GetW", Meter_GetW);
tolua_function(L, "GetH", Meter_GetH);
tolua_function(L, "GetX", Meter_GetX);
@ -188,15 +140,7 @@ void LuaManager::RegisterMeter(lua_State* L)
tolua_function(L, "SetH", Meter_SetH);
tolua_function(L, "SetX", Meter_SetX);
tolua_function(L, "SetY", Meter_SetY);
tolua_function(L, "GetToolTipText", Meter_GetToolTipText);
tolua_function(L, "HasToolTip", Meter_HasToolTip);
tolua_function(L, "SetToolTipHidden", Meter_SetToolTipHidden);
tolua_function(L, "HasMouseAction", Meter_HasMouseAction);
tolua_function(L, "HasMouseActionCursor", Meter_HasMouseActionCursor);
tolua_function(L, "SetMouseActionCursor", Meter_SetMouseActionCursor);
tolua_function(L, "Hide", Meter_Hide);
tolua_function(L, "Show", Meter_Show);
tolua_function(L, "IsHidden", Meter_IsHidden);
tolua_function(L, "GetName", Meter_GetName);
tolua_endmodule(L);
}