changed need-power-indicator to the classic blinking symbol

power messages fade out a lot faster
messages are also shown when a producer/consumer returns to giving/needing 0 power
rope
David Dormagen 2012-02-19 17:02:29 +01:00
parent 2262e1a8a9
commit 3b093ac0de
3 changed files with 19 additions and 21 deletions

View File

@ -42,8 +42,8 @@ func FadeOut(int speed, step)
func FxFadeOutTimer(target, effect)
{
if(alpha < 5) return RemoveObject();
alpha -= effect.step;
if(alpha < 5) return RemoveObject();
Update();
return 1;
}
@ -60,7 +60,8 @@ func SetColor(int r2, g2, b2, a)
func Update()
{
this->Message(Format("@<c %x>%s</c>", RGBa(r, g, b, alpha), msg));
// the lacking </c> is on purpose
this->Message(Format("@<c %x><c %x>%s</c>", RGBa(255, 255, 255, alpha), RGBa(r, g, b, alpha), msg));
}
public func Initialize()

View File

@ -74,6 +74,7 @@ func AddPowerLink(object p, int a, bool surpress_balance_check)
{
var n = {obj = p, amount = a};
var before = 0;
var found = false;
var first_empty = -1;
var diff = 0;
@ -98,7 +99,11 @@ func AddPowerLink(object p, int a, bool surpress_balance_check)
diff = a - o.amount;
power_balance += diff;
if(a == 0) power_links[i] = nil;
if(a == 0)
{
before = power_links[i].amount;
power_links[i] = nil;
}
else power_links[i] = n;
break;
}
@ -118,17 +123,21 @@ func AddPowerLink(object p, int a, bool surpress_balance_check)
}
diff = n.amount;
if(diff > 0)
if((diff > 0) || ((a == 0) && (before > 0)))
{
var t = CreateObject(FloatingMessage, n.obj->GetX() - GetX(), n.obj->GetY() - GetY(), NO_OWNER);
t->SetMessage(Format("<c 00ff00>+%d</c>{{Library_PowerConsumer}}", diff));
t->SetMessage(Format("+%d</c>{{Library_PowerConsumer}}", diff));
t->SetColor(0, 255, 0);
t->SetYDir(-10);
t->FadeOut(4, 8);
}
else if(diff < 0)
else if((diff < 0) || ((a == 0) && (before < 0)))
{
var t = CreateObject(FloatingMessage, n.obj->GetX() - GetX(), n.obj->GetY() - GetY(), NO_OWNER);
t->SetMessage(Format("<c ff0000>%d</c>{{Library_PowerConsumer}}", diff));
t->SetMessage(Format("%d</c>{{Library_PowerConsumer}}", diff));
t->SetColor(255, 0, 0);
t->SetYDir(-10);
t->FadeOut(4, 8);
}
if(n.amount < 0)
n.obj->~OnEnoughPower(); // might be reverted soon, though

View File

@ -35,9 +35,7 @@ public func OnNotEnoughPower()
PowerConsumer_has_power = false;
// show symbol
if(GetEffect("ShowPowerMessage", this))
FatalError("OnNotEnoughPower() called two times in a row!");
AddEffect("ShowPowerMessage", this, 1, 10, this);
this->AddStatusSymbol(Library_PowerConsumer);
}
// called when consumer was sleeping but power is available again
@ -46,17 +44,7 @@ public func OnEnoughPower()
PowerConsumer_has_power = true;
// remove symbol
if(GetEffect("ShowPowerMessage", this))
RemoveEffect("ShowPowerMessage", this);
}
public func FxShowPowerMessageTimer(target, effect, time)
{
if(effect.Interval < 35*3)
effect.Interval = 35*3;
var t = CreateObject(FloatingMessage, 0, 0, NO_OWNER);
t->SetMessage("{{Library_PowerConsumer}}<c ff0000>?</c>");
t->SetYDir(-10);
this->RemoveStatusSymbol(Library_PowerConsumer);
}
func Destruction()