add the single saveID copytext button into the save preview too
This commit is contained in:
parent
a6ee8e2af1
commit
52ec8f438b
@ -1,47 +1,9 @@
|
||||
#include "gui/Style.h"
|
||||
#include "SaveIDMessage.h"
|
||||
#include "gui/interface/Button.h"
|
||||
#include "gui/interface/CopyTextButton.h"
|
||||
#include "gui/interface/Label.h"
|
||||
#include "PowderToy.h"
|
||||
|
||||
class CopyTextButton : public ui::Button
|
||||
{
|
||||
ui::Label *copyTextLabel;
|
||||
public:
|
||||
CopyTextButton(ui::Point position, ui::Point size, std::string buttonText, ui::Label *copyTextLabel_):
|
||||
Button(position, size, buttonText)
|
||||
{
|
||||
copyTextLabel = copyTextLabel_;
|
||||
}
|
||||
|
||||
virtual void OnMouseClick(int x, int y, unsigned int button)
|
||||
{
|
||||
ui::Button::OnMouseClick(x, y, button);
|
||||
ClipboardPush((char*)ButtonText.c_str());
|
||||
|
||||
int textWidth = Graphics::textwidth("Copied!");
|
||||
copyTextLabel->SetText("Copied!");
|
||||
copyTextLabel->Position = ui::Point(Position.X+(Size.X-textWidth)/2-4, copyTextLabel->Position.Y);
|
||||
copyTextLabel->Size = ui::Point(textWidth+20, 16);
|
||||
|
||||
Appearance.TextInactive = ui::Colour(180, 230, 180);
|
||||
Appearance.TextHover = ui::Colour(180, 230, 180);
|
||||
Appearance.BorderInactive = ui::Colour(180, 230, 180);
|
||||
Appearance.BorderHover = ui::Colour(180, 230, 180);
|
||||
}
|
||||
|
||||
virtual void OnMouseEnter(int x, int y)
|
||||
{
|
||||
ui::Button::OnMouseEnter(x, y);
|
||||
copyTextLabel->SetTextColour(ui::Colour(230, 230, 230));
|
||||
}
|
||||
|
||||
virtual void OnMouseLeave(int x, int y)
|
||||
{
|
||||
ui::Button::OnMouseLeave(x, y);
|
||||
copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
|
||||
}
|
||||
};
|
||||
#include "Format.h"
|
||||
|
||||
SaveIDMessage::SaveIDMessage(int id):
|
||||
ui::Window(ui::Point((XRES-244)/2, (YRES-90)/2), ui::Point(244, 90))
|
||||
@ -62,20 +24,11 @@ SaveIDMessage::SaveIDMessage(int id):
|
||||
textWidth = Graphics::textwidth("Click the box below to copy the save ID");
|
||||
ui::Label * copyTextLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, 35), ui::Point(textWidth+20, 16), "Click the box below to copy the save id");
|
||||
copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
|
||||
copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
copyTextLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
copyTextLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
AddComponent(copyTextLabel);
|
||||
|
||||
std::stringstream saveID;
|
||||
saveID << id;
|
||||
textWidth = Graphics::textwidth(saveID.str().c_str());
|
||||
CopyTextButton * copyTextButton = new CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+8, 18), saveID.str(), copyTextLabel);
|
||||
copyTextButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
copyTextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
copyTextButton->Appearance.TextInactive = ui::Colour(150, 150, 150);
|
||||
copyTextButton->Appearance.TextActive = ui::Colour(230, 255, 230);
|
||||
copyTextButton->Appearance.BorderActive = ui::Colour(230, 255, 230);
|
||||
copyTextButton->Appearance.BackgroundActive = style::Colour::InactiveBackground;
|
||||
textWidth = Graphics::textwidth(format::NumberToString<int>(id).c_str());
|
||||
ui::CopyTextButton * copyTextButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, 50), ui::Point(textWidth+10, 18), format::NumberToString<int>(id), copyTextLabel);
|
||||
AddComponent(copyTextButton);
|
||||
|
||||
class DismissAction: public ui::ButtonAction
|
||||
|
@ -11,4 +11,4 @@ public:
|
||||
virtual ~SaveIDMessage();
|
||||
};
|
||||
|
||||
#endif /* ERRORMESSAGE_H_ */
|
||||
#endif /* SAVEIDMESSAGE_H */
|
||||
|
44
src/gui/interface/CopyTextButton.cpp
Normal file
44
src/gui/interface/CopyTextButton.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "CopyTextButton.h"
|
||||
#include "Colour.h"
|
||||
#include "gui/Style.h"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
CopyTextButton::CopyTextButton(Point position, Point size, std::string buttonText, Label *copyTextLabel_):
|
||||
Button(position, size, buttonText)
|
||||
{
|
||||
copyTextLabel = copyTextLabel_;
|
||||
Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
Appearance.TextInactive = ui::Colour(150, 150, 150);
|
||||
Appearance.TextActive = ui::Colour(230, 255, 230);
|
||||
Appearance.BorderActive = ui::Colour(230, 255, 230);
|
||||
Appearance.BackgroundActive = style::Colour::InactiveBackground;
|
||||
}
|
||||
|
||||
void CopyTextButton::OnMouseClick(int x, int y, unsigned int button)
|
||||
{
|
||||
ui::Button::OnMouseClick(x, y, button);
|
||||
ClipboardPush((char*)ButtonText.c_str());
|
||||
|
||||
int textWidth = Graphics::textwidth("Copied!");
|
||||
copyTextLabel->SetText("Copied!");
|
||||
|
||||
Appearance.TextInactive = ui::Colour(180, 230, 180);
|
||||
Appearance.TextHover = ui::Colour(180, 230, 180);
|
||||
Appearance.BorderInactive = ui::Colour(180, 230, 180);
|
||||
Appearance.BorderHover = ui::Colour(180, 230, 180);
|
||||
}
|
||||
|
||||
void CopyTextButton::OnMouseEnter(int x, int y)
|
||||
{
|
||||
ui::Button::OnMouseEnter(x, y);
|
||||
copyTextLabel->SetTextColour(ui::Colour(230, 230, 230));
|
||||
}
|
||||
|
||||
void CopyTextButton::OnMouseLeave(int x, int y)
|
||||
{
|
||||
ui::Button::OnMouseLeave(x, y);
|
||||
copyTextLabel->SetTextColour(ui::Colour(150, 150, 150));
|
||||
}
|
||||
} /* namespace ui */
|
22
src/gui/interface/CopyTextButton.h
Normal file
22
src/gui/interface/CopyTextButton.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef COPYTEXTBUTTON_H
|
||||
#define COPYTEXTBUTTON_H
|
||||
|
||||
#include "Button.h"
|
||||
#include "Label.h"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
class CopyTextButton : public Button
|
||||
{
|
||||
ui::Label *copyTextLabel;
|
||||
public:
|
||||
CopyTextButton(Point position, Point size, std::string buttonText, Label *copyTextLabel_);
|
||||
|
||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||
|
||||
virtual void OnMouseEnter(int x, int y);
|
||||
virtual void OnMouseLeave(int x, int y);
|
||||
};
|
||||
}
|
||||
#endif /* COPYTEXTBUTTON_H */
|
||||
|
@ -189,44 +189,31 @@ PreviewView::PreviewView():
|
||||
viewsLabel->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
||||
viewsLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
AddComponent(viewsLabel);
|
||||
|
||||
|
||||
pageInfo = new ui::Label(ui::Point((XRES/2) + 5, Size.Y+1), ui::Point(Size.X-((XRES/2) + 10), 15), "Page 1 of 1");
|
||||
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
|
||||
saveIDTextbox = new ui::Textbox(ui::Point((XRES/2)-55, Size.Y-40), ui::Point(50, 16), "0000000");
|
||||
saveIDTextbox->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
saveIDTextbox->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
saveIDTextbox->ReadOnly = true;
|
||||
AddComponent(saveIDTextbox);
|
||||
|
||||
class CopyIDAction: public ui::ButtonAction
|
||||
{
|
||||
PreviewView * v;
|
||||
public:
|
||||
CopyIDAction(PreviewView * v_){ v = v_; }
|
||||
virtual void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
ClipboardPush((char*)v->saveIDTextbox->GetText().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
ui::Button * tempButton = new ui::Button(ui::Point((XRES/2)-130, Size.Y-40), ui::Point(70, 16), "Copy Save ID");
|
||||
tempButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
tempButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
tempButton->SetActionCallback(new CopyIDAction(this));
|
||||
AddComponent(tempButton);
|
||||
|
||||
pageInfo = new ui::Label(ui::Point((XRES/2) + 85, Size.Y+1), ui::Point(70, 16), "Page 1 of 1");
|
||||
pageInfo->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
AddComponent(pageInfo);
|
||||
|
||||
commentsPanel = new ui::ScrollPanel(ui::Point((XRES/2)+1, 1), ui::Point((Size.X-(XRES/2))-2, Size.Y-commentBoxHeight));
|
||||
AddComponent(commentsPanel);
|
||||
|
||||
AddComponent(pageInfo);
|
||||
}
|
||||
|
||||
void PreviewView::AttachController(PreviewController * controller)
|
||||
{
|
||||
c = controller;
|
||||
saveIDTextbox->SetText(format::NumberToString<int>(c->SaveID()));
|
||||
|
||||
int textWidth = Graphics::textwidth("Click the box below to copy the save ID");
|
||||
saveIDLabel = new ui::Label(ui::Point((Size.X-textWidth-20)/2, Size.Y+5), ui::Point(textWidth+20, 16), "Click the box below to copy the save ID");
|
||||
saveIDLabel->SetTextColour(ui::Colour(150, 150, 150));
|
||||
saveIDLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
|
||||
AddComponent(saveIDLabel);
|
||||
|
||||
textWidth = Graphics::textwidth(format::NumberToString<int>(c->SaveID()).c_str());
|
||||
saveIDLabel2 = new ui::Label(ui::Point((Size.X-textWidth-20)/2-37, Size.Y+22), ui::Point(40, 16), "Save ID:");
|
||||
AddComponent(saveIDLabel2);
|
||||
|
||||
saveIDButton = new ui::CopyTextButton(ui::Point((Size.X-textWidth-10)/2, Size.Y+20), ui::Point(textWidth+10, 18), format::NumberToString<int>(c->SaveID()), saveIDLabel);
|
||||
AddComponent(saveIDButton);
|
||||
}
|
||||
|
||||
void PreviewView::commentBoxAutoHeight()
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "gui/preview/PreviewController.h"
|
||||
#include "gui/preview/PreviewModel.h"
|
||||
#include "gui/interface/Button.h"
|
||||
#include "gui/interface/CopyTextButton.h"
|
||||
#include "gui/interface/Label.h"
|
||||
#include "gui/interface/Textbox.h"
|
||||
|
||||
@ -38,7 +39,9 @@ class PreviewView: public ui::Window {
|
||||
ui::Label * pageInfo;
|
||||
ui::Label * saveDescriptionLabel;
|
||||
ui::Label * viewsLabel;
|
||||
ui::Textbox * saveIDTextbox;
|
||||
ui::Label * saveIDLabel;
|
||||
ui::Label * saveIDLabel2;
|
||||
ui::CopyTextButton * saveIDButton;
|
||||
ui::ScrollPanel * commentsPanel;
|
||||
std::vector<ui::Component*> commentComponents;
|
||||
std::vector<ui::Component*> commentTextComponents;
|
||||
|
@ -184,6 +184,8 @@ void SearchController::OpenSave(int saveID)
|
||||
{
|
||||
if(activePreview)
|
||||
delete activePreview;
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
g->fillrect(XRES/3, YRES+MENUSIZE-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
|
||||
activePreview = new PreviewController(saveID, new OpenCallback(this));
|
||||
ui::Engine::Ref().ShowWindow(activePreview->GetView());
|
||||
}
|
||||
@ -192,6 +194,8 @@ void SearchController::OpenSave(int saveID, int saveDate)
|
||||
{
|
||||
if(activePreview)
|
||||
delete activePreview;
|
||||
Graphics * g = ui::Engine::Ref().g;
|
||||
g->fillrect(XRES/3, YRES+MENUSIZE-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
|
||||
activePreview = new PreviewController(saveID, saveDate, new OpenCallback(this));
|
||||
ui::Engine::Ref().ShowWindow(activePreview->GetView());
|
||||
}
|
||||
|
Reference in New Issue
Block a user