Exemplo n.º 1
0
void InfoBox::UpdateDialog()
{
    if( !is_visible() ) return;
#if 0
    if( !f_editCharAction && f_refActionGroup )
    {
        f_editCharAction = f_refActionGroup->get_action( "Edit::Edit" );
    }
#endif

    f_infoBuffer->erase( f_infoBuffer->begin(), f_infoBuffer->end() );
    //
    if( f_char )
    {
        GenerateAbilityString();
        GenerateBuiltinString();
        GenerateStatString();
        //
        AddCR();
        AddNotesString();
        //
        //MakeReadOnly();
    }
    show_all();
}
Exemplo n.º 2
0
void InfoBox::GenerateStatString()
{
    auto statMgr( GetStatMgr().lock() );
    assert(statMgr);
    auto		iter( statMgr->GetStats().begin() );
    const auto	end ( statMgr->GetStats().end()   );

    while( iter != end )
    {
        Stat::pointer_t	stat ( iter->second );

        const int mod   = f_char->getMod( stat->id(), true /*with_ability*/ );
        const bool last = (++iter == end);

        if( stat->ability() || stat->internal() ) continue;

        AddAttribute( stat->name(), mod );

        if( last )
        {
            AddCR();
        }
        else
        {
            AddComma();
        }
    }
}
Exemplo n.º 3
0
void InfoBox::GenerateAbilityString()
{
    f_infoBuffer->insert_at_cursor( "Name: " );
    f_infoBuffer->insert_at_cursor( f_char->name() );
    f_infoBuffer->insert_at_cursor( " " );
    Glib::RefPtr<Gtk::TextChildAnchor> refAnchor = f_infoBuffer->create_child_anchor(f_infoBuffer->end());
    Gtk::Button* editBtn = Gtk::manage( new Gtk::Button("Edit") );
    editBtn->signal_clicked().connect( sigc::mem_fun( *this, &InfoBox::OnEditCharacter ) );
    //editBtn->set_sensitive( true );
    add_child_at_anchor( *editBtn, refAnchor );
    f_infoBuffer->insert_at_cursor( "\n" );
    editBtn->show_all();

    auto statMgr( GetStatMgr().lock() );
    assert(statMgr);

    auto       iter (statMgr->GetStats().begin());
    const auto end  (statMgr->GetStats().end()  );

    while( iter != end )
    {
        Stat::pointer_t stat ( iter->second );
        Value::pointer_t value ( f_char->getStat( stat->id() ) );

        const bool last = (++iter == end);

        if( !stat->ability() ) continue;
#if 0
        if( stat->enabled() )
        {
#endif
            AddAttribute( stat->name(), value->total() );
            AddModifier( Common::StatToMod( value->total() ) );
#if 0
        }
        else
        {
            AddAttribute( stat->name(), "--" );
        }
#endif

        if( last )
        {
            AddCR();
        }
        else
        {
            AddComma();
        }
    }
}
Exemplo n.º 4
0
void InfoBox::GenerateBuiltinString()
{
    const int	init    = f_char->getMod( GetStatMgr().lock()->initId(), true /*with_ability*/ );
    const int	hp      = f_char->maxHP();
    const int	damage  = f_char->damage();
    const int	hp_left = f_char->hitpoints();
    const int	pct     = hp? (int)(((float)hp_left / (float) hp) * 100.0): 0;

    AddAttribute( "Init",              init    );
    AddComma();
    AddAttribute( "Max Hitpoints",     hp      );
    AddComma();
    AddAttribute( "Current Damage",    damage  );
    AddComma();
    AddAttribute( "Current Hitpoints", hp_left );
    AddPercentage( pct>=0? pct: 0 );
    AddCR();
}
Exemplo n.º 5
0
wchar_t* GetStr(STATUSMSGINFO *n, const wchar_t *tmplt)
{
	if (n == nullptr || tmplt == nullptr || tmplt[0] == '\0')
		return nullptr;

	CMStringW res;
	size_t len = mir_wstrlen(tmplt);

	for (size_t i = 0; i < len; i++) {
		if (tmplt[i] == '%') {
			i++;
			switch (tmplt[i]) {
			case 'n':
				if (n->compare == COMPARE_DEL || mir_wstrcmp(n->newstatusmsg, TranslateT("<no status message>")) == 0)
					res.Append(TranslateT("<no status message>"));
				else
					AddCR(res, n->newstatusmsg);
				break;

			case 'o':
				if (n->oldstatusmsg == nullptr || n->oldstatusmsg[0] == '\0' || mir_wstrcmp(n->oldstatusmsg, TranslateT("<no status message>")) == 0)
					res.Append(TranslateT("<no status message>"));
				else
					AddCR(res, n->oldstatusmsg);
				break;

			case 'c':
				if (n->hContact == NULL)
					res.Append(TranslateT("Contact"));
				else
					res.Append(Clist_GetContactDisplayName(n->hContact));
				break;

			case 's':
				if (n->hContact == NULL)
					res.Append(TranslateT("<unknown>"));
				else
					res.Append(StatusList[Index(db_get_w(n->hContact, n->proto, "Status", ID_STATUS_ONLINE))].lpzStandardText);
				break;

			default:
				i--;
				res.AppendChar(tmplt[i]);
				break;
			}
		}
		else if (tmplt[i] == '\\') {
			i++;
			switch (tmplt[i]) {
			case 'n':
				res.AppendChar('\r');
				res.AppendChar('\n');
				break;
			case 't':
				res.AppendChar('\t');
				break;
			default:
				i--;
				res.AppendChar(tmplt[i]);
				break;
			}
		}
		else res.AppendChar(tmplt[i]);
	}

	if (res.GetLength() > 2044) {
		res.Truncate(2044);
		res.Append(L"...");
	}

	return mir_wstrndup(res, res.GetLength());
}