/** * Berechnet Spielerfarbe mit in eine gegebene Farbe mit ein * (player muss mit +1 gegeben sein!) * * @author OLiver */ unsigned IngameMinimap::CombineWithPlayerColor(const unsigned color, const unsigned char player) const { // Spielerfarbe mit einberechnen unsigned player_color = COLORS[GameClient::inst().GetPlayer(player-1)->color]; return MakeColor(0xFF,(GetRed(color)+GetRed(player_color))/2, (GetGreen(color)+GetGreen(player_color))/2, (GetBlue(color)+GetBlue(player_color))/2); }
/** * Berechnet Spielerfarbe mit in eine gegebene Farbe mit ein * (player muss mit +1 gegeben sein!) */ unsigned IngameMinimap::CombineWithPlayerColor(const unsigned color, const unsigned char player) const { // Spielerfarbe mit einberechnen unsigned player_color = gwv.GetWorld().GetPlayer(player - 1).color; return MakeColor(0xFF, (GetRed(color) + GetRed(player_color)) / 2, (GetGreen(color) + GetGreen(player_color)) / 2, (GetBlue(color) + GetBlue(player_color)) / 2); }
PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { ASSERT(m_pApp); PWL_CREATEPARAM cp; cp.pParentWnd = nullptr; cp.pProvider = this; cp.rcRectWnd = GetPDFWindowRect(); uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; uint32_t dwFieldFlag = m_pWidget->GetFieldFlags(); if (dwFieldFlag & FIELDFLAG_READONLY) { dwCreateFlags |= PWS_READONLY; } FX_COLORREF color; if (m_pWidget->GetFillColor(color)) { cp.sBackgroundColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color)); } if (m_pWidget->GetBorderColor(color)) { cp.sBorderColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color)); } cp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0); if (m_pWidget->GetTextColor(color)) { cp.sTextColor = CPWL_Color(GetRed(color), GetGreen(color), GetBlue(color)); } cp.fFontSize = m_pWidget->GetFontSize(); cp.dwBorderWidth = m_pWidget->GetBorderWidth(); cp.nBorderStyle = m_pWidget->GetBorderStyle(); switch (cp.nBorderStyle) { case BorderStyle::DASH: cp.sDash = CPWL_Dash(3, 3, 0); break; case BorderStyle::BEVELED: cp.dwBorderWidth *= 2; break; case BorderStyle::INSET: cp.dwBorderWidth *= 2; break; default: break; } if (cp.fFontSize <= 0) dwCreateFlags |= PWS_AUTOFONTSIZE; cp.dwFlags = dwCreateFlags; cp.pSystemHandler = m_pApp->GetSysHandler(); return cp; }
void Color::ToFloat(float Dest[]) const { Dest[0] = GetRed() / 255.0f; Dest[1] = GetGreen() / 255.0f; Dest[2] = GetBlue() / 255.0f; Dest[3] = GetAlpha() / 255.0f; }
/** * Additional stuff we need to do before drawing (in this case: update the map) */ void IngameMinimap::BeforeDrawing() { // Ab welcher Knotenanzahl (Teil der Gesamtknotenanzahl) die Textur komplett neu erstellt werden soll static const unsigned MAX_NODES_UPDATE_DENOMINATOR = 2; // (2 = 1/2, 3 = 1/3 usw.) if(!nodesToUpdate.empty()) { // Komplette Textur neu erzeugen, weil es zu viele Knoten sind? if(nodesToUpdate.size() >= map_width * map_height / MAX_NODES_UPDATE_DENOMINATOR) { // Ja, alles neu erzeugen UpdateAll(); for(MapPoint p(0, 0); p.y < map_height; p.y++) for(p.x = 0; p.x < map_width; p.x++) nodes_updated[GetMMIdx(p)] = false; } else { // Entsprechende Pixel updaten for(std::vector<MapPoint>::iterator it = nodesToUpdate.begin(); it != nodesToUpdate.end(); ++it) { for(unsigned t = 0; t < 2; ++t) { unsigned color = CalcPixelColor(*it, t); map.tex_setPixel((it->x * 2 + t + (it->y & 1)) % (map_width * 2), it->y, GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); } nodes_updated[GetMMIdx(*it)] = false; } } this->nodesToUpdate.clear(); } }
/** * * @author OLiver */ unsigned PreviewMinimap::CalcPixelColor(const void * param, const MapCoord x, const MapCoord y, const unsigned t) { const glArchivItem_Map& s2map = *static_cast<const glArchivItem_Map*>(param); unsigned color = 0; // Baum an dieser Stelle? unsigned char landscape_obj = s2map.GetMapDataAt(MAP_TYPE, x, y); if(landscape_obj >= 0xC4 && landscape_obj <= 0xC6) color = VaryBrightness(TREE_COLOR,VARY_TREE_COLOR); // Granit an dieser Stelle? else if(landscape_obj == 0xCC || landscape_obj == 0xCD) color = VaryBrightness(GRANITE_COLOR,VARY_GRANITE_COLOR); // Ansonsten die jeweilige Terrainfarbe nehmen else { color = TERRAIN_COLORS[s2map.getHeader().getGfxSet()] [TERRAIN_INDIZES[s2map.GetMapDataAt(MapLayer(MAP_TERRAIN1+t),x,y)]]; // Schattierung int r = GetRed(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40; int g = GetGreen(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40; int b = GetBlue(color)+s2map.GetMapDataAt(MAP_SHADOWS, x, y)-0x40; if(r < 0) r = 0; if(r > 255) r = 255; if(g < 0) g = 0; if(g > 255) g = 255; if(b < 0) b = 0; if(b > 255) b = 255; color = MakeColor(0xFF,unsigned(r),unsigned(g),unsigned(b)); } return color; }
/** * * @author OLiver */ unsigned PreviewMinimap::CalcPixelColor(const MapPoint pt, const unsigned t) { unsigned color = 0; // Baum an dieser Stelle? unsigned char landscape_obj = objects[GetMMIdx(pt)]; if(landscape_obj >= 0xC4 && landscape_obj <= 0xC6) color = VaryBrightness(TREE_COLOR, VARY_TREE_COLOR); // Granit an dieser Stelle? else if(landscape_obj == 0xCC || landscape_obj == 0xCD) color = VaryBrightness(GRANITE_COLOR, VARY_GRANITE_COLOR); // Ansonsten die jeweilige Terrainfarbe nehmen else { color = TerrainData::GetColor(lt, TerrainData::MapIdx2Terrain(t == 0 ? terrain1[GetMMIdx(pt)] : terrain2[GetMMIdx(pt)])); // Schattierung const int shading = shadows[GetMMIdx(pt)] - 0x40; int r = GetRed(color) + shading; int g = GetGreen(color) + shading; int b = GetBlue(color) + shading; if(r < 0) r = 0; if(r > 255) r = 255; if(g < 0) g = 0; if(g > 255) g = 255; if(b < 0) b = 0; if(b > 255) b = 255; color = MakeColor(0xFF, unsigned(r), unsigned(g), unsigned(b)); } return color; }
// **************************************************************************** // // Function Name: RSolidColor::DarkenBy( ) // // Description: // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // void RSolidColor::DarkenBy( YScaleFactor scale ) { YColorComponent red = GetRed(); YColorComponent green = GetGreen(); YColorComponent blue = GetBlue(); uLONG redder = static_cast<uLONG>( ::Round( static_cast<YRealDimension>( red ) * scale ) ); uLONG greener = static_cast<uLONG>( ::Round( static_cast<YRealDimension>( green ) * scale ) ); uLONG bluer = static_cast<uLONG>( ::Round( static_cast<YRealDimension>( blue ) * scale ) ); TpsAssert( ( scale >= 0.0 ), "Negative color component makes no sense." ); TpsAssert( ( scale <= 1.0 ), "Bad color component scale factor." ); red = ( redder > red ) ? kMinColorComponent : static_cast<YColorComponent>( red - redder ); green = ( greener > green ) ? kMinColorComponent : static_cast<YColorComponent>( green - greener ); blue = ( bluer > blue ) ? kMinColorComponent : static_cast<YColorComponent>( blue - bluer ); #ifdef _WINDOWS m_Color = RGB( red, green, blue ); #endif // _WINDOWS #ifdef MAC m_Color.red = red; m_Color.green = green; m_Color.blue = blue; #endif // MAC }
/** * * @author OLiver */ void Minimap::CreateMapTexture(const void *param) { map.DeleteTexture(); if(!param) return; /// Buffer für die Daten erzeugen unsigned char *buffer = new unsigned char[map_width * 2 * map_height * 4]; for(MapCoord y = 0;y<map_height;++y) { for(MapCoord x = 0;x<map_width;++x) { // Die 2. Terraindreiecke durchgehen for(unsigned t = 0;t<2;++t) { unsigned color = CalcPixelColor(param,x,y,t); unsigned pos = y*map_width*4*2+(x*4*2+t*4+(y&1)*4)%(map_width*4*2); buffer[pos+2] = GetRed(color); buffer[pos+1] = GetGreen(color); buffer[pos] = GetBlue(color); buffer[pos+3] = GetAlpha(color); } } } map.setFilter(GL_LINEAR); map.create(map_width*2, map_height, buffer, map_width*2, map_height, libsiedler2::FORMAT_RGBA, LOADER.GetPaletteN("pal5")); delete [] buffer; }
void SkeletonSprite::Render() const { // TAREA: Implementar la especificacion del enunciado Renderer::Instance().SetBlendMode( GetBlendMode() ); Renderer::Instance().SetColor( GetRed(), GetGreen(), GetBlue(), GetAlpha() ); glPushMatrix(); glTranslated( GetX(), GetY(), 0 ); root->Render(); glPopMatrix(); }
sf::Color rbColor::ToSFML( VALUE aColor ) { aColor = rbColor::ToRuby( aColor ); sf::Uint8 r = NUM2CHR( GetRed( aColor ) ); sf::Uint8 g = NUM2CHR( GetGreen( aColor ) ); sf::Uint8 b = NUM2CHR( GetBlue( aColor ) ); sf::Uint8 a = NUM2CHR( GetAlpha( aColor ) ); return sf::Color( r, g, b, a ); }
Color Color::Modulate(const Color& c) const { uint8 R = static_cast<uint8>(GetRed() * c.GetRed() / 255); uint8 G = static_cast<uint8>(GetGreen() * c.GetGreen() / 255); uint8 B = static_cast<uint8>(GetBlue() * c.GetBlue() / 255); uint8 A = static_cast<uint8>(GetAlpha() * c.GetAlpha() / 255); return Color(R, G, B, A); }
/** * Zeichnet die Textur. * * @author FloSoft */ void glArchivItem_Bitmap::Draw(short dst_x, short dst_y, short dst_w, short dst_h, short src_x, short src_y, short src_w, short src_h, const unsigned int color, const unsigned int unused) { if(texture == 0) GenerateTexture(); if(texture == 0) return; if(src_w == 0) src_w = width_; if(src_h == 0) src_h = height_; if(dst_w == 0) dst_w = src_w; if(dst_h == 0) dst_h = src_h; VIDEODRIVER.BindTexture(texture); assert(getBobType() != libsiedler2::BOBTYPE_BITMAP_PLAYER); struct GL_T2F_C4UB_V3F_Struct { GLfloat tx, ty; GLubyte r, g, b, a; GLfloat x, y, z; }; GL_T2F_C4UB_V3F_Struct tmp[4]; int x = -nx_ + dst_x; int y = -ny_ + dst_y; tmp[0].x = tmp[1].x = GLfloat(x); tmp[2].x = tmp[3].x = GLfloat(x + dst_w); tmp[0].y = tmp[3].y = GLfloat(y); tmp[1].y = tmp[2].y = GLfloat(y + dst_h); tmp[0].z = tmp[1].z = tmp[2].z = tmp[3].z = 0.0f; tmp[0].tx = tmp[1].tx = (GLfloat)src_x / tex_width_; tmp[2].tx = tmp[3].tx = (GLfloat)(src_x + src_w) / tex_width_; tmp[0].ty = tmp[3].ty = (GLfloat)src_y / tex_height_; tmp[1].ty = tmp[2].ty = (GLfloat)(src_y + src_h) / tex_height_; tmp[0].r = tmp[1].r = tmp[2].r = tmp[3].r = GetRed(color); tmp[0].g = tmp[1].g = tmp[2].g = tmp[3].g = GetGreen(color); tmp[0].b = tmp[1].b = tmp[2].b = tmp[3].b = GetBlue(color); tmp[0].a = tmp[1].a = tmp[2].a = tmp[3].a = GetAlpha(color); glInterleavedArrays(GL_T2F_C4UB_V3F, 0, tmp); glDrawArrays(GL_QUADS, 0, 4); return; }
const Color& Color::operator *=(float v) { int R = static_cast<int>(GetRed() * v); int G = static_cast<int>(GetGreen() * v); int B = static_cast<int>(GetBlue() * v); int A = static_cast<int>(GetAlpha() * v); SetInt(R, G, B, A); return *this; }
const Color& Color::operator -=(const Color& c) { int R = GetRed() - c.GetRed(); int G = GetGreen() - c.GetGreen(); int B = GetBlue() - c.GetBlue(); int A = GetAlpha() - c.GetAlpha(); SetInt(R, G, B, A); return *this; }
Color Color::operator +(const Color& c) const { int R = GetRed() + c.GetRed(); int G = GetGreen() + c.GetGreen(); int B = GetBlue() + c.GetBlue(); int A = GetAlpha() + c.GetAlpha(); Color Ret; Ret.SetInt(R, G, B, A); return Ret; }
void CColour::Invert() { // Invert the RGB values int red(0),green(0),blue(0); // RGB values have a range of 255 red = ~(GetRed()); green = ~(GetGreen()); blue = ~(GetBlue()); SetRGB(red,green,blue); }
Color Color::operator *(float v) const { int R = static_cast<int>(GetRed() * v); int G = static_cast<int>(GetGreen() * v); int B = static_cast<int>(GetBlue() * v); int A = static_cast<int>(GetAlpha() * v); Color Ret; Ret.SetInt(R, G, B, A); return Ret; }
/** * zeichnet eine Linie. * * @param[in] x X-Koordinate * * @author jh */ void Window::DrawLine(unsigned short ax, unsigned short ay, unsigned short bx, unsigned short by, unsigned short width, unsigned int color) { glDisable(GL_TEXTURE_2D); glColor4ub(GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); glLineWidth(width); glBegin(GL_LINES); glVertex2i(ax, ay); glVertex2i(bx, by); glEnd(); glEnable(GL_TEXTURE_2D); }
/// Berechnet die dunklere Spielerfarbe zum Zeichnen unsigned CalcPlayerFOWDrawColor(const unsigned color) { // Farbkomponenten extrahieren unsigned red = GetRed(color), green = GetGreen(color), blue = GetBlue(color); // "Skalieren" red = red * FOW_DRAW_COLOR_BRIGHTNESS / 0xFF; green = green * FOW_DRAW_COLOR_BRIGHTNESS / 0xFF; blue = blue * FOW_DRAW_COLOR_BRIGHTNESS / 0xFF; // Fertige Farbe zurückgeben return MakeColor(0xFF, red, green, blue); }
void StaticText::SetText(cchar* text) { XAGUI::StaticText::SetText(text); Release(); SDL_Color color = { GetRed(), GetGreen(), GetBlue(), GetAlpha() }; SDL_Surface* surface = TTF_RenderUTF8_Blended_Wrapped(static_cast<Font*>(GetFont())->Get(), GetText(), color, GetFont()->GetTextWidth(text)); _texture = SDL_CreateTextureFromSurface(static_cast<Renderer*>(XAGUI::XAGUI::GetRenderer())->Get(), surface); SDL_SetTextureAlphaMod(_texture, color.a); SDL_FreeSurface(surface); }
/********************************************//** * \brief Draw a line on image in a given color * \warning NOT FUNCTIONNAL * \param img t_img* - image to modify (also output) * \param pix1 t_pixel - first point of line * \param pix2 t_pixel - second point of line * \param RGB CPU_INT32U - color of the line * \return t_vect - vector representing the line * * Needs to be done * Helpfull macro to define color is SetRGB(r,g,b), with value between 0 and 255 ***********************************************/ t_vect highlight_line(t_img * img,t_pixel pix1,t_pixel pix2,CPU_INT32U RGB) { t_vect v; CPU_FP32 a, b, y_calc; CPU_INT16S i,j; t_simplearea area_of_draw; if((pix2.x - pix1.x) != 0) { a = ((CPU_FP32)pix2.y - (CPU_FP32)pix1.y) / (((CPU_FP32)pix2.x - (CPU_FP32)pix1.x)); }else { a = 1000000; } b = (CPU_FP32)pix1.y - a * (CPU_FP32)pix1.x; //printf("y = %.2f x + %.2f\n",a,b); area_of_draw.BotLeft.x = mini(pix1.x,pix2.x); area_of_draw.BotLeft.y = mini(pix1.y,pix2.y); area_of_draw.TopRight.x = maxi(pix1.x,pix2.x); area_of_draw.TopRight.y = maxi(pix1.y,pix2.y); for(i=area_of_draw.BotLeft.y;i<= area_of_draw.TopRight.y ;i++) { for(j=area_of_draw.BotLeft.x ; (j<= area_of_draw.TopRight.x );j++) { //check if point belong to the line between pix1 and pix 2 y_calc = a * j + b; if(((CPU_INT16S)y_calc -abs(a)/1.5 <= i)&&((CPU_INT16S)y_calc +abs(a)/1.5 >= i)) { img->Red[i][j] = GetRed(RGB); img->Green[i][j] = GetGreen(RGB); img->Blue[i][j] = GetBlue(RGB); }else { //nothing } } } v.x = 5; v.y = a * v.x + b; return v; }
/** * zeichnet ein Rechteck. * * @param[in] x X-Koordinate * * @author OLiver */ void Window::DrawRectangle(unsigned short x, unsigned short y, unsigned short width, unsigned short height, unsigned int color) { glDisable(GL_TEXTURE_2D); glColor4ub(GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); glBegin(GL_QUADS); glVertex2i(x, y); glVertex2i(x, y+height); glVertex2i(x+width, y+height); glVertex2i(x+width, y); glEnd(); glEnable(GL_TEXTURE_2D); }
//--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/CppRainbow.htm void Rainbow( const double x, unsigned char& r, unsigned char& g, unsigned char& b) { const int r0 = GetRed(x); const int g0 = GetGreen(x); const int b0 = GetBlue(x); const int max = std::max(r0, std::max(g0,b0)); assert(max!=0); r = 255.0 * static_cast<double>(r0) / static_cast<double>(max); g = 255.0 * static_cast<double>(g0) / static_cast<double>(max); b = 255.0 * static_cast<double>(b0) / static_cast<double>(max); }
/** * Variiert die übergebene Farbe zufällig in der Helligkeit * * @author OLiver */ unsigned Minimap::VaryBrightness(const unsigned color, const int range) const { int add = 100 - rand()%(2*range); int red = GetRed(color)*add/100; if(red < 0) red = 0; else if(red > 0xFF) red = 0xFF; int green = GetGreen(color)*add/100; if(green < 0) green = 0; else if(green > 0xFF) green = 0xFF; int blue = GetBlue(color)*add/100; if(blue < 0) blue = 0; else if(blue > 0xFF) blue = 0xFF; return MakeColor(GetAlpha(color), red, green, blue); }
/** * Zeichnet die Textur. */ void glArchivItem_Bitmap::Draw(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) { if(GetTexture() == 0) return; RTTR_Assert(dstArea.getSize().x > 0 && dstArea.getSize().y > 0); RTTR_Assert(srcArea.getSize().x > 0 && srcArea.getSize().y > 0); // Compatibility only! Extent srcSize = srcArea.getSize(); if(srcSize.x == 0) srcSize.x = getWidth(); if(srcSize.y == 0) srcSize.y = getHeight(); srcArea.setSize(srcSize); Extent dstSize = dstArea.getSize(); if(dstSize.x == 0) dstSize.x = srcSize.x; if(dstSize.y == 0) dstSize.y = srcSize.y; dstArea.setSize(dstSize); RTTR_Assert(getBobType() != libsiedler2::BOBTYPE_BITMAP_PLAYER); std::array<Point<GLfloat>, 4> texCoords, vertices; dstArea.move(-GetOrigin()); vertices[0].x = vertices[1].x = GLfloat(dstArea.left); vertices[2].x = vertices[3].x = GLfloat(dstArea.right); vertices[0].y = vertices[3].y = GLfloat(dstArea.top); vertices[1].y = vertices[2].y = GLfloat(dstArea.bottom); Point<GLfloat> srcOrig = Point<GLfloat>(srcArea.getOrigin()) / GetTexSize(); Point<GLfloat> srcEndPt = Point<GLfloat>(srcArea.getEndPt()) / GetTexSize(); texCoords[0].x = texCoords[1].x = srcOrig.x; texCoords[2].x = texCoords[3].x = srcEndPt.x; texCoords[0].y = texCoords[3].y = srcOrig.y; texCoords[1].y = texCoords[2].y = srcEndPt.y; glVertexPointer(2, GL_FLOAT, 0, vertices.data()); glTexCoordPointer(2, GL_FLOAT, 0, texCoords.data()); VIDEODRIVER.BindTexture(GetTexture()); glColor4ub(GetRed(color), GetGreen(color), GetBlue(color), GetAlpha(color)); glDrawArrays(GL_QUADS, 0, 4); }
/** * Berechnet für einen bestimmten Punkt und ein Dreieck die normale Terrainfarbe * * @author OLiver */ unsigned IngameMinimap::CalcTerrainColor(const MapCoord x, const MapCoord y, const unsigned t) { unsigned color = TERRAIN_COLORS[gwv.GetLandscapeType()][ (t==0) ? gwv.GetNode(x,y).t1 : gwv.GetNode(x,y).t2]; // Schattierung int shadow = gwv.GetNode(x,y).shadow; int r = GetRed(color)+shadow-0x40; int g = GetGreen(color)+shadow-0x40; int b = GetBlue(color)+shadow-0x40; if(r < 0) r = 0; else if(r > 255) r = 255; if(g < 0) g = 0; else if(g > 255) g = 255; if(b < 0) b = 0; else if(b > 255) b = 255; return MakeColor(0xFF,unsigned(r),unsigned(g),unsigned(b)); }
/** * Calculate the normal terrain color for a given point and triangle */ unsigned IngameMinimap::CalcTerrainColor(const MapPoint pt, const unsigned t) { unsigned color = TerrainData::GetColor(gwv.GetWorld().GetLandscapeType(), (t == 0) ? gwv.GetNode(pt).t1 : gwv.GetNode(pt).t2); //-V807 // Schattierung int shadow = gwv.GetNode(pt).shadow; int r = GetRed(color) + shadow - 0x40; int g = GetGreen(color) + shadow - 0x40; int b = GetBlue(color) + shadow - 0x40; if(r < 0) r = 0; else if(r > 255) r = 255; if(g < 0) g = 0; else if(g > 255) g = 255; if(b < 0) b = 0; else if(b > 255) b = 255; return MakeColor(0xFF, unsigned(r), unsigned(g), unsigned(b)); }
/** * Zusätzliche Dinge, die die einzelnen Maps vor dem Zeichenvorgang zu tun haben * in dem Falle: Karte aktualisieren * * @author OLiver */ void IngameMinimap::BeforeDrawing() { // Ab welcher Knotenanzahl (Teil der Gesamtknotenanzahl) die Textur komplett neu erstellt werden soll static const unsigned MAX_NODES_UPDATE_DENOMINATOR = 2; // (2 = 1/2, 3 = 1/3 usw.) // Überhaupt Änderungen nötig? if(nodes_updated_list.size()) { // Komplette Textur neu erzeugen, weil es zu viele Knoten sind? if(nodes_updated_list.size() >= map_width*map_height/MAX_NODES_UPDATE_DENOMINATOR) { // Ja, alles neu erzeugen UpdateAll(); // Alles Aktualisierungen wieder zurücksetzen for(MapCoord y = 0;y<map_height;++y) { for(MapCoord x = 0;x<map_width;++x) nodes_updated[y*map_width+x] = false; } } else { // Entsprechende Pixel updaten for(list<Node>::iterator it = nodes_updated_list.begin();it.valid();++it) { for(unsigned t = 0;t<2;++t) { unsigned color = CalcPixelColor(&gwv,it->x,it->y,t); map.tex_setPixel((it->x*2+t+(it->y&1))%(map_width*2),it->y,GetRed(color),GetGreen(color), GetBlue(color),GetAlpha(color)); } // Jetzt muss er nicht mehr geändert werden nodes_updated[it->y*map_width+it->x] = false; } } this->nodes_updated_list.clear(); } }
/** * Alle Punkte Updaten, bei denen das DrawnObject * gleich dem übergebenen drawn_object ist * * @author OLiver */ void IngameMinimap::UpdateAll(const DrawnObject drawn_object) { // Gesamte Karte neu berechnen for(MapCoord y = 0;y<map_height;++y) { for(MapCoord x = 0;x<map_width;++x) { for(unsigned t = 0;t<2;++t) { if(dos[y*map_width+x] == drawn_object || // das gewünschte Objekt (drawn_object == DO_PLAYER && // bei DO_PLAYER auf evtl. nicht gezeichnete Häuser und Straßen ((dos[y*map_width+x] == DO_BUILDING && !houses) || // achten, da dort auch nur das Player- (dos[y*map_width+x] == DO_ROAD && !roads)))) // Territorium zu sehen ist! { unsigned color = CalcPixelColor(&gwv,x,y,t); map.tex_setPixel((x*2+t+(y&1))%(map_width*2),y,GetRed(color),GetGreen(color), GetBlue(color),GetAlpha(color)); } } } } }