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