Clean up and optimize the AO

Added the feature of selecting an animation from combo boxes and it playing automatically if it should be at this moment.

Now for the stuff only developers will understand:
FloaterAO is now a FloaterSingleton, because it should've been behaving that way all along.
Refactors a lot, simplifies a lot, best view without space changes.
Reduces a lot of redundant blocks.
Creates some functions to make things like AOStates easier to get
AOStates are now an enum instead of a bunch of const ints.
Cleaned up includes.
NULL -> nullptr, virtual->override, BOOL->bool, for->foreach
Removed struct_tokens,  it was redundant and actually just took up space.
No longer set all the children invisible, their parent does a good job of that.
Relate ComboBoxes to their states, so that we can easily get a setting and do a whole bunch of things with a lot less code.
Remove unused parameters and functions and variables
Remove unused boolean returns from functions.
Don't clear combo boxes just because one id is null.
This commit is contained in:
Lirusaito
2019-01-11 05:55:40 -05:00
parent 0c585aca39
commit b61cba8e01
12 changed files with 389 additions and 1030 deletions

View File

@@ -33,7 +33,6 @@
#include "aoremotectrl.h"
#include "floaterao.h"
#include "llbutton.h"
#include "lloverlaybar.h"
#include "lluictrlfactory.h"
#include "llviewercontrol.h"
@@ -46,80 +45,23 @@ AORemoteCtrl::AORemoteCtrl()
setFocusRoot(TRUE);
}
AORemoteCtrl::~AORemoteCtrl()
{
}
void AORemoteCtrl::draw()
{
LLButton* expand_button = getChild<LLButton>("popup_btn");
if (expand_button)
{
if (expand_button->getToggleState())
{
expand_button->setImageOverlay("arrow_down.tga");
}
else
{
expand_button->setImageOverlay("arrow_up.tga");
}
}
LLPanel::draw();
}
void AORemoteCtrl::build()
{
if (gSavedSettings.getBOOL("ShowAOSitPopup"))
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_ao_remote_expanded.xml");
}
else
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_ao_remote.xml");
}
LLUICtrlFactory::getInstance()->buildPanel(this, gSavedSettings.getBOOL("ShowAOSitPopup") ? "panel_ao_remote_expanded.xml" : "panel_ao_remote.xml");
}
BOOL AORemoteCtrl::postBuild()
{
childSetAction("ao_btn", onClickToggleAO, this);
if (gSavedSettings.getBOOL("ShowAOSitPopup"))
{
childSetAction("ao_sit_btn", onClickToggleAOSit, this);
//childSetAction("ao_show_btn", onClickShowAO, this);
}
childSetAction("popup_btn", onClickPopupBtn, this);
/*if (LLUICtrl* ctrl = findChild<LLUICtrl>("ao_show_btn"))
ctrl->setCommitCallback(boost::bind(&LLFloaterAO::showInstance, LLSD()));*/
getChild<LLUICtrl>("popup_btn")->setCommitCallback(boost::bind(&AORemoteCtrl::onClickPopupBtn, this));
return TRUE;
}
// static
void AORemoteCtrl::onClickToggleAO(void* data)
void AORemoteCtrl::onClickPopupBtn()
{
BOOL ao_enable = gSavedSettings.getBOOL("AOEnabled");
gSavedSettings.setBOOL("AOEnabled", !ao_enable);
}
//static
void AORemoteCtrl::onClickToggleAOSit(void* data)
{
BOOL sit_enable = gSavedSettings.getBOOL("AOSitsEnabled");
gSavedSettings.setBOOL("AOSitsEnabled", !sit_enable);
}
//static
void AORemoteCtrl::onClickShowAO(void* data)
{
LLFloaterAO::show(NULL);
}
//static
void AORemoteCtrl::onClickPopupBtn(void* data)
{
AORemoteCtrl* remotep = (AORemoteCtrl*)data;
remotep->deleteAllChildren();
remotep->build();
deleteAllChildren();
build();
gOverlayBar->layoutButtons();
}

View File

@@ -37,18 +37,12 @@ class AORemoteCtrl : public LLPanel
{
public:
AORemoteCtrl();
virtual ~AORemoteCtrl();
/*virtual*/ BOOL postBuild();
/*virtual*/ void draw();
BOOL postBuild() override;
private:
void build();
static void onClickToggleAO(void* data);
static void onClickToggleAOSit(void* data);
static void onClickShowAO(void* data);
static void onClickPopupBtn(void* data);
void onClickPopupBtn();
};
#endif // AOREMOTECTRL_H

