diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-30 00:40:28 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-30 00:40:28 (GMT) |
| commit | 259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec (patch) | |
| tree | f0fe2c14499345121371bba0ecc3fe21d17e0953 /src/ssave/SSaveView.cpp | |
| parent | fe329e9127ebcb8c89c505c4c120e175810d280c (diff) | |
| download | powder-259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec.zip powder-259fc2bcf75d754af043a5d3fa39b6ee0c0b1dec.tar.gz | |
ASCII for key events, save and Textarea (no caret, yet)
Diffstat (limited to 'src/ssave/SSaveView.cpp')
| -rw-r--r-- | src/ssave/SSaveView.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/ssave/SSaveView.cpp b/src/ssave/SSaveView.cpp new file mode 100644 index 0000000..8a4a482 --- /dev/null +++ b/src/ssave/SSaveView.cpp @@ -0,0 +1,92 @@ +/* + * SSaveView.cpp + * + * Created on: Jan 29, 2012 + * Author: Simon + */ + +#include "SSaveView.h" + +SSaveView::SSaveView(): + ui::Window(ui::Point(-1, -1), ui::Point(200, 200)), + publishCheckbox(NULL), + saveButton(NULL), + closeButton(NULL), + nameField(NULL), + titleLabel(NULL), + descriptionField(NULL) +{ + titleLabel = new ui::Label(ui::Point(2, 1), ui::Point(Size.X-4, 16), "Save to Server"); + titleLabel->SetAlignment(AlignLeft, AlignBottom); + AddComponent(titleLabel); + + nameField = new ui::Textbox(ui::Point(4, 18), ui::Point(Size.X-8, 16), ""); + nameField->SetAlignment(AlignLeft, AlignBottom); + AddComponent(nameField); + + descriptionField = new ui::Textarea(ui::Point(4, 54), ui::Point(Size.X-8, Size.Y-26-54), ""); + AddComponent(descriptionField); + + publishCheckbox = new ui::Checkbox(ui::Point(4, 36), ui::Point(Size.X-8, 16), "Publish"); + AddComponent(publishCheckbox); + + class CloseAction: public ui::ButtonAction + { + SSaveView * v; + public: + CloseAction(SSaveView * v_) { v = v_; }; + void ActionCallback(ui::Button * sender) + { + v->c->Exit(); + } + }; + closeButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(50, 16), "Cancel"); + closeButton->SetActionCallback(new CloseAction(this)); + AddComponent(closeButton); + + class SaveAction: public ui::ButtonAction + { + SSaveView * v; + public: + SaveAction(SSaveView * v_) { v = v_; }; + void ActionCallback(ui::Button * sender) + { + v->c->UploadSave(v->nameField->GetText(), "", v->publishCheckbox->GetChecked()); + } + }; + saveButton = new ui::Button(ui::Point(Size.X-50, Size.Y-16), ui::Point(50, 16), "Save"); + saveButton->SetActionCallback(new SaveAction(this)); + AddComponent(saveButton); +} + +void SSaveView::NotifySaveChanged(SSaveModel * sender) +{ + if(sender->GetSave()) + { + nameField->SetText(sender->GetSave()->GetName()); + publishCheckbox->SetChecked(sender->GetSave()->Published); + } + else + { + nameField->SetText(""); + //publishCheckbox->SetChecked(sender->GetSave()->GetPublished()); + } +} + +void SSaveView::NotifySaveUploadChanged(SSaveModel * sender) +{ + if(sender->GetSaveUploaded()) + c->Exit(); +} + +void SSaveView::OnDraw() +{ + Graphics * g = ui::Engine::Ref().g; + + g->clearrect(Position.X, Position.Y, Size.X, Size.Y); + g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); +} + +SSaveView::~SSaveView() { +} + |
