From df05ebbe2d04fded5dc42f816ce220364ed35e73 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 2 Apr 2010 23:35:18 -0700 Subject: Added button to create a new template notecard for the AO --- linden/indra/newview/app_settings/ao_template.ini | 103 +++++++++++++++++++++ linden/indra/newview/floaterao.cpp | 65 +++++++++++++ linden/indra/newview/floaterao.h | 2 +- linden/indra/newview/llpreviewnotecard.h | 3 +- .../newview/skins/default/xui/en-us/floater_ao.xml | 11 +++ 5 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 linden/indra/newview/app_settings/ao_template.ini (limited to 'linden/indra') diff --git a/linden/indra/newview/app_settings/ao_template.ini b/linden/indra/newview/app_settings/ao_template.ini new file mode 100644 index 0000000..03f02e3 --- /dev/null +++ b/linden/indra/newview/app_settings/ao_template.ini @@ -0,0 +1,103 @@ +############################################################ +############################################################ +## +## IMPRUDENCE AO TEMPLATE +## +############################################################ +## +## INSTRUCTIONS: +## +## 1. Detach any AO you are currently wearing or it will interfere. +## +## 2. Place all of the animations you want ot use into a folder in your inventory. +## +## 3. Place the notecard for the AO in the *SAME* folder. +## +## 4. Find the line that matches the animation you're changing. +## For example, if you're adding a walk animation, +## find the line that starts with [ Walking ] +## +## If the notecard already has walking animations, the line will look something like this: +## [ Walking ]SexyWalk1|SexyWalk2 +## +## 5. Type the name of the new animation at the end of this line. +## If the line already contains some animations, type '|' before +## typing the animation name. Once you're done, the line should look like this: +## [ Walking ]NewWalkAnim +## or +## [ Walking ]SexyWalk1|SexyWalk2|NewWalkAnim +## +## 6. Once you're done, save the notecard. +## +## 7. Open the client AO window (CTRL-SHIFT-O) then drag the notecard onto the indicated spot. +## +## 8. Press the "Reload" button in the AO. +## +############################################################ + +############################################################ +############################################################ +## +## LIST YOUR ANIMATIONS HERE +## +############################################################ +############################################################ + + +[ Standing ] +[ Walking ] +[ Sitting ] +[ Sitting On Ground ] +[ Crouching ] +[ Crouch Walking ] +[ Landing ] +[ Standing Up ] +[ Falling ] +[ Flying Down ] +[ Flying Up ] +[ Flying ] +[ Flying Slow ] +[ Hovering ] +[ Jumping ] +[ Pre Jumping ] +[ Running ] +[ Turning Right ] +[ Turning Left ] +[ Floating ] +[ Swimming Forward ] +[ Swimming Up ] +[ Swimming Down ] + + +############################################################# +############################################################# +## +## FOR ADVANCED USERS ONLY +## +############################################################# +## +## Lines starting with a # are treated as comments and ignored. Blank lines are ignored. Valid lines look like this: +## +## [ Walking ]SexyWalk1|SexyWalk2|SexyWalk3 +## +## The token (in this case, [ Walking ] - note the spaces inside the [ ]) identifies the animation to be overridden. The rest is a list of +## animations, separated by the '|' (pipe) character. You can specify multiple animations for Stands, Walks, Sits, and GroundSits. +## Multiple animations on any other line are invalid. You can list as many animations as you want. +## +## You can repeat tokens, so you can split the Stands up across multiple lines. Use the [ Standing ] token in each line, and +## the viewer will add the animation lists together. +## +## Each 'animation name' can be a comma-separated list of animations, which will be played together. For example: +## [ Walking ]SexyWalk1UpperBody,SexyWalk1LowerBody|SexyWalk2|SexyWalk3 +## +## Note the ',' between SexyWalk1UpperBody and SexyWalk1LowerBody - this tells AO to treat these as a single +## 'animation' and play them together. The '|' between this 'animation' and SexyWalk2 tells AO to treat SexyWalk2 and +## SexyWalk3 as separate walk animations. You can use this to layer animations on top of each other. +## +## Do not add any spaces around animation names!!! +## +## If you have read and understood these instructions, feel free to delete these lines. +## +## Imprudence's AO notecard system is based on the ZHAO-II HUD by Second Life resident Ziggy Puff. +## +############################################################ \ No newline at end of file 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) } +class AONotecardCallback : public LLInventoryCallback +{ +public: + AONotecardCallback(std::string &filename) + { + mFileName = filename; + } + + void fire(const LLUUID &inv_item) + { + if (!mFileName.empty()) + { + LLPreviewNotecard* nc; + nc = (LLPreviewNotecard*)LLPreview::find(inv_item); + if(nc) + { + nc->open(); + LLTextEditor *text = nc->getEditor(); + if (text) + { + text->setText(LLStringUtil::null); + text->makePristine(); + + std::ifstream file(mFileName.c_str()); + + std::string line; + while (!file.eof()) + { + getline(file, line); + line = line + "\n"; + text->insertText(line); + } + file.close(); + + nc->saveIfNeeded(); + } + } + } + } + +private: + std::string mFileName; +}; + + // ------------------------------------------------------- AOStandTimer* mAOStandTimer; @@ -308,6 +353,7 @@ BOOL LLFloaterAO::postBuild() childSetAction("reloadcard",onClickReloadCard,this); childSetAction("opencard",onClickOpenCard,this); + childSetAction("newcard",onClickNewCard,this); childSetAction("prevstand",onClickPrevStand,this); childSetAction("nextstand",onClickNextStand,this); childSetCommitCallback("AOEnabled",onClickToggleAO); @@ -948,6 +994,25 @@ void LLFloaterAO::onClickOpenCard(void* user_data) } } +void LLFloaterAO::onClickNewCard(void* user_data) +{ + // load the template file from app_settings/ao_template.ini then + // create a new properly-formatted notecard in the user's inventory + std::string ao_template = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "ao_template.ini"); + if (!ao_template.empty()) + { + LLPointer cb = new AONotecardCallback(ao_template); + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + LLUUID::null, LLTransactionID::tnull, "New AO Notecard", + "Drop this notecard in your AO window to use", LLAssetType::AT_NOTECARD, + LLInventoryType::IT_NOTECARD, NOT_WEARABLE, PERM_ALL, cb); + } + else + { + llwarns << "Can't find ao_template.ini in app_settings!" << llendl; + } +} + struct AOAssetInfo { std::string path; diff --git a/linden/indra/newview/floaterao.h b/linden/indra/newview/floaterao.h index 6b356cd..204717f 100644 --- a/linden/indra/newview/floaterao.h +++ b/linden/indra/newview/floaterao.h @@ -99,7 +99,7 @@ public: static void onClickNextStand(void* userdata); static void onClickReloadCard(void* userdata); static void onClickOpenCard(void* userdata); - + static void onClickNewCard(void* userdata); static LLUUID invfolderid; static const LLUUID& getAssetIDByName(const std::string& name); diff --git a/linden/indra/newview/llpreviewnotecard.h b/linden/indra/newview/llpreviewnotecard.h index 75d1a50..a879fec 100644 --- a/linden/indra/newview/llpreviewnotecard.h +++ b/linden/indra/newview/llpreviewnotecard.h @@ -87,10 +87,11 @@ public: void refreshFromInventory(); LLTextEditor* getEditor(); + + bool saveIfNeeded(LLInventoryItem* copyitem = NULL); protected: virtual void loadAsset(); - bool saveIfNeeded(LLInventoryItem* copyitem = NULL); static LLPreviewNotecard* getInstance(const LLUUID& uuid); diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_ao.xml b/linden/indra/newview/skins/default/xui/en-us/floater_ao.xml index 02aed11..2bcc9d1 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_ao.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_ao.xml @@ -101,6 +101,17 @@ mouse_opaque="true" name="standtime" label="Stand Time" label_width="80" tool_tip="AO Stand Time in seconds" width="180" /> +