void setValue(float v) { value=v; for(int i=0;i<=1024;++i) { int tr=(int)((1.0f-value)*255); int tg=(int)(value*255); DWORD tcolor=ARGB(alpha,tr,tg,0); smColorHSVA *tc=new smColorHSVA(tcolor); if(tc->v<0.85)tc->v=0.85; tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha); delete tc; if((float)i/1024.<=value) { circle->setColor(i,2,tcolor); circle->setColor(i,1,SETA(0x00FFFFFF,alpha)); circle->setColor(i,0,tcolor); } else { circle->setColor(i,2,0); circle->setColor(i,1,0); circle->setColor(i,0,0); } } }
void Console::RenderTypeSuggestions() { if( input_line.size() == 0 || suggestion_map.size() == 0 ) { return; } const float x1 = x; const float x2 = x1 + suggestion_box_width + 2 * text_off_left; const float y1 = y + h; const float y2 = y1 + text_off_down + line_height * suggestion_map.size(); back->SetColor( SETA( suggestion_back_color, opacity ) ); back->Render4V( x1, y1, x2, y1, x2, y2, x1, y2 ); int n = 0; for( StrMap::iterator it = suggestion_map.begin(); it != suggestion_map.end(); ++it ) { if( n == sugg_pos ) { fnt->SetColor( SETA( fnt_highlight_color, fnt_opacity ) ); } else { fnt->SetColor( SETA( fnt_suggestion_color, fnt_opacity ) ); } std::string s = it->first + ' ' + it->second; fnt->Render( x + text_off_left, y + h + line_height * n, HGETEXT_LEFT, s.c_str() ); n++; } }
void Console::RenderHistory() { fnt->SetColor( SETA( fnt_history_color, fnt_opacity ) ); const int max_n = (int)(( h - text_off_top - text_off_down ) / line_height - 2); int n = (int)big_history.size() - 1 < max_n ? big_history.size() - 1 : max_n; for( StrList::iterator it = big_history.begin(); it != big_history.end(); ++it ) { if( it->substr( 0, 3 ) == ">> " ) { fnt->SetColor( SETA( fnt_history_line_sign_color, fnt_opacity ) ); fnt->Render( x + text_off_left, y + text_off_top + n * line_height, HGETEXT_LEFT, ">> " ); fnt->SetColor( SETA( fnt_history_color, fnt_opacity ) ); fnt->Render( x + text_off_left + fnt->GetStringWidth( ">> " ), y + text_off_top + n * line_height, HGETEXT_LEFT, it->substr( 3 ).c_str() ); } else { fnt->Render( x + text_off_left, y + text_off_top + n * line_height, HGETEXT_LEFT, it->c_str() ); } --n; if( n < 0 ) { break; } } }
void Console::RenderInputLine() { fnt->Render( x + text_off_left, y + h - text_off_down - fnt->GetHeight(), HGETEXT_LEFT, input_line.c_str() ); if( SelectionIsActive() ) { std::string before, sel; if( sel_length > 0 ) { before = input_line.substr( 0, sel_start ); sel = input_line.substr( sel_start, sel_length ); } else { before = input_line.substr( 0, sel_start + sel_length ); sel = input_line.substr( sel_start + sel_length, -sel_length ); } const float sel_x1 = x + text_off_left + fnt->GetStringWidth( before.c_str() ); const float sel_x2 = sel_x1 + fnt->GetStringWidth( sel.c_str() ); const float sel_y1 = y + h - text_off_down; const float sel_y2 = y + h - text_off_down - fnt->GetHeight(); q->v[0].x = sel_x1; q->v[0].y = sel_y1; q->v[1].x = sel_x2; q->v[1].y = sel_y1; q->v[2].x = sel_x2; q->v[2].y = sel_y2; q->v[3].x = sel_x1; q->v[3].y = sel_y2; q->v[0].col = SETA( selection_color, selection_opacity ); q->v[1].col = SETA( selection_color, selection_opacity ); q->v[2].col = SETA( selection_color, selection_opacity ); q->v[3].col = SETA( selection_color, selection_opacity ); hge->Gfx_RenderQuad( q.get() ); } fnt->Render( x + text_off_left, y + h - text_off_down - fnt->GetHeight(), HGETEXT_LEFT, input_line.c_str() ); if( blink_timer.GetTime() < blinkie_time ) { //the little blinking helper thing float line_x = x + text_off_left + fnt->GetStringWidth( input_line.substr( 0, input_line_pos ).c_str() ); float line_h = fnt->GetHeight(); float line_y = y + h - text_off_down - fnt->GetHeight(); hge->Gfx_RenderLine( line_x, line_y, line_x, line_y + line_h, SETA( blinkie_color, blinkie_opacity ) ); } else if( blink_timer.GetTime() > 2 * blinkie_time ) { blink_timer.Restart(); } }
void setValue(float v) { value=v; int tr=(int)((1.0f-value)*255); int tg=(int)(value*255); DWORD tcolor=ARGB(alpha,tr,tg,0); smColorHSVA *tc=new smColorHSVA(tcolor); if(tc->v<0.85)tc->v=0.85; tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha); delete tc; upper->setColor(tcolor,0);upper->setColor(tcolor,1); upper->setColor(0,2);upper->setColor(0,3); lower->setColor(0,0);lower->setColor(0,1); lower->setColor(tcolor,2);lower->setColor(tcolor,3); }
int main(int argc, const char *argv[]) { DATA->a = 10; printf("a:%d\n", DATA->a); SETA(2); PRINTA(); return 0; }
void CParticleSystem::Render() { DWORD dwColor=m_Info.pSprite->GetColor(); PPARTICLE pPar=m_Particles; for (int i=0; i<m_nParticlesAlive; i++, pPar++) { if(m_Info.colColorStart.r<0) m_Info.pSprite->SetColor(SETA(m_Info.pSprite->GetColor(), pPar->colColor.a*255.0f)); else m_Info.pSprite->SetColor(pPar->colColor.GetColor()); m_Info.pSprite->RenderEx(pPar->vecLocation.x*m_fScale+m_fTx, pPar->vecLocation.y*m_fScale+m_fTy, pPar->fSpin*pPar->fAge, pPar->fSize*m_fScale); } m_Info.pSprite->SetColor(dwColor); }
void Console::RenderBones() { back->SetColor( SETA( large_back_color, opacity ) ); back->Render( x, y ); // //line above input line // const float x1 = x; // const float x2 = x + w; // const float y1 = y + h - text_off_down - fnt->GetHeight(); // // hge->Gfx_RenderLine( x1, y1, x2, y1, SETA( delimiter_color, delimiter_opacity ) ); // const float x3 = x + w; // const float y2 = y + h; // const float y3 = y2 - text_off_down - fnt->GetHeight(); // // hge->Gfx_RenderLine( x3, y2, x3, y3, SETA( delimiter_color, delimiter_opacity ) ); }
void hgeParticleSystem::Render() { int i; uint32_t col; hgeParticle *par=particles; col=info.sprite->GetColor(); for(i=0; i<nParticlesAlive; i++) { if(info.colColorStart.r < 0) info.sprite->SetColor(SETA(info.sprite->GetColor(),par->colColor.a*255)); else info.sprite->SetColor(par->colColor.GetHWColor()); info.sprite->RenderEx(par->vecLocation.x*fScale+fTx, par->vecLocation.y*fScale+fTy, par->fSpin*par->fAge, par->fSize*fScale); par++; } info.sprite->SetColor(col); }
int slap_sort_vals( Modifications *ml, const char **text, int *dup, void *ctx ) { AttributeDescription *ad; MatchingRule *mr; int istack[sizeof(int)*16]; int i, j, k, l, ir, jstack, match, *ix, itmp, nvals, rc = LDAP_SUCCESS; int is_norm; struct berval a, *cv; #define SMALL 8 #define SWAP(a,b,tmp) tmp=(a);(a)=(b);(b)=tmp #define COMP(a,b) match=0; rc = ordered_value_match( &match, \ ad, mr, SLAP_MR_EQUALITY \ | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX \ | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH \ | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, \ &(a), &(b), text ); #define IX(x) ix[x] #define EXCH(x,y) SWAP(ix[x],ix[y],itmp) #define SETA(x) itmp = ix[x]; a = cv[itmp] #define GETA(x) ix[x] = itmp; #define SET(x,y) ix[x] = ix[y] ad = ml->sml_desc; nvals = ml->sml_numvals; if ( nvals <= 1 ) goto ret; /* For Modifications, sml_nvalues is NULL if normalization wasn't needed. * For Attributes, sml_nvalues == sml_values when normalization isn't needed. */ if ( ml->sml_nvalues && ml->sml_nvalues != ml->sml_values ) { cv = ml->sml_nvalues; is_norm = 1; } else { cv = ml->sml_values; is_norm = 0; } if ( ad == slap_schema.si_ad_objectClass ) mr = NULL; /* shortcut matching */ else mr = ad->ad_type->sat_equality; /* record indices to preserve input ordering */ ix = slap_sl_malloc( nvals * sizeof(int), ctx ); for (i=0; i<nvals; i++) ix[i] = i; ir = nvals-1; l = 0; jstack = 0; for(;;) { if (ir - l < SMALL) { /* Insertion sort */ match=1; for (j=l+1;j<=ir;j++) { SETA(j); for (i=j-1;i>=0;i--) { COMP(cv[IX(i)], a); if ( match <= 0 ) break; SET(i+1,i); } GETA(i+1); if ( match == 0 ) goto done; } if ( jstack == 0 ) break; if ( match == 0 ) break; ir = istack[jstack--]; l = istack[jstack--]; } else { k = (l + ir) >> 1; /* Choose median of left, center, right */ EXCH(k, l+1); COMP( cv[IX(l)], cv[IX(ir)] ); if ( match > 0 ) { EXCH(l, ir); } else if ( match == 0 ) { i = ir; break; } COMP( cv[IX(l+1)], cv[IX(ir)] ); if ( match > 0 ) { EXCH(l+1, ir); } else if ( match == 0 ) { i = ir; break; } COMP( cv[IX(l)], cv[IX(l+1)] ); if ( match > 0 ) { EXCH(l, l+1); } else if ( match == 0 ) { i = l; break; } i = l+1; j = ir; a = cv[IX(i)]; for(;;) { do { i++; COMP( cv[IX(i)], a ); } while( match < 0 ); while( match > 0 ) { j--; COMP( cv[IX(j)], a ); } if (j < i) { match = 1; break; } if ( match == 0 ) { i = l+1; break; } EXCH(i,j); } if ( match == 0 ) break; EXCH(l+1,j); jstack += 2; if (ir-i+1 >= j) { istack[jstack] = ir; istack[jstack-1] = i; ir = j; } else { istack[jstack] = j; istack[jstack-1] = l; l = i; } } } done: if ( match == 0 && i >= 0 ) *dup = ix[i]; /* For sorted attributes, put the values in index order */ if ( rc == LDAP_SUCCESS && match && ( ad->ad_type->sat_flags & SLAP_AT_SORTED_VAL )) { BerVarray tmpv = slap_sl_malloc( sizeof( struct berval ) * nvals, ctx ); for ( i = 0; i<nvals; i++ ) tmpv[i] = cv[ix[i]]; for ( i = 0; i<nvals; i++ ) cv[i] = tmpv[i]; /* Check if the non-normalized array needs to move too */ if ( is_norm ) { cv = ml->sml_values; for ( i = 0; i<nvals; i++ ) tmpv[i] = cv[ix[i]]; for ( i = 0; i<nvals; i++ ) cv[i] = tmpv[i]; } slap_sl_free( tmpv, ctx ); } slap_sl_free( ix, ctx ); if ( rc == LDAP_SUCCESS && match == 0 ) { /* value exists already */ assert( i >= 0 ); assert( i < nvals ); rc = LDAP_TYPE_OR_VALUE_EXISTS; } ret: return rc; }