File diff suppressed because it is too large Load Diff

View File

@@ -8,38 +8,42 @@
#include "lleventtimer.h"
const int STATE_AGENT_IDLE = 0;
const int STATE_AGENT_WALK = 1;
const int STATE_AGENT_RUN = 2;
const int STATE_AGENT_STAND = 3;
enum AOState
{
STATE_AGENT_IDLE = 0,
STATE_AGENT_WALK = 1,
STATE_AGENT_RUN = 2,
STATE_AGENT_STAND = 3,
const int STATE_AGENT_PRE_JUMP = 4;
const int STATE_AGENT_JUMP = 5;
const int STATE_AGENT_TURNLEFT = 6;
const int STATE_AGENT_TURNRIGHT = 7;
STATE_AGENT_PRE_JUMP = 4,
STATE_AGENT_JUMP = 5,
STATE_AGENT_TURNLEFT = 6,
STATE_AGENT_TURNRIGHT = 7,
const int STATE_AGENT_SIT = 8;
const int STATE_AGENT_GROUNDSIT = 9;
STATE_AGENT_SIT = 8,
STATE_AGENT_GROUNDSIT = 9,
const int STATE_AGENT_HOVER = 10;
const int STATE_AGENT_HOVER_DOWN = 11;
const int STATE_AGENT_HOVER_UP = 12;
STATE_AGENT_HOVER = 10,
STATE_AGENT_HOVER_DOWN = 11,
STATE_AGENT_HOVER_UP = 12,
const int STATE_AGENT_CROUCH = 13;
const int STATE_AGENT_CROUCHWALK = 14;
const int STATE_AGENT_FALLDOWN = 15;
const int STATE_AGENT_STANDUP = 16;
const int STATE_AGENT_LAND = 17;
STATE_AGENT_CROUCH = 13,
STATE_AGENT_CROUCHWALK = 14,
STATE_AGENT_FALLDOWN = 15,
STATE_AGENT_STANDUP = 16,
STATE_AGENT_LAND = 17,
const int STATE_AGENT_FLY = 18;
const int STATE_AGENT_FLYSLOW = 19;
STATE_AGENT_FLY = 18,
STATE_AGENT_FLYSLOW = 19,
const int STATE_AGENT_TYPING = 20;
STATE_AGENT_TYPING = 20,
const int STATE_AGENT_SWIM_DOWN = 21;
const int STATE_AGENT_SWIM_UP = 22;
const int STATE_AGENT_SWIM = 23;
const int STATE_AGENT_FLOAT = 24;
STATE_AGENT_SWIM_DOWN = 21,
STATE_AGENT_SWIM_UP = 22,
STATE_AGENT_SWIM = 23,
STATE_AGENT_FLOAT = 24,
STATE_AGENT_END
};
@@ -49,8 +53,8 @@ class AOStandTimer : public LLEventTimer
public:
AOStandTimer();
~AOStandTimer();
virtual BOOL tick();
virtual void reset();
BOOL tick() override;
void reset();
};
class AOInvTimer : public LLEventTimer
@@ -58,76 +62,69 @@ class AOInvTimer : public LLEventTimer
public:
AOInvTimer();
~AOInvTimer();
BOOL tick();
BOOL tick() override;
};
class LLFloaterAO : public LLFloater
class LLFloaterAO : public LLFloater, public LLFloaterSingleton<LLFloaterAO>
{
public:
LLFloaterAO();
virtual BOOL postBuild();
LLFloaterAO(const LLSD&);
BOOL postBuild() override;
void onOpen() override;
virtual ~LLFloaterAO();
static void show(void*);
static void init();
static void run();
static void updateLayout(LLFloaterAO* floater);
void updateLayout(bool advanced);
//static BOOL loadAnims();
//static bool loadAnims();
static void typing(bool start);
static int flyToSwimState(const int state);
static int swimToFlyState(const int state);
static int getAnimationState();
static void setAnimationState(int state);
//static void setStates(const LLUUID& id, BOOL start);
static AOState flyToSwimState(const AOState& state);
static AOState swimToFlyState(const AOState& state);
static AOState getAnimationState();
static void setAnimationState(const AOState& state);
static LLUUID getCurrentStandId();
static void setCurrentStandId(const LLUUID& id);
static int stand_iterator;
static BOOL ChangeStand();
static void ChangeStand();
static void toggleSwim(bool underwater);
static BOOL startMotion(const LLUUID& id, F32 time_offset = 0.f, BOOL stand = FALSE);
static BOOL stopMotion(const LLUUID& id, BOOL stop_immediate, BOOL stand = FALSE);
static void doMotion(const LLUUID& id, bool start, bool stand = false);
static void startMotion(const LLUUID& id, bool stand = false) { doMotion(id, true, stand); }
static void stopMotion(const LLUUID& id, bool stand = false) { doMotion(id, false, stand); }
static bool swimCheck(const int state);
static bool swimCheck(const AOState& state);
static LLUUID GetAnimID(const LLUUID& id);
static int GetStateFromAnimID(const LLUUID& id);
static LLUUID GetAnimIDFromState(const int state);
static int GetStateFromToken(std::string strtoken);
static AOState GetStateFromAnimID(const LLUUID& id);
static LLUUID GetAnimIDFromState(const AOState& state);
static AOState GetStateFromToken(std::string strtoken);
static void onClickLess(void* data) ;
static void onClickMore(void* data) ;
static void onClickPrevStand(void* userdata);
static void onClickNextStand(void* userdata);
static void onClickReloadCard(void* userdata);
static void onClickOpenCard(void* userdata);
static void onClickNewCard(void* userdata);
static void onClickCycleStand(bool next);
static void onClickReloadCard();
static void onClickOpenCard();
static void onClickNewCard();
static LLUUID invfolderid;
static const LLUUID& getAssetIDByName(const std::string& name);
static bool getInstance();
private:
static LLFloaterAO* sInstance;
static int mAnimationState;
static AOState mAnimationState;
static LLUUID mCurrentStandId;
static void onSpinnerCommit(LLUICtrl* ctrl);
static void onSpinnerCommit();
static void onComboBoxCommit(LLUICtrl* ctrl);
static BOOL SetDefault(void *userdata, LLUUID ao_id, std::string defaultanim);
BOOL mDirty;
protected:
static AOState getStateFromCombo(const class LLComboBox* combo);
static LLComboBox* getComboFromState(const AOState& state);
static void onNotecardLoadComplete(LLVFS *vfs,const LLUUID& asset_uuid,LLAssetType::EType type,void* user_data, S32 status, LLExtStat ext_status);
};

