Ejemplo n.º 1
0
void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incolor, bool log_to_file, const LLUUID& source, const std::string& name)
{
	static const LLCachedControl<bool> mKeywordsChangeColor(gSavedPerAccountSettings, "KeywordsChangeColor", false);
	static const LLCachedControl<LLColor4> mKeywordsColor(gSavedPerAccountSettings, "KeywordsColor", LLColor4(1.f, 1.f, 1.f, 1.f));

	if (gAgentID != source)
	{
		if (mKeywordsChangeColor)
		{
			if (AscentKeyword::hasKeyword(utf8msg, 2))
			{
				incolor = mKeywordsColor;
			}
		}

		if (mDing && (!hasFocus() || !gFocusMgr.getAppHasFocus()))
		{
			static const LLCachedControl<std::string> ding("LiruNewMessageSound");
			static const LLCachedControl<std::string> dong("LiruNewMessageSoundForSystemMessages");
			LLUI::sAudioCallback(LLUUID(source.notNull() ? ding : dong));
		}
	}

	const LLColor4& color = incolor;
	// start tab flashing when receiving im for background session from user
	if (source.notNull())
	{
		LLMultiFloater* hostp = getHost();
		if( !isInVisibleChain() 
			&& hostp 
			&& source != gAgentID)
		{
			hostp->setFloaterFlashing(this, TRUE);
		}
	}

	// Now we're adding the actual line of text, so erase the 
	// "Foo is typing..." text segment, and the optional timestamp
	// if it was present. JC
	removeTypingIndicator(NULL);

	// Actually add the line
	bool prepend_newline = true;
	if (gSavedSettings.getBOOL("IMShowTimestamps"))
	{
		mHistoryEditor->appendTime(prepend_newline);
		prepend_newline = false;
	}

	std::string show_name = name;
	bool is_irc = false;
	// 'name' is a sender name that we want to hotlink so that clicking on it opens a profile.
	if (!name.empty()) // If name exists, then add it to the front of the message.
	{
		// Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text.
		if (name == SYSTEM_FROM)
		{
			mHistoryEditor->appendColoredText(name,false,prepend_newline,color);
		}
		else
		{
			// IRC style text starts with a colon here; empty names and system messages aren't irc style.
			static const LLCachedControl<bool> italicize("LiruItalicizeActions");
			is_irc = italicize && utf8msg[0] != ':';
			if (source.notNull())
				LLAvatarNameCache::getPNSName(source, show_name);
			// Convert the name to a hotlink and add to message.
			LLStyleSP source_style = LLStyleMap::instance().lookupAgent(source);
			source_style->mItalic = is_irc;
			mHistoryEditor->appendStyledText(show_name,false,prepend_newline,source_style);
		}
		prepend_newline = false;
	}

	// Append the chat message in style
	{
		LLStyleSP style(new LLStyle);
		style->setColor(color);
		style->mItalic = is_irc;
		style->mBold = gSavedSettings.getBOOL("SingularityBoldGroupModerator") && isModerator(source);
		mHistoryEditor->appendStyledText(utf8msg, false, prepend_newline, style);
	}

	if (log_to_file
		&& gSavedPerAccountSettings.getBOOL("LogInstantMessages") ) 
	{
		std::string histstr;
		if (gSavedPerAccountSettings.getBOOL("IMLogTimestamp"))
			histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + show_name + utf8msg;
		else
			histstr = show_name + utf8msg;

		// [Ansariel: Display name support]
		// Floater title contains display name -> bad idea to use that as filename
		// mLogLabel, however, is the old legacy name
		//LLLogChat::saveHistory(getTitle(),histstr);
		LLLogChat::saveHistory(mLogLabel, histstr);
		// [/Ansariel: Display name support]
	}

	if (source.notNull())
	{
		if (!isInVisibleChain() || (!hasFocus() && getParent() == gFloaterView))
		{
			mNumUnreadMessages++;
		}

		mSpeakers->speakerChatted(source);
		mSpeakers->setSpeakerTyping(source, FALSE);
	}
}
Ejemplo n.º 2
0
void UIWidget::updateState(Fw::WidgetState state)
{
    if(m_destroyed)
        return;

    bool newStatus = true;
    bool oldStatus = hasState(state);
    bool updateChildren = false;

    switch(state) {
        case Fw::ActiveState: {
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            UIWidgetPtr parent;
            do {
                parent = widget->getParent();
                if(!widget->isExplicitlyEnabled() ||
                   ((parent && parent->getFocusedChild() != widget))) {
                    newStatus = false;
                    break;
                }
            } while((widget = parent));

            updateChildren = newStatus != oldStatus;
            break;
        }
        case Fw::FocusState: {
            newStatus = (getParent() && getParent()->getFocusedChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::HoverState: {
            newStatus = (g_ui.getHoveredWidget() == static_self_cast<UIWidget>() && isEnabled());
            break;
        }
        case Fw::PressedState: {
            newStatus = (g_ui.getPressedWidget() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::DraggingState: {
            newStatus = (g_ui.getDraggingWidget() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::DisabledState: {
            bool enabled = true;
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            do {
                if(!widget->isExplicitlyEnabled()) {
                    enabled = false;
                    break;
                }
            } while((widget = widget->getParent()));
            newStatus = !enabled;
            updateChildren = newStatus != oldStatus;
            break;
        }
        case Fw::FirstState: {
            newStatus = (getParent() && getParent()->getFirstChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::MiddleState: {
            newStatus = (getParent() && getParent()->getFirstChild() != static_self_cast<UIWidget>() && getParent()->getLastChild() != static_self_cast<UIWidget>());
            break;
        }
        case Fw::LastState: {
            newStatus = (getParent() && getParent()->getLastChild() == static_self_cast<UIWidget>());
            break;
        }
        case Fw::AlternateState: {
            newStatus = (getParent() && (getParent()->getChildIndex(static_self_cast<UIWidget>()) % 2) == 1);
            break;
        }
        case Fw::HiddenState: {
            bool visible = true;
            UIWidgetPtr widget = static_self_cast<UIWidget>();
            do {
                if(!widget->isExplicitlyVisible()) {
                    visible = false;
                    break;
                }
            } while((widget = widget->getParent()));
            newStatus = !visible;
            updateChildren = newStatus != oldStatus;
            break;
        }
        default:
            return;
    }

    if(updateChildren) {
        // do a backup of children list, because it may change while looping it
        UIWidgetList children = m_children;
        for(const UIWidgetPtr& child : children)
            child->updateState(state);
    }

    if(setState(state, newStatus)) {
        // disabled widgets cannot have hover state
        if(state == Fw::DisabledState && !newStatus && isHovered()) {
            g_ui.updateHoveredWidget();
        } else if(state == Fw::HiddenState) {
            onVisibilityChange(!newStatus);
        }
    }
}
Ejemplo n.º 3
0
void DepotLocker::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link /*= LINK_OWNER*/)
{
	if (getParent() != NULL) {
		getParent()->postAddNotification(thing, oldParent, index, LINK_PARENT);
	}
}
Ejemplo n.º 4
0
void LLDrawable::makeActive()
{		
#if !LL_RELEASE_FOR_DOWNLOAD
	if (mVObjp.notNull())
	{
		U32 pcode = mVObjp->getPCode();
		if (pcode == LLViewerObject::LL_VO_WATER ||
			pcode == LLViewerObject::LL_VO_VOID_WATER ||
			pcode == LLViewerObject::LL_VO_SURFACE_PATCH ||
			pcode == LLViewerObject::LL_VO_PART_GROUP ||
			pcode == LLViewerObject::LL_VO_HUD_PART_GROUP ||
			pcode == LLViewerObject::LL_VO_CLOUDS ||
			pcode == LLViewerObject::LL_VO_GROUND ||
			pcode == LLViewerObject::LL_VO_SKY)
		{
			llerrs << "Static viewer object has active drawable!" << llendl;
		}
	}
#endif

	if (!isState(ACTIVE)) // && mGeneration > 0)
	{
		setState(ACTIVE);
		
		//parent must be made active first
		if (!isRoot() && !mParent->isActive())
		{
			mParent->makeActive();
		}

		//all child objects must also be active
		llassert_always(mVObjp);
		
		LLViewerObject::const_child_list_t& child_list = mVObjp->getChildren();
		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
			 iter != child_list.end(); iter++)
		{
			LLViewerObject* child = *iter;
			LLDrawable* drawable = child->mDrawable;
			if (drawable)
			{
				drawable->makeActive();
			}
		}

		if (mVObjp->getPCode() == LL_PCODE_VOLUME)
		{
			if (mVObjp->isFlexible())
			{
				return;
			}
		}
	
		if (mVObjp->getPCode() == LL_PCODE_VOLUME)
		{
			gPipeline.markRebuild(this, LLDrawable::REBUILD_VOLUME, TRUE);
		}
		updatePartition();
	}

	if (isRoot())
	{
		mQuietCount = 0;
	}
	else
	{
		getParent()->mQuietCount = 0;
	}
}
void DroidStimpackModuleDataComponent::handleInsertStimpack(CreatureObject* player, StimPack* pack) {
    // we need to send the invalid stimpack message just where is a good question
    countUses();

    if (player == NULL)
        return;

    if (!player->hasSkill("science_medic_ability_04")) {
        return;
    }

    ManagedReference<DroidObject*> droid = getDroidObject();
    if (droid == NULL) {
        return;
    }
    if (pack == NULL) {
        player->sendSystemMessage("@pet/droid_modules:invalid_stimpack");
        return;
    }
    if(!pack->isClassA()) {
        player->sendSystemMessage("@pet/droid_modules:invalid_stimpack");
        return;
    }
    if(droid->getLinkedCreature().get() != player) {
        return;
    }
    // we have the player and the stim to add to ourselves.
    // code should goes as follow, count total use of all stims, then deduct amount form capacity
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    ManagedReference<SceneObject*> craftingComponents = droidComponent->getSlottedObject("crafted_components");
    if (craftingComponents != NULL) {
        SceneObject* satchel = craftingComponents->getContainerObject(0);
        if (satchel != NULL) {
            int allowedAmount = capacity - loaded;
            if (allowedAmount <= 0) {
                player->sendSystemMessage("@pet/droid_modules:stimpack_capacity_full");
                return;
            }

            Locker plocker(pack);
            int amountOnStim = pack->getUseCount();
            StimPack* targetStim = compatibleStimpack(pack->getEffectiveness());
            if (targetStim != NULL) {
                Locker tlocker(targetStim);

                if (allowedAmount > amountOnStim) {
                    targetStim->setUseCount(targetStim->getUseCount() + amountOnStim,true);
                    pack->setUseCount(0,true);
                } else {
                    targetStim->setUseCount(targetStim->getUseCount() + allowedAmount,true);
                    pack->setUseCount(pack->getUseCount() - allowedAmount,true);
                }
            } else {
                // can we take it all?
                if(allowedAmount > amountOnStim) {
                    pack->destroyObjectFromWorld(true);
                    // transfer to the droid and broadcast, then send the satchel to the player
                    satchel->transferObject(pack,-1,true);
                    satchel->broadcastObject(pack, true);
                    pack->sendTo(player,true);
                    droid->sendTo(player,true);
                    player->sendSystemMessage("@pet/droid_modules:stimpack_loaded");
                } else {
                    // we cant load it all so split the diff
                    StimPack* newStim = pack->split(allowedAmount);

                    if (newStim != NULL) {
                        Locker slocker(newStim);
                        satchel->transferObject(newStim,-1,true);
                        satchel->broadcastObject(newStim, true);
                        player->sendSystemMessage("@pet/droid_modules:stimpack_loaded");
                    }
                }
            }
        }
    }
    countUses();
}
Ejemplo n.º 6
0
void Mailbox::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link /*= LINK_OWNER*/, bool isNewItem /*=true*/)
{
	getParent()->postAddNotification(thing, oldParent, index, LINK_PARENT, isNewItem);
}
Ejemplo n.º 7
0
BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
									 EDragAndDropType cargo_type,
									 void* cargo_data,
									 EAcceptance* accept,
									 std::string& tooltip_msg)
{
	BOOL handled = FALSE;

	if (!gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_SEND))
	{
		*accept = ACCEPT_NO;
		return TRUE;
	}

	if(getParent())
	{
		// check if inside
		//LLRect parent_rect = mParentView->getRect();
		//getRect().set(0, parent_rect.getHeight(), parent_rect.getWidth(), 0);
		handled = TRUE;

		// check the type
		switch(cargo_type)
		{
		case DAD_TEXTURE:
		case DAD_SOUND:
		case DAD_LANDMARK:
		case DAD_SCRIPT:
		case DAD_OBJECT:
		case DAD_NOTECARD:
		case DAD_CLOTHING:
		case DAD_BODYPART:
		case DAD_ANIMATION:
		case DAD_GESTURE:
		{
			LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
			if(gInventory.getItem(inv_item->getUUID())
				&& LLToolDragAndDrop::isInventoryGroupGiveAcceptable(inv_item))
			{
				// *TODO: get multiple object transfers working
				*accept = ACCEPT_YES_COPY_SINGLE;
				if(drop)
				{
					mGroupNoticesPanel->setItem(inv_item);
				}
			}
			else
			{
				// It's not in the user's inventory (it's probably
				// in an object's contents), so disallow dragging
				// it here.  You can't give something you don't
				// yet have.
				*accept = ACCEPT_NO;
			}
			break;
		}
		case DAD_CATEGORY:
		case DAD_CALLINGCARD:
		default:
			*accept = ACCEPT_NO;
			break;
		}
	}
	return handled;
}
Ejemplo n.º 8
0
void
SavedFrame::updatePrivateParent()
{
    setReservedSlot(JSSLOT_PRIVATE_PARENT, PrivateValue(getParent()));
}
Ejemplo n.º 9
0
//-----------------------------------------------
//
//
void CTaskEventSubGui::menuCallback(CCObject * pSender)
{
	CGameWorldScene* pWorldLayer =  ( CGameWorldScene* )getParent();
    pWorldLayer->EnableAllWorldButton( true );
    getParent()->removeChild(this,true);
}
Ejemplo n.º 10
0
void CardStateActive::mouseReleaseEvent(QMouseEvent *)
{
    getParent()->getGameWindow()->selectPlayerCard(getParent());
}
Ejemplo n.º 11
0
CardStateActive::~CardStateActive()
{
    getParent()->setStyleSheet(CardStateActive::RESET);
}
Ejemplo n.º 12
0
// override
void CWListCtrl::makeImageList()
{
#ifndef hab218
	CWListView *pParent = getParent();
	if (pParent->IsKindOf(RUNTIME_CLASS(CDlgManualParseChoice)))
	  {
		return;
	  }
#endif // hab218
	if(getParent()->m_pList->getLangFont())	/// just a convenient place to get this done
		m_dwFlags |= MULTIPLE_FONTS;


/*	THIS DIDN'T WORK (AND WASN'T NEEDED)
	Because, surprisingly, the header uses the imagelist of the ctrl, not its own
	image list (so why does it have one? you ask)

	 // make a list for the header control to show the little pencil on editable columns
	m_headerctrl.m_ximageList.m_hImageList=NULL; // there's a compiler/mfc problem where this is set to cdcdcdcd and mfc squawks because it isn't null
	m_headerctrl.m_ximageList.Create(GetSystemMetrics(SM_CXSMICON),
		GetSystemMetrics(SM_CYSMICON), TRUE, 1, 1);

	HICON hiconItem;        // icon for list view items
	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_Editable));
	m_headerctrl.m_ximageList.Add(hiconItem);
	DeleteObject(hiconItem);

	// our header control may not have been subclassed yet
	CHeaderCtrl* pHeader =(CHeaderCtrl*)GetDlgItem(0);
	pHeader->SetImageList( &m_headerctrl.m_ximageList);

*/
	// make our image list for the list items

/*	m_imageList.Create(GetSystemMetrics(SM_CXSMICON),
		GetSystemMetrics(SM_CYSMICON), TRUE, 10, 1);

	HICON hiconItem;        // icon for list view items
	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_GenericListItem));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MorphEnvironment));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_StringEnvironment));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	// make the "disabled" overlay icon
	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_DisabledOverlay));

	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	m_imageList.SetOverlayImage( 3, // the 4th image is #3(zero-based) in the list
								1);	// is the overlay image #1 (one-based).


	// with all this bitmap stuff I was trying to get the darn thing to show transparently,
	// but it instead is invisible when a bitmap instead of an icon.  I also tried using
	// LoadImage(... LR_LOADTRANSPARENT) on the icon (instead of the bitmap) to no avail.

	// 	CBitmap* bmp = new CBitmap();
//	bmp.FromHandle( (HBITMAP)
//		LoadImage (AfxGetInstanceHandle (),MAKEINTRESOURCE (IDB_Editable),
//			IMAGE_BITMAP,0,0,LR_LOADTRANSPARENT));		// TRANSPARENT DOESN'T ACTUALLY WORK


//	bmp->LoadBitmap(IDB_Editable);
//	m_imageList.Add(bmp, RGB(0,0,0));//RGB(255,255,255)/*mask color);

	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_Editable));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	// SPECIAL ICONS FOR VARIOUS TYPES


	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_STAMPFlag));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);

	hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_GenericListItemB));
	m_imageList.Add(hiconItem);
	DeleteObject(hiconItem);
*/
	int ids[] = {IDI_GenericListItem0,IDI_MorphEnvironment,IDI_StringEnvironment,
				IDI_DisabledOverlay, IDI_Editable, IDI_STAMPFlag, IDI_GenericListItem1,
				IDI_GenericListItem2,
				IDI_SENTRANSLimit, IDI_SENTRANSBegin, IDI_SENTRANSEnd, IDI_SENTRANSRulesOn, IDI_SENTRANSRulesOff,
				IDI_CommentListItem, IDI_TestDataListItem};

	m_imageList.Create(GetSystemMetrics(SM_CXSMICON),
		GetSystemMetrics(SM_CYSMICON), TRUE, sizeof(ids), 1);

	for(int i=0; i< sizeof(ids); i++)
	{
		HICON hiconItem = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(ids[i]));
		m_imageList.Add(hiconItem);
		DeleteObject(hiconItem);
	}

	m_imageList.SetOverlayImage( 3, // the 4th image is #3(zero-based) in the list
							1);	// is the overlay image #1 (one-based).

	SetImageList( &m_imageList, LVSIL_SMALL);
}
Ejemplo n.º 13
0
//virtual override since we can have different fonts for different columns
CFont* CWListCtrl::getFontForSubItem(int nItem, int nCol)
{
	static CFont fntNotEditable;

#ifndef hab218
				// it'd sure be nice if there were an easier
				// way...
	ASSERT(getParent());
	CWListView *pParent = getParent();
	CWList * pList;
	if (pParent->IsKindOf(RUNTIME_CLASS(CDlgManualParseChoice)))
	  {
		CDlgManualParseChoice * pDlg = (CDlgManualParseChoice *)pParent;
		pList = pDlg->m_pList;
	  }
	else
	  {
		pList = pParent->m_pList;
	  }
	ASSERT(pList);
	if(pList->getUseLangFontInColumn(nCol))
	  {
		CFont* pF;
		if (pParent->IsKindOf(RUNTIME_CLASS(CDlgManualParseChoice)))
		  {
		CDlgManualParseChoice * pDlg = (CDlgManualParseChoice *)pParent;
		pF = pDlg->getLangFont();
		  }
		else
		  pF = pParent->getLangFont();
		ASSERT(pF);
		return pF;
	  }
#else // hab218
	ASSERT(getParent());
	ASSERT(getParent()->m_pList);
	if(getParent()->m_pList->getUseLangFontInColumn(nCol))
	{
		CFont* pF = getParent()->getLangFont();
		ASSERT(pF);
		return pF;
	}
#endif //hab218
		// if not editable
/*	else if(! (getParent()->m_pList->m_dwEditableColumns & (1 << nCol)))
	{
		//fntNotEditable.FromHandle((HFONT)GetStockObject(ANSI_FIXED_FONT));
		if(!HFONT(fntNotEditable))
		{
			CFont* pf = GetFont();
			LOGFONT lf;
			pf->GetLogFont(&lf);
			lf.lfItalic=TRUE;
			fntNotEditable.CreateFontIndirect(&lf);
			//fntNotEditable.CreateFont(lf.lfHeight ,0,0,0,0,TRUE,0,0,ANSI_CHARSET,0,0,0,lf.lfPitchAndFamily ,lf.lfFaceName);
		}
		return &fntNotEditable;
		//return getParent()->getLangFont();
	}
*/	else
		return GetFont();

}
Ejemplo n.º 14
0
void Fire::EndFire(){
    getParent()->removeChild(this);
}
Ejemplo n.º 15
0
void GMSourceView::saveSettings(const FXString & key) const {
  getApp()->reg().writeBoolEntry(key.text(),"source-list-sort-reverse",sourcelist->getSortFunc()==source_list_sort_reverse);
  getApp()->reg().writeBoolEntry(key.text(),"source-list",getParent()->shown());
  }
ofVec3f BasicScreenObject::globalToLocal(ofVec3f _global){
	ofVec3f				origpoint(_global);
	ofMatrix4x4 local	= getParent()->getGlobalTransformMatrix().getInverse();
	origpoint			= origpoint*local;
	return origpoint;
}
Ejemplo n.º 17
0
void NewGameConfirmDlg::cancelCallBack()
{
	getParent()->removeChild(this,true);
}
ofVec3f BasicScreenObject::globalToLocalDir(ofVec3f _globaldir){
	ofMatrix4x4	local = getParent()->getGlobalTransformMatrix().getInverse();
	local.setTranslation(0, 0, 0);
	return _globaldir*local;	
}
Ejemplo n.º 19
0
    void TextBox::keyPressed(KeyEvent& keyEvent)
    {
        Key key = keyEvent.getKey();

        if (key.getValue() == Key::LEFT)
        {
            --mCaretColumn;
            if (mCaretColumn < 0)
            {
                --mCaretRow;

                if (mCaretRow < 0)
                {
                    mCaretRow = 0;
                    mCaretColumn = 0;
                }
                else
                {
                    mCaretColumn = mTextRows[mCaretRow].size();
                }
            }
        }

        else if (key.getValue() == Key::RIGHT)
        {
            ++mCaretColumn;
            if (mCaretColumn > (int)mTextRows[mCaretRow].size())
            {
                ++mCaretRow;

                if (mCaretRow >= (int)mTextRows.size())
                {
                    mCaretRow = mTextRows.size() - 1;
                    if (mCaretRow < 0)
                    {
                        mCaretRow = 0;
                    }

                    mCaretColumn = mTextRows[mCaretRow].size();
                }
                else
                {
                    mCaretColumn = 0;
                }
            }
        }

        else if (key.getValue() == Key::DOWN)
        {
            setCaretRow(mCaretRow + 1);
        }

        else if (key.getValue() == Key::UP)
        {
            setCaretRow(mCaretRow - 1);
        }

        else if (key.getValue() == Key::HOME)
        {
            mCaretColumn = 0;
        }

        else if (key.getValue() == Key::END)
        {
            mCaretColumn = mTextRows[mCaretRow].size();
        }

        else if (key.getValue() == Key::ENTER && mEditable)
        {
            mTextRows.insert(mTextRows.begin() + mCaretRow + 1,
                             mTextRows[mCaretRow].substr(mCaretColumn, mTextRows[mCaretRow].size() - mCaretColumn));
            mTextRows[mCaretRow].resize(mCaretColumn);
            ++mCaretRow;
            mCaretColumn = 0;
        }

        else if (key.getValue() == Key::BACKSPACE
                 && mCaretColumn != 0
                 && mEditable)
        {
			wchar_t c = mTextRows[mCaretRow][mCaretColumn-1];
			if(c < 128) {
				mTextRows[mCaretRow].erase(mCaretColumn - 1, 1);
				--mCaretColumn;
			}
			else {
				mTextRows[mCaretRow].erase(mCaretColumn - 3, 3); 
				mCaretColumn -= 3;
			}
        }

        else if (key.getValue() == Key::BACKSPACE
                 && mCaretColumn == 0
                 && mCaretRow != 0
                 && mEditable)
        {
            mCaretColumn = mTextRows[mCaretRow - 1].size();
            mTextRows[mCaretRow - 1] += mTextRows[mCaretRow];
            mTextRows.erase(mTextRows.begin() + mCaretRow);
            --mCaretRow;
        }

//         else if (key.getValue() == Key::DELETE
//                  && mCaretColumn < (int)mTextRows[mCaretRow].size()
//                  && mEditable)
		else if (key.getValue() == 1013
			&& mCaretColumn != 0
			&& mEditable)
        {
            mTextRows[mCaretRow].erase(mCaretColumn, 1);
        }

		else if (key.getValue() == 1013
			&& mCaretColumn == (int)mTextRows[mCaretRow].size()
			&& mCaretRow < ((int)mTextRows.size() - 1)
			&& mEditable)
        {
            mTextRows[mCaretRow] += mTextRows[mCaretRow + 1];
            mTextRows.erase(mTextRows.begin() + mCaretRow + 1);
        }

        else if(key.getValue() == Key::PAGE_UP)
        {
            Widget* par = getParent();

            if (par != NULL)
            {
                int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight();
                mCaretRow -= rowsPerPage;

                if (mCaretRow < 0)
                {
                    mCaretRow = 0;
                }
            }
        }

        else if(key.getValue() == Key::PAGE_DOWN)
        {
            Widget* par = getParent();

            if (par != NULL)
            {
                int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight();
                mCaretRow += rowsPerPage;

                if (mCaretRow >= (int)mTextRows.size())
                {
                    mCaretRow = mTextRows.size() - 1;
                }
            }
        }

        else if(key.getValue() == Key::TAB
                && mEditable)
        {
            mTextRows[mCaretRow].insert(mCaretColumn, std::string("    "));
            mCaretColumn += 4;
        }

        else if (key.isCharacter()
                 && mEditable)
        {
            mTextRows[mCaretRow].insert(mCaretColumn, std::string(1,(char)key.getValue()));
            ++mCaretColumn;
        }

		// ak add ime
		else if (key.isIME())
		{
			char szImeChar[3];

			if (key.getValue() < 128)
			{
				szImeChar[0]=(char)key.getValue();   
				szImeChar[1]='\0';   
			}
			else
			{
				szImeChar[0]=(char)(key.getValue()>>8);   
				szImeChar[1]=(char)key.getValue();
				szImeChar[2]='\0';
			}

			mTextRows[mCaretRow].insert(mCaretColumn, szImeChar);
			++mCaretColumn;
		}
Ejemplo n.º 20
0
void CArmySprite::enemyUpdate(float fEscapeTime)
{
	switch(m_eCurState)
	{
	case AS_DEFAULT:
		break;
	case AS_MOVE:
		//if (getPosition().y < -getContentSize().height || getPosition().y > mScreenSize.height - BANNER_HEIGHT + getContentSize().height)
		//{
		//	m_eCurState = BS_HIDE;
		//}
		m_fFireCoolTime += fEscapeTime;
		if (m_fFireCoolTime > 2.0f)
		{
			fireBullet(fEscapeTime);
		}
		break;
	case AS_EXPLODE:
		break;
	case AS_HIDE:
		if(getPosition().y < -getContentSize().height * 0.5f)
		{
			getParent()->removeChild(this, true);
		}
		break;
	}

	if (m_eCurState < AS_EXPLODE && m_sCurData.mKind < AK_BUNKER01)
	{
		CCNode *m_pTarget = (CCNode*)(getParent()->getChildByTag(PALYER_TYPE));

		float o = m_pTarget->getPosition().x - getPosition().x;
		float a = m_pTarget->getPosition().y - getPosition().y;
		float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );

		if( a < 0 ) 
		{
			if(  o < 0 )
				at = 180 + fabs(at);
			else
				at = 180 - fabs(at);    
		}
		m_pTurretSprite->setRotation(180 + at);
	}

	if (getPosition().y > -getContentSize().height * 0.5f)
	{
		setPosition(ccpAdd(getPosition(),ccpMult(ccp(0.0f, -1.0f), m_sCurData.mMoveSpeed * fEscapeTime)));
	}
	else
	{
		m_eCurState = AS_HIDE;
	}

	if (!m_bIsNormal)
	{
		m_fFlashTime += fEscapeTime;
		if (m_fFlashTime > 0.1f)
		{
			m_fFlashTime = 0.0f;
			CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTurretSprite);
			pRGBAProtocol->setColor(color);
			m_bIsNormal = true;
		}
	}
}
Ejemplo n.º 21
0
const LLMatrix4& LLDrawable::getRenderMatrix() const
{ 
	return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix();
}
Ejemplo n.º 22
0
void LabelMenuLayer::showCurrentTest()
{
    auto scene = (LabelMainScene*) getParent();
    scene->autoShowLabelTests(_curCase,LabelMainScene::AUTO_TEST_NODE_NUM);
}
int DroidStimpackModuleDataComponent::handleObjectMenuSelect(CreatureObject* player, byte selectedID, PetControlDevice* controller) {

    ManagedReference<DroidObject*> droid = getDroidObject();
    DroidComponent* droidComponent = cast<DroidComponent*>(getParent());
    if( droid == NULL || droidComponent == NULL) {
        player->sendSystemMessage("@pet/droid_modules:stimpack_error");
        return 0;
    }
    if( selectedID == LOAD_STIMPACK ) {
        Locker dLock(droid);
        Locker crossLoker(player,droid);
        ManagedReference<SceneObject*> inventory = player->getSlottedObject("inventory");
        if (inventory == NULL) {
            player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
            return 0;
        }
        int foundStims = 0;
        for (int i = 0; i < inventory->getContainerObjectsSize(); ++i) {
            SceneObject* item = inventory->getContainerObject(i);

            if (!item->isTangibleObject())
                continue;

            TangibleObject* tano = cast<TangibleObject*>( item);
            // check it they have atleast 1 stim pack
            if (tano->isPharmaceuticalObject()) {
                PharmaceuticalObject* pharma = cast<PharmaceuticalObject*>( tano);
                if (pharma->isStimPack()) {
                    StimPack* stim = cast<StimPack*>(pharma);
                    if (stim->isClassA()) {
                        foundStims += 1;
                    }
                }
            }
        }
        if (foundStims == 0) {
            player->sendSystemMessage("@pet/droid_modules:no_stimpacks");
            return 0;
        } else {
            sendLoadUI(player);
            return 0;
        }
    }
    if( selectedID == REQUEST_STIMPACK ) {
        // we need to check cooldown on droid
        if( droid->isDead() || droid->isIncapacitated() || player->isDead()) {
            return 0;
        }

        // Droid must have power
        if( !droid->hasPower() ) {
            droid->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
            return 0;
        }
        if(droid->getPendingTask("droid_request_stimpack") != NULL) {
            player->sendSystemMessage("@pet/droid_modules:stimpack_not_ready");
            return 0;
        }
        // Submit repair task
        Reference<Task*> task = new DroidStimpackTask( droid,player,controller->getCustomObjectName().toString() );
        droid->addPendingTask("droid_request_stimpack", task, 1); // rte determines when it will fire it
    }
    return 0;
}
Ejemplo n.º 24
0
// 获取主角当前的位置
Point Enemy::getActorPos()
{
	Point p = getParent()->getChildByTag(TAG_ACTOR)->getPosition();
	return p;
}
Ejemplo n.º 25
0
void SpyFrame::handleSearch(const tstring& searchString) {
	if(Util::strnicmp(searchString.c_str(), _T("TTH:"), 4) == 0)
		SearchFrame::openWindow(getParent(), searchString.substr(4), 0, SearchManager::SIZE_DONTCARE, SearchManager::TYPE_TTH);
	else
		SearchFrame::openWindow(getParent(), searchString);
}
Ejemplo n.º 26
0
void GObject::sendForward() {
   GCompound *parent = getParent();
   if (parent != NULL) parent->sendForward(this);
}
Ejemplo n.º 27
0
	void TabItem::setButtonWidth(int _width)
	{
		TabControl* owner = getParent() != nullptr ? getParent()->castType<TabControl>(false) : nullptr;
		if (owner != nullptr)
			owner->setButtonWidth(this, _width);
	}
Ejemplo n.º 28
0
void GObject::sendToBack() {
   GCompound *parent = getParent();
   if (parent != NULL) parent->sendToBack(this);
}
Ejemplo n.º 29
0
void DepotLocker::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, bool isCompleteRemoval, cylinderlink_t link /*= LINK_OWNER*/)
{
	if (getParent() != NULL) {
		getParent()->postRemoveNotification(thing, newParent, index, isCompleteRemoval, LINK_PARENT);
	}
}
Ejemplo n.º 30
0
void SkillDialog::postInit()
{
    setLocationRelativeTo(getParent());
    loadWindowState();
    enableVisibleSound(true);
}