aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/floaterao.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/floaterao.cpp')
-rw-r--r--linden/indra/newview/floaterao.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/linden/indra/newview/floaterao.cpp b/linden/indra/newview/floaterao.cpp
index d8844d8..5ecd769 100644
--- a/linden/indra/newview/floaterao.cpp
+++ b/linden/indra/newview/floaterao.cpp
@@ -45,6 +45,51 @@ void cmdline_printchat(std::string message)
45} 45}
46 46
47 47
48class AONotecardCallback : public LLInventoryCallback
49{
50public:
51 AONotecardCallback(std::string &filename)
52 {
53 mFileName = filename;
54 }
55
56 void fire(const LLUUID &inv_item)
57 {
58 if (!mFileName.empty())
59 {
60 LLPreviewNotecard* nc;
61 nc = (LLPreviewNotecard*)LLPreview::find(inv_item);
62 if(nc)
63 {
64 nc->open();
65 LLTextEditor *text = nc->getEditor();
66 if (text)
67 {
68 text->setText(LLStringUtil::null);
69 text->makePristine();
70
71 std::ifstream file(mFileName.c_str());
72
73 std::string line;
74 while (!file.eof())
75 {
76 getline(file, line);
77 line = line + "\n";
78 text->insertText(line);
79 }
80 file.close();
81
82 nc->saveIfNeeded();
83 }
84 }
85 }
86 }
87
88private:
89 std::string mFileName;
90};
91
92
48// ------------------------------------------------------- 93// -------------------------------------------------------
49 94
50AOStandTimer* mAOStandTimer; 95AOStandTimer* mAOStandTimer;
@@ -308,6 +353,7 @@ BOOL LLFloaterAO::postBuild()
308 353
309 childSetAction("reloadcard",onClickReloadCard,this); 354 childSetAction("reloadcard",onClickReloadCard,this);
310 childSetAction("opencard",onClickOpenCard,this); 355 childSetAction("opencard",onClickOpenCard,this);
356 childSetAction("newcard",onClickNewCard,this);
311 childSetAction("prevstand",onClickPrevStand,this); 357 childSetAction("prevstand",onClickPrevStand,this);
312 childSetAction("nextstand",onClickNextStand,this); 358 childSetAction("nextstand",onClickNextStand,this);
313 childSetCommitCallback("AOEnabled",onClickToggleAO); 359 childSetCommitCallback("AOEnabled",onClickToggleAO);
@@ -948,6 +994,25 @@ void LLFloaterAO::onClickOpenCard(void* user_data)
948 } 994 }
949} 995}
950 996
997void LLFloaterAO::onClickNewCard(void* user_data)
998{
999 // load the template file from app_settings/ao_template.ini then
1000 // create a new properly-formatted notecard in the user's inventory
1001 std::string ao_template = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "ao_template.ini");
1002 if (!ao_template.empty())
1003 {
1004 LLPointer<LLInventoryCallback> cb = new AONotecardCallback(ao_template);
1005 create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
1006 LLUUID::null, LLTransactionID::tnull, "New AO Notecard",
1007 "Drop this notecard in your AO window to use", LLAssetType::AT_NOTECARD,
1008 LLInventoryType::IT_NOTECARD, NOT_WEARABLE, PERM_ALL, cb);
1009 }
1010 else
1011 {
1012 llwarns << "Can't find ao_template.ini in app_settings!" << llendl;
1013 }
1014}
1015
951struct AOAssetInfo 1016struct AOAssetInfo
952{ 1017{
953 std::string path; 1018 std::string path;