Show number of votes and the history button on your own saves
This commit is contained in:
parent
eac109a563
commit
8f58c61c69
@ -22,7 +22,9 @@ SaveButton::SaveButton(Point position, Point size, SaveInfo * save):
|
|||||||
selectable(false),
|
selectable(false),
|
||||||
selected(false),
|
selected(false),
|
||||||
waitingForThumb(false),
|
waitingForThumb(false),
|
||||||
isMouseInsideAuthor(false)
|
isMouseInsideAuthor(false),
|
||||||
|
MouseInsideHistory(false),
|
||||||
|
showVotes(false)
|
||||||
{
|
{
|
||||||
if(save)
|
if(save)
|
||||||
{
|
{
|
||||||
@ -67,7 +69,9 @@ SaveButton::SaveButton(Point position, Point size, SaveFile * file):
|
|||||||
selected(false),
|
selected(false),
|
||||||
wantsDraw(false),
|
wantsDraw(false),
|
||||||
waitingForThumb(false),
|
waitingForThumb(false),
|
||||||
isMouseInsideAuthor(false)
|
isMouseInsideAuthor(false),
|
||||||
|
MouseInsideHistory(false),
|
||||||
|
showVotes(false)
|
||||||
{
|
{
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
@ -187,6 +191,39 @@ void SaveButton::Draw(const Point& screenPos)
|
|||||||
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 200, 230, 255, 255);
|
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 200, 230, 255, 255);
|
||||||
else
|
else
|
||||||
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255);
|
g->drawtext(screenPos.X+(Size.X-Graphics::textwidth((char *)save->userName.c_str()))/2, screenPos.Y+Size.Y - 10, save->userName, 100, 130, 160, 255);
|
||||||
|
if (!isMouseInside && showVotes)
|
||||||
|
{
|
||||||
|
char icon[64], votestring[64];
|
||||||
|
int j;
|
||||||
|
sprintf(votestring, "%d", save->GetVotesUp()-save->GetVotesDown());
|
||||||
|
icon[0] = 0xBB;
|
||||||
|
for (j = 1; j <= strlen(votestring); j++)
|
||||||
|
icon[j] = 0xBC;
|
||||||
|
icon[j-1] = 0xB9;
|
||||||
|
icon[j] = 0xBA;
|
||||||
|
icon[j+1] = 0;
|
||||||
|
int x = screenPos.X-7+(Size.X-thumbBoxSize.X)/2+thumbBoxSize.X-Graphics::textwidth(icon);
|
||||||
|
int y = screenPos.Y-23+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y;
|
||||||
|
g->drawtext(x, y, icon, 16, 72, 16, 255);
|
||||||
|
for (j=0; icon[j]; j++)
|
||||||
|
icon[j] -= 14;
|
||||||
|
g->drawtext(x, y, icon, 192, 192, 192, 255);
|
||||||
|
for (j=0; votestring[j]; j++)
|
||||||
|
if (votestring[j] != '-')
|
||||||
|
votestring[j] += 127;
|
||||||
|
g->drawtext(x+3, y, votestring, 255, 255, 255, 255);
|
||||||
|
}
|
||||||
|
if (MouseInsideHistory && showVotes)
|
||||||
|
{
|
||||||
|
int x = screenPos.X;
|
||||||
|
int y = screenPos.Y-15+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y;
|
||||||
|
g->fillrect(x+1, y+1, 7, 8, 255, 255, 255, 255);
|
||||||
|
if (MouseInsideHistory) {
|
||||||
|
g->drawtext(x, y, "\xA6", 200, 100, 80, 255);
|
||||||
|
} else {
|
||||||
|
g->drawtext(x, y, "\xA6", 160, 70, 50, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
@ -233,6 +270,8 @@ void SaveButton::OnMouseUnclick(int x, int y, unsigned int button)
|
|||||||
isButtonDown = false;
|
isButtonDown = false;
|
||||||
if(isMouseInsideAuthor)
|
if(isMouseInsideAuthor)
|
||||||
DoAuthorAction();
|
DoAuthorAction();
|
||||||
|
else if (MouseInsideHistory)
|
||||||
|
DoHistoryAction();
|
||||||
else
|
else
|
||||||
DoAction();
|
DoAction();
|
||||||
}
|
}
|
||||||
@ -258,6 +297,13 @@ void SaveButton::OnMouseMovedInside(int x, int y, int dx, int dy)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
isMouseInsideAuthor = false;
|
isMouseInsideAuthor = false;
|
||||||
|
|
||||||
|
if(showVotes && y > Size.Y-29 && y < Size.Y - 18 && x > 0 && x < 9)
|
||||||
|
{
|
||||||
|
MouseInsideHistory = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MouseInsideHistory = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveButton::OnMouseEnter(int x, int y)
|
void SaveButton::OnMouseEnter(int x, int y)
|
||||||
@ -269,6 +315,13 @@ void SaveButton::OnMouseLeave(int x, int y)
|
|||||||
{
|
{
|
||||||
isMouseInside = false;
|
isMouseInside = false;
|
||||||
isMouseInsideAuthor = false;
|
isMouseInsideAuthor = false;
|
||||||
|
MouseInsideHistory = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveButton::DoHistoryAction()
|
||||||
|
{
|
||||||
|
if(actionCallback)
|
||||||
|
actionCallback->HistoryActionCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveButton::DoAuthorAction()
|
void SaveButton::DoAuthorAction()
|
||||||
|
@ -19,6 +19,7 @@ class SaveButtonAction
|
|||||||
public:
|
public:
|
||||||
virtual void ActionCallback(ui::SaveButton * sender) {}
|
virtual void ActionCallback(ui::SaveButton * sender) {}
|
||||||
virtual void AuthorActionCallback(ui::SaveButton * sender) {}
|
virtual void AuthorActionCallback(ui::SaveButton * sender) {}
|
||||||
|
virtual void HistoryActionCallback(ui::SaveButton * sender) {}
|
||||||
virtual void SelectedCallback(ui::SaveButton * sender) {}
|
virtual void SelectedCallback(ui::SaveButton * sender) {}
|
||||||
virtual ~SaveButtonAction() {}
|
virtual ~SaveButtonAction() {}
|
||||||
};
|
};
|
||||||
@ -32,6 +33,8 @@ class SaveButton : public Component, public ThumbnailListener
|
|||||||
bool wantsDraw;
|
bool wantsDraw;
|
||||||
bool waitingForThumb;
|
bool waitingForThumb;
|
||||||
bool isMouseInsideAuthor;
|
bool isMouseInsideAuthor;
|
||||||
|
bool MouseInsideHistory;
|
||||||
|
bool showVotes;
|
||||||
public:
|
public:
|
||||||
SaveButton(Point position, Point size, SaveInfo * save);
|
SaveButton(Point position, Point size, SaveInfo * save);
|
||||||
SaveButton(Point position, Point size, SaveFile * file);
|
SaveButton(Point position, Point size, SaveFile * file);
|
||||||
@ -54,12 +57,14 @@ public:
|
|||||||
bool GetSelected() { return selected; }
|
bool GetSelected() { return selected; }
|
||||||
void SetSelectable(bool selectable_) { selectable = selectable_; }
|
void SetSelectable(bool selectable_) { selectable = selectable_; }
|
||||||
bool GetSelectable() { return selectable; }
|
bool GetSelectable() { return selectable; }
|
||||||
|
void SetShowVotes(bool showVotes_) { showVotes = showVotes_; }
|
||||||
|
|
||||||
SaveInfo * GetSave() { return save; }
|
SaveInfo * GetSave() { return save; }
|
||||||
SaveFile * GetSaveFile() { return file; }
|
SaveFile * GetSaveFile() { return file; }
|
||||||
inline bool GetState() { return state; }
|
inline bool GetState() { return state; }
|
||||||
virtual void DoAction();
|
virtual void DoAction();
|
||||||
virtual void DoAuthorAction();
|
virtual void DoAuthorAction();
|
||||||
|
virtual void DoHistoryAction();
|
||||||
virtual void DoSelection();
|
virtual void DoSelection();
|
||||||
void SetActionCallback(SaveButtonAction * action);
|
void SetActionCallback(SaveButtonAction * action);
|
||||||
protected:
|
protected:
|
||||||
|
@ -596,6 +596,12 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
{
|
{
|
||||||
v->Search("user:"+sender->GetSave()->GetUserName());
|
v->Search("user:"+sender->GetSave()->GetUserName());
|
||||||
}
|
}
|
||||||
|
virtual void HistoryActionCallback(ui::SaveButton * sender)
|
||||||
|
{
|
||||||
|
stringstream search;
|
||||||
|
search << "history:" << sender->GetSave()->GetID();
|
||||||
|
v->Search(search.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
for(i = 0; i < saves.size(); i++)
|
for(i = 0; i < saves.size(); i++)
|
||||||
{
|
{
|
||||||
@ -617,6 +623,8 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
|
|||||||
saveButton->SetActionCallback(new SaveOpenAction(this));
|
saveButton->SetActionCallback(new SaveOpenAction(this));
|
||||||
if(Client::Ref().GetAuthUser().ID)
|
if(Client::Ref().GetAuthUser().ID)
|
||||||
saveButton->SetSelectable(true);
|
saveButton->SetSelectable(true);
|
||||||
|
if (saves[i]->GetUserName() == Client::Ref().GetAuthUser().Username || sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator)
|
||||||
|
saveButton->SetShowVotes(true);
|
||||||
saveButtons.push_back(saveButton);
|
saveButtons.push_back(saveButton);
|
||||||
AddComponent(saveButton);
|
AddComponent(saveButton);
|
||||||
saveX++;
|
saveX++;
|
||||||
|
Loading…
Reference in New Issue
Block a user