Save ID copying for preview
This commit is contained in:
parent
5c293ba9bf
commit
e88fca8aa1
@ -19,7 +19,8 @@ Textbox::Textbox(Point position, Point size, std::string textboxText, std::strin
|
||||
limit(std::string::npos),
|
||||
inputType(All),
|
||||
keyDown(0),
|
||||
characterDown(0)
|
||||
characterDown(0),
|
||||
ReadOnly(false)
|
||||
{
|
||||
placeHolder = textboxPlaceholder;
|
||||
|
||||
@ -268,12 +269,12 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
copySelection();
|
||||
return;
|
||||
}
|
||||
if(ctrl && key == 'v')
|
||||
if(ctrl && key == 'v' && !ReadOnly)
|
||||
{
|
||||
pasteIntoSelection();
|
||||
return;
|
||||
}
|
||||
if(ctrl && key == 'x' && !masked)
|
||||
if(ctrl && key == 'x' && !masked && !ReadOnly)
|
||||
{
|
||||
cutSelection();
|
||||
return;
|
||||
@ -307,6 +308,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_DELETE:
|
||||
if(ReadOnly)
|
||||
break;
|
||||
if(HasSelection())
|
||||
{
|
||||
if(getLowerSelectionBound() < 0 || getHigherSelectionBound() > backingText.length())
|
||||
@ -326,6 +329,8 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
ClearSelection();
|
||||
break;
|
||||
case KEY_BACKSPACE:
|
||||
if(ReadOnly)
|
||||
break;
|
||||
if(HasSelection())
|
||||
{
|
||||
if(getLowerSelectionBound() < 0 || getHigherSelectionBound() > backingText.length())
|
||||
@ -351,7 +356,7 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
ClearSelection();
|
||||
break;
|
||||
}
|
||||
if(CharacterValid(character))
|
||||
if(CharacterValid(character) && !ReadOnly)
|
||||
{
|
||||
if(HasSelection())
|
||||
{
|
||||
|
@ -20,6 +20,7 @@ class Textbox : public Label
|
||||
{
|
||||
friend class TextboxAction;
|
||||
public:
|
||||
bool ReadOnly;
|
||||
enum ValidInput { All, Numeric, Number };
|
||||
Textbox(Point position, Point size, std::string textboxText = "", std::string textboxPlaceholder = "");
|
||||
virtual ~Textbox();
|
||||
|
@ -124,12 +124,9 @@ void PreviewController::FavouriteSave()
|
||||
|
||||
void PreviewController::OpenInBrowser()
|
||||
{
|
||||
if(previewModel->GetSave())
|
||||
{
|
||||
std::stringstream uriStream;
|
||||
uriStream << "http://" << SERVER << "/Browse/View.html?ID=" << previewModel->GetSave()->id;
|
||||
OpenURI(uriStream.str());
|
||||
}
|
||||
std::stringstream uriStream;
|
||||
uriStream << "http://" << SERVER << "/Browse/View.html?ID=" << saveId;
|
||||
OpenURI(uriStream.str());
|
||||
}
|
||||
|
||||
void PreviewController::NextCommentPage()
|
||||
|
@ -25,6 +25,7 @@ class PreviewController: public ClientListener {
|
||||
ControllerCallback * callback;
|
||||
public:
|
||||
virtual void NotifyAuthUserChanged(Client * sender);
|
||||
inline int SaveID() { return saveId; };
|
||||
|
||||
bool HasExited;
|
||||
PreviewController(int saveID, ControllerCallback * callback);
|
||||
|
@ -155,15 +155,45 @@ PreviewView::PreviewView():
|
||||
authorDateLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; authorDateLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||
AddComponent(authorDateLabel);
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
clipboard_push_text((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);
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
void PreviewView::commentBoxAutoHeight()
|
||||
{
|
||||
if(!addCommentBox)
|
||||
|
@ -41,6 +41,7 @@ class PreviewView: public ui::Window {
|
||||
ui::Label * authorDateLabel;
|
||||
ui::Label * pageInfo;
|
||||
ui::Label * saveDescriptionLabel;
|
||||
ui::Textbox * saveIDTextbox;
|
||||
ui::ScrollPanel * commentsPanel;
|
||||
std::vector<SaveComment> comments;
|
||||
std::vector<ui::Component*> commentComponents;
|
||||
@ -59,7 +60,7 @@ class PreviewView: public ui::Window {
|
||||
void commentBoxAutoHeight();
|
||||
void submitComment();
|
||||
public:
|
||||
void AttachController(PreviewController * controller) { c = controller;}
|
||||
void AttachController(PreviewController * controller);
|
||||
PreviewView();
|
||||
void NotifySaveChanged(PreviewModel * sender);
|
||||
void NotifyCommentsChanged(PreviewModel * sender);
|
||||
|
Loading…
Reference in New Issue
Block a user