View File

@@ -2270,7 +2270,7 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
mMouselookTimer.reset();
gFocusMgr.setKeyboardFocus(NULL);
if (gSavedSettings.getBOOL("AONoStandsInMouselook")) LLFloaterAO::stopMotion(LLFloaterAO::getCurrentStandId(), FALSE,TRUE);
if (gSavedSettings.getBOOL("AONoStandsInMouselook")) LLFloaterAO::stopMotion(LLFloaterAO::getCurrentStandId(), true);
updateLastCamera();
mCameraMode = CAMERA_MODE_MOUSELOOK;

View File

@@ -165,7 +165,6 @@ struct MenuFloaterDict : public LLSingleton<MenuFloaterDict>
registerFloater("about", boost::bind(&LLFloaterAbout::show,(void*)NULL));
registerFloater("always run", boost::bind(toggle_always_run), boost::bind(&LLAgent::getAlwaysRun, &gAgent));
registerFloater("anims_explorer", boost::bind(LLFloaterExploreAnimations::show));
registerFloater("ao", boost::bind(LLFloaterAO::show, (void*)NULL));
registerFloater("appearance", boost::bind(LLFloaterCustomize::show));
registerFloater("asset_blacklist", boost::bind(LLFloaterBlacklist::toggle), boost::bind(LLFloaterBlacklist::visible));
registerFloater("build", boost::bind(toggle_build));
@@ -213,6 +212,7 @@ struct MenuFloaterDict : public LLSingleton<MenuFloaterDict>
registerFloater<LLFloaterLand> ("about land");
registerFloater<LLFloaterRegionInfo> ("about region");
registerFloater<LLFloaterActiveSpeakers> ("active speakers");
registerFloater<LLFloaterAO> ("ao");
registerFloater<JCFloaterAreaSearch> ("areasearch");
registerFloater<LLFloaterAutoReplaceSettings> ("autoreplace");
registerFloater<LLFloaterAvatar> ("avatar");

View File

