Skip to content

Commit

Permalink
lua logs fade out individually
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Nov 7, 2014
1 parent a801f0a commit 46eda12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/gui/game/GameView.cpp
Expand Up @@ -192,7 +192,6 @@ GameView::GameView():
recordingIndex(0),
toolTipPresence(0),
currentSaveType(0),
lastLogEntry(0.0f),
lastMenu(-1)
{

Expand Down Expand Up @@ -1647,8 +1646,6 @@ void GameView::OnTick(float dt)
toolTipPresence = 0;
}
c->Update();
if(lastLogEntry > -0.1f)
lastLogEntry -= 0.16*dt;
}


Expand Down Expand Up @@ -1823,9 +1820,8 @@ void GameView::NotifyZoomChanged(GameModel * sender)

void GameView::NotifyLogChanged(GameModel * sender, string entry)
{
logEntries.push_front(entry);
lastLogEntry = 100.0f;
if(logEntries.size()>20)
logEntries.push_front(std::pair<std::string, int>(entry, 600));
if (logEntries.size() > 20)
logEntries.pop_back();
}

Expand Down Expand Up @@ -2076,20 +2072,24 @@ void GameView::OnDraw()
Client::Ref().WriteFile(data, filename.str());
}

int startX = 20;
int startY = YRES-20;
int startAlpha;
if(lastLogEntry>0.1f && logEntries.size())
if (logEntries.size())
{
startAlpha = 2.55f*lastLogEntry;
deque<string>::iterator iter;
for(iter = logEntries.begin(); iter != logEntries.end() && startAlpha>0; iter++)
int startX = 20;
int startY = YRES-20;
deque<std::pair<std::string, int>>::iterator iter;
for(iter = logEntries.begin(); iter != logEntries.end(); iter++)
{
string message = (*iter);
string message = (*iter).first;
int alpha = std::min((*iter).second, 255);
if (alpha <= 0) //erase this and everything older
{
logEntries.erase(iter, logEntries.end());
break;
}
startY -= 14;
g->fillrect(startX-3, startY-3, Graphics::textwidth((char*)message.c_str())+6, 14, 0, 0, 0, 100);
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, startAlpha);
startAlpha-=14;
g->drawtext(startX, startY, message.c_str(), 255, 255, 255, alpha);
(*iter).second -= 3;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/gui/game/GameView.h
Expand Up @@ -77,8 +77,7 @@ class GameView: public ui::Window
vector<ui::Button*> menuButtons;
vector<ToolButton*> toolButtons;
vector<ui::Component*> notificationComponents;
deque<string> logEntries;
float lastLogEntry;
deque<std::pair<std::string, int>> logEntries;
ui::Button * scrollBar;
ui::Button * searchButton;
ui::Button * reloadButton;
Expand Down

0 comments on commit 46eda12

Please sign in to comment.