Use CclGetPos when possible.

This commit is contained in:
Joris 2012-11-13 17:17:17 +01:00
parent 4d4eb8e86a
commit d90462c010
3 changed files with 8 additions and 52 deletions

View file

@ -686,12 +686,7 @@ static CContentType *CclParseContent(lua_State *l)
for (lua_pushnil(l); lua_next(l, -2); lua_pop(l, 1)) {
const char *key = LuaToString(l, -2);
if (!strcmp(key, "Pos")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
posX = LuaToNumber(l, -2);
posY = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &posX, &posY);
} else if (!strcmp(key, "More")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // Method name
@ -748,12 +743,7 @@ static int CclDefinePanelContents(lua_State *l)
if (!strcmp(key, "Ident")) {
infopanel->Name = LuaToString(l, -1);
} else if (!strcmp(key, "Pos")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
infopanel->PosX = LuaToNumber(l, -2);
infopanel->PosY = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &infopanel->PosX, &infopanel->PosY);
} else if (!strcmp(key, "DefaultFont")) {
infopanel->DefaultFont = CFont::Get(LuaToString(l, -1));
} else if (!strcmp(key, "Condition")) {
@ -1017,12 +1007,7 @@ static PopupConditionPanel *ParsePopupConditions(lua_State *l)
} else if (!strcmp(key, "HighlightColor")) {
highColor = LuaToString(l, -1);
} else if (!strcmp(key, "Margin")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
marginX = LuaToNumber(l, -2);
marginY = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &marginX, &marginY);
} else if (!strcmp(key, "MinWidth")) {
minWidth = LuaToNumber(l, -1);
} else if (!strcmp(key, "MinHeight")) {
@ -1089,12 +1074,7 @@ static int CclDefinePopup(lua_State *l)
} else if (!strcmp(key, "BorderColor")) {
popup->BorderColor = LuaToNumber(l, -1);
} else if (!strcmp(key, "Margin")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
popup->MarginX = LuaToNumber(l, -2);
popup->MarginY = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &popup->MarginX, &popup->MarginY);
} else if (!strcmp(key, "MinWidth")) {
popup->MinWidth = LuaToNumber(l, -1);
} else if (!strcmp(key, "MinHeight")) {

View file

@ -1545,19 +1545,9 @@ static int CclDefineDecorations(lua_State *l)
tmp.Index = UnitTypeVar.VariableNameLookup[value];// User variables
Assert(tmp.Index != -1);
} else if (!strcmp(key, "Offset")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
tmp.OffsetX = LuaToNumber(l, -2);
tmp.OffsetY = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &tmp.OffsetX, &tmp.OffsetY);
} else if (!strcmp(key, "OffsetPercent")) {
Assert(lua_istable(l, -1));
lua_rawgeti(l, -1, 1); // X
lua_rawgeti(l, -2, 2); // Y
tmp.OffsetXPercent = LuaToNumber(l, -2);
tmp.OffsetYPercent = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop X and Y
CclGetPos(l, &tmp.OffsetXPercent, &tmp.OffsetYPercent);
} else if (!strcmp(key, "CenterX")) {
tmp.IsCenteredInX = LuaToBoolean(l, -1);
} else if (!strcmp(key, "CenterY")) {

View file

@ -296,23 +296,9 @@ static int CclDefineSprites(lua_State *l)
} else if (!strcmp(key, "File")) {
deco.File = LuaToString(l, -1);
} else if (!strcmp(key, "Offset")) {
if (!lua_istable(l, -1) || lua_rawlen(l, -1) != 2) {
LuaError(l, "incorrect argument");
}
lua_rawgeti(l, -1, 1); // offsetX
lua_rawgeti(l, -2, 2); // offsetY
deco.HotPos.x = LuaToNumber(l, -2);
deco.HotPos.y = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop offsetX and Y
CclGetPos(l, &deco.HotPos.x, &deco.HotPos.y);
} else if (!strcmp(key, "Size")) {
if (!lua_istable(l, -1) || lua_rawlen(l, -1) != 2) {
LuaError(l, "incorrect argument");
}
lua_rawgeti(l, -1, 1); // Width
lua_rawgeti(l, -2, 2); // Height
deco.Width = LuaToNumber(l, -2);
deco.Height = LuaToNumber(l, -1);
lua_pop(l, 2); // Pop Width and Height
CclGetPos(l, &deco.Width, &deco.Height);
} else { // Error.
LuaError(l, "incorrect field '%s' for the DefineSprite." _C_ key);
}