@@ -5930,7 +5930,7 @@ void LLVOAvatar::processAnimationStateChanges()
{
if (AOEnabled && isSelf()) // AO is only for ME
{
LLFloaterAO::startMotion(anim_it->first, 0,FALSE); // AO overrides the anim if needed
LLFloaterAO::startMotion(anim_it->first, false); // AO overrides the anim if needed
}
mPlayingAnimations[anim_it->first] = anim_it->second;

View File

@@ -20,8 +20,7 @@
<button name="newcard" label="Neue Notecard Vorlage"/>
<button label="Mehr &gt;&gt;" name="more_btn" tool_tip="Erweiterte Optionen"/>
<button label="&lt;&lt; Weniger" name="less_btn" tool_tip="Erweiterte Optionen"/>
<button label="Mehr &gt;&gt;" label_selected="&lt;&lt; Weniger" name="more_btn" tool_tip="Erweiterte Optionen"/>
<tab_container label="Standard" name="tabcontainer">
<panel label="Standardanimationen" name="tabdefaultanims">

View File

@@ -100,13 +100,9 @@
/>
<button bottom="4" follows="left|bottom" font="SansSerifSmall" halign="center"
height="20" label="More &gt;&gt;" left="118"
mouse_opaque="true" name="more_btn" scale_image="TRUE"
height="20" label="More &gt;&gt;" label_selected="&lt;&lt; Less" left="118" toggle="true"
mouse_opaque="true" name="more_btn" scale_image="TRUE" control_name="AOAdvanced" image_selected="button_enabled_32x128.tga"
tool_tip="Advanced Options" width="76" />
<button bottom_delta="0" follows="left|bottom" font="SansSerifSmall" halign="center"
height="20" label="&lt;&lt; Less" left_delta="0"
mouse_opaque="true" name="less_btn" scale_image="TRUE"
tool_tip="Advanced Options" width="76" />
<tab_container label="Default" bottom="6" left="210" mouse_opaque="false" name="tabcontainer" tab_min_width="50" tab_position="top" width="580" height="350" bg_opaque_color="0,0,0,0.0">
<panel border="true" left="0" bottom="0" follows="left|top|right|bottom" height="350" label="Default Anims" mouse_opaque="true" name="tabdefaultanims" width="580">

View File

@@ -2,10 +2,11 @@
<panel bg_visible="false" border="false" border_visible="false" bottom="1"
enabled="true" follows="right|bottom" height="20" left="0"
name="ao_controls" width="96">
<button bottom="-22" follows="left|bottom" font="SansSerif" halign="center" height="22"
<button bottom="-22" follows="left|bottom" font="SansSerif" halign="center" height="22" toggle="true"
label="AO Off" label_selected="AO On" left="3" name="ao_btn" control_name="AOEnabled"
tool_tip="Click here to toggle the Animation Overrider" width="66" />
<button bottom="-22" follows="left|bottom" font="SansSerif" halign="center" height="22" toggle="true"
label="" left_delta="68" name="popup_btn" scale_image="true" control_name="ShowAOSitPopup"
image_selected="arrow_down.tga" image_unselected="arrow_up.tga"
tool_tip="Click here for more options" width="22" />
</panel>

View File

@@ -3,7 +3,7 @@
enabled="true" follows="right|bottom" height="45" left="0" mouse_opaque="true"
name="ao_remote" use_bounding_rect="true" width="96">
<panel bottom="1" filename="panel_bg_tab.xml" name="panel_bg_tab" height="47" left="0" width="96" />
<button bottom="-20" control_name="AOSitsEnabled" enabled="true"
<button bottom="-20" control_name="AOSitsEnabled" enabled="true" toggle="true"
follows="left|top" font="SansSerif" height="22" label="AO Sits Off" label_selected="AO Sits On"
mouse_opaque="true" name="ao_sit_btn" width="92" left="3" />
<panel bottom="13" filename="panel_ao_remote_controls.xml" name="panel_ao_controls" left="0" width="96" />

View File

@@ -16,8 +16,7 @@
<check_box label="Mostrar AO en Barra de Herram." name="ao_remote_checkbox"/>
<spinner name="standtime" label="Tiempo de Ejecución:" label_width="120" tool_tip="Tiempo de ejecución de la animación, en segundos" />
<button name="newcard" label="Nueva Plantilla de Nota" />
<button label="Más &gt;&gt;" name="more_btn" tool_tip="Opciones Avanzadas" />
<button label="&lt;&lt; Menos" name="less_btn" tool_tip="Opciones Avanzadas" />
<button label="Más &gt;&gt;" label_selected="&lt;&lt; Menos" name="more_btn" tool_tip="Opciones Avanzadas" />
<tab_container label="Por Defecto" name="tabcontainer" >
<panel label="Animaciones por Defecto" name="tabdefaultanims">
<text name="textdefaultwalk">