add some more flexibility for live reloading of ui, allow using frames in panel graphics
This commit is contained in:
parent
c172559e1d
commit
99579eea94
8 changed files with 61 additions and 9 deletions
src
include/ui
spell
tolua
ui
video
|
@ -155,6 +155,7 @@ public:
|
|||
|
||||
private:
|
||||
std::string graphic;
|
||||
int frame;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -123,6 +123,18 @@ char Ccl2Condition(lua_State *l, const char *value)
|
|||
return CONDITION_FALSE;
|
||||
} else if (!strcmp(value, "only")) {
|
||||
return CONDITION_ONLY;
|
||||
} else if (value[0] == '<') {
|
||||
int v = atoi(value + 1);
|
||||
if (v > 100) {
|
||||
LuaError(l, "Can only encode condition '<' up to 100%%, got %d" _C_ v);
|
||||
}
|
||||
return -v;
|
||||
} else if (value[0] == '>') {
|
||||
int v = atoi(value + 1);
|
||||
if (v > 100) {
|
||||
LuaError(l, "Can only encode condition '<' up to 100%%, got %d" _C_ v);
|
||||
}
|
||||
return v + CONDITION_ONLY;
|
||||
} else {
|
||||
LuaError(l, "Bad condition result: %s" _C_ value);
|
||||
return -1;
|
||||
|
|
|
@ -205,6 +205,8 @@ class CUserInterface
|
|||
Vec2i EditorSettingsAreaBottomRight;
|
||||
Vec2i EditorButtonAreaTopLeft;
|
||||
Vec2i EditorButtonAreaBottomRight;
|
||||
|
||||
void Load();
|
||||
};
|
||||
|
||||
extern CUserInterface UI;
|
||||
|
@ -688,3 +690,6 @@ void UiTrackUnit();
|
|||
void SetNewViewportMode(ViewportModeType new_mode);
|
||||
|
||||
void SetDefaultTextColors(const std::string &normal, const std::string &reverse);
|
||||
|
||||
void LoadDecorations();
|
||||
void InitUserInterface();
|
||||
|
|
|
@ -269,7 +269,11 @@ static const CUnit *GetUnitRef(const CUnit &unit, EnumUnit e)
|
|||
{
|
||||
CGraphic *g = CGraphic::Get(this->graphic);
|
||||
if (g) {
|
||||
g->DrawClip(this->Pos.x, this->Pos.y);
|
||||
if (this->frame) {
|
||||
g->DrawFrameClip(this->frame, this->Pos.x, this->Pos.y);
|
||||
} else {
|
||||
g->DrawClip(this->Pos.x, this->Pos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +520,19 @@ static EnumUnit Str2EnumUnit(lua_State *l, const char *s)
|
|||
|
||||
/* virtual */ void CContentTypeGraphic::Parse(lua_State *l)
|
||||
{
|
||||
this->graphic = LuaToString(l, -1);
|
||||
if (lua_isstring(l, -1)) {
|
||||
this->graphic = LuaToString(l, -1);
|
||||
this->frame = 0;
|
||||
} else if (lua_istable(l, -1)) {
|
||||
for (lua_pushnil(l); lua_next(l, -2); lua_pop(l, 1)) {
|
||||
const char *key = LuaToString(l, -2);
|
||||
if (!strcmp(key, "Graphic")) {
|
||||
this->graphic = LuaToString(l, -1);
|
||||
} else if (!strcmp(key, "Frame")) {
|
||||
this->frame = LuaToNumber(l, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CContentTypeLifeBar::Parse(lua_State *l)
|
||||
|
|
|
@ -866,7 +866,7 @@ static void InputKey(int key)
|
|||
} else
|
||||
#endif
|
||||
if (!IsNetworkGame()) {
|
||||
if (!GameObserve && !GamePaused && !GameEstablishing) {
|
||||
if (!GameObserve && !GameEstablishing) {
|
||||
if (HandleCheats(Input)) {
|
||||
CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, Input, -1);
|
||||
}
|
||||
|
|
|
@ -229,8 +229,25 @@ static bool CanShowContent(const ConditionPanel *condition, const CUnit &unit)
|
|||
}
|
||||
if (condition->Variables) {
|
||||
for (unsigned int i = 0; i < UnitTypeVar.GetNumberVariable(); ++i) {
|
||||
if (condition->Variables[i] != CONDITION_TRUE) {
|
||||
if ((condition->Variables[i] == CONDITION_ONLY) ^ unit.Variable[i].Enable) {
|
||||
char v = condition->Variables[i];
|
||||
if (v < 0) {
|
||||
// only show for less than -v%
|
||||
if (unit.Variable[i].Enable) {
|
||||
const int f = (100 * unit.Variable[i].Value) / unit.Variable[i].Max;
|
||||
if (f >= -v) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (v > CONDITION_ONLY) {
|
||||
// only show for more than (v-CONDITION_ONLY)%
|
||||
if (unit.Variable[i].Enable) {
|
||||
const int f = (100 * unit.Variable[i].Value) / unit.Variable[i].Max;
|
||||
if (f <= v - CONDITION_ONLY) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (v != CONDITION_TRUE) {
|
||||
if ((v == CONDITION_ONLY) ^ unit.Variable[i].Enable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -205,6 +205,11 @@ void InitUserInterface()
|
|||
UI.Offset640X = (Video.Width - 640) / 2;
|
||||
UI.Offset480Y = (Video.Height - 480) / 2;
|
||||
|
||||
UI.LifeBarColorsInt.clear();
|
||||
for(std::vector<std::string>::iterator it = UI.LifeBarColorNames.begin(); it != UI.LifeBarColorNames.end(); ++it) {
|
||||
UI.LifeBarColorsInt.push_back(IndexToColor(GetColorIndexByName((*it).c_str())));
|
||||
}
|
||||
|
||||
//
|
||||
// Calculations
|
||||
//
|
||||
|
|
|
@ -497,10 +497,6 @@ void InitVideoSdl()
|
|||
ColorGreen = Video.MapRGB(TheScreen->format, 0, 252, 0);
|
||||
ColorYellow = Video.MapRGB(TheScreen->format, 252, 252, 0);
|
||||
|
||||
for(std::vector<std::string>::iterator it = UI.LifeBarColorNames.begin(); it != UI.LifeBarColorNames.end(); ++it) {
|
||||
UI.LifeBarColorsInt.push_back(IndexToColor(GetColorIndexByName((*it).c_str())));
|
||||
}
|
||||
|
||||
UI.MouseWarpPos.x = UI.MouseWarpPos.y = -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue