Ticket #1029: VariableNames_Colour_to_Color_15728.diff
File VariableNames_Colour_to_Color_15728.diff, 63.1 KB (added by , 10 years ago) |
---|
-
graphics/GameView.cpp
481 481 482 482 CheckLightEnv(); 483 483 484 m->Game->CachePlayerColo urs();484 m->Game->CachePlayerColors(); 485 485 } 486 486 487 487 void CGameView::Render() -
graphics/LOSTexture.cpp
229 257 230 258 glGenTextures(1, &m_Texture); 231 259 232 // Initialise texture with SoD colo ur, for the areas we don't260 // Initialise texture with SoD color, for the areas we don't 233 261 // overwrite with glTexSubImage2D later 234 262 u8* texData = new u8[m_TextureSize * m_TextureSize * 4]; 235 263 memset(texData, 0x00, m_TextureSize * m_TextureSize * 4); -
graphics/Model.cpp
666 666 it->m_Model->SetPlayerID(id); 667 667 } 668 668 669 void CModel::SetShadingColor(const CColor& colo ur)669 void CModel::SetShadingColor(const CColor& color) 670 670 { 671 CModelAbstract::SetShadingColor(colo ur);671 CModelAbstract::SetShadingColor(color); 672 672 673 673 for (std::vector<Prop>::iterator it = m_Props.begin(); it != m_Props.end(); ++it) 674 it->m_Model->SetShadingColor(colo ur);674 it->m_Model->SetShadingColor(color); 675 675 } -
graphics/Model.h
103 103 // set the model's player ID, recursively through props 104 104 void SetPlayerID(player_id_t id); 105 105 // set the models mod color 106 virtual void SetShadingColor(const CColor& colo ur);106 virtual void SetShadingColor(const CColor& color); 107 107 // get the model's material 108 108 CMaterial& GetMaterial() { return m_Material; } 109 109 -
graphics/ModelAbstract.h
154 154 // get the model's player ID; initial default is INVALID_PLAYER 155 155 virtual player_id_t GetPlayerID() const { return m_PlayerID; } 156 156 157 virtual void SetShadingColor(const CColor& colo ur) { m_ShadingColor = colour; }157 virtual void SetShadingColor(const CColor& color) { m_ShadingColor = color; } 158 158 virtual CColor GetShadingColor() const { return m_ShadingColor; } 159 159 160 160 protected: -
graphics/ObjectEntry.cpp
73 73 str << variation.color; 74 74 int r, g, b; 75 75 if (! (str >> r >> g >> b)) // Any trailing data is ignored 76 LOGERROR(L"Actor '%ls' has invalid RGB colo ur '%hs'", m_Base->m_ShortName.c_str(), variation.color.c_str());76 LOGERROR(L"Actor '%ls' has invalid RGB color '%hs'", m_Base->m_ShortName.c_str(), variation.color.c_str()); 77 77 else 78 78 m_Color = CColor(r/255.0f, g/255.0f, b/255.0f, 1.0f); 79 79 } -
graphics/ObjectEntry.h
55 55 std::vector<CObjectBase::Samp> m_Samplers; 56 56 // model name 57 57 VfsPath m_ModelName; 58 // colo ur (used when doing alpha-channel colouring, but not doing player-colour)58 // color (used when doing alpha-channel coloring, but not doing player-color) 59 59 CColor m_Color; 60 // (probable TODO: make colo ur a per-model thing, rather than per-objectEntry,61 // so we can have lots of colo ur variations without wasting memory on60 // (probable TODO: make color a per-model thing, rather than per-objectEntry, 61 // so we can have lots of color variations without wasting memory on 62 62 // lots of objectEntries) 63 63 64 64 std::wstring m_ProjectileModelName; -
graphics/ParticleEmitter.cpp
151 151 152 152 SColor4ub color = m_Particles[i].color; 153 153 154 // Special case: If the blending depends on the source colo ur, not the source alpha,154 // Special case: If the blending depends on the source color, not the source alpha, 155 155 // then pre-multiply by the alpha. (This is kind of a hack.) 156 156 if (m_Type->m_BlendFuncDst == GL_ONE_MINUS_SRC_COLOR) 157 157 { -
graphics/Terrain.cpp
41 41 // CTerrain constructor 42 42 CTerrain::CTerrain() 43 43 : m_Heightmap(0), m_Patches(0), m_MapSize(0), m_MapSizePatches(0), 44 m_BaseColo ur(255, 255, 255, 255)44 m_BaseColor(255, 255, 255, 255) 45 45 { 46 46 } 47 47 -
graphics/Terrain.h
147 147 */ 148 148 CBoundingBoxAligned GetVertexesBound(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1); 149 149 150 // get the base colo ur for the terrain (typically pure white - other colours150 // get the base color for the terrain (typically pure white - other colors 151 151 // will interact badly with LOS - but used by the Actor Viewer tool) 152 SColor4ub GetBaseColo ur() const { return m_BaseColour; }153 // set the base colo ur for the terrain154 void SetBaseColo ur(SColor4ub colour) { m_BaseColour = colour; }152 SColor4ub GetBaseColor() const { return m_BaseColor; } 153 // set the base color for the terrain 154 void SetBaseColor(SColor4ub color) { m_BaseColor = color; } 155 155 156 156 const CHeightMipmap& GetHeightMipmap() const { return m_HeightMipmap; } 157 157 … … 169 169 CPatch* m_Patches; 170 170 // 16-bit heightmap data 171 171 u16* m_Heightmap; 172 // base colo ur (usually white)173 SColor4ub m_BaseColo ur;172 // base color (usually white) 173 SColor4ub m_BaseColor; 174 174 // heightmap mipmap 175 175 CHeightMipmap m_HeightMipmap; 176 176 }; -
graphics/TerrainTextureEntry.cpp
174 174 (*it)->RemoveTerrain(this); 175 175 } 176 176 177 // BuildBaseColor: calculate the root colo ur of the texture, used for coloring minimap, and store177 // BuildBaseColor: calculate the root color of the texture, used for coloring minimap, and store 178 178 // in m_BaseColor member 179 179 void CTerrainTextureEntry::BuildBaseColor() 180 180 { … … 186 186 return; 187 187 } 188 188 189 // Use the texture colo ur if available189 // Use the texture color if available 190 190 if (GetTexture()->TryLoad()) 191 191 { 192 m_BaseColor = GetTexture()->GetBaseColo ur();192 m_BaseColor = GetTexture()->GetBaseColor(); 193 193 m_BaseColorValid = true; 194 194 } 195 195 } … … 362 362 result.m_hCompositeAlphaMap = hCompositeAlphaMap; 363 363 364 364 m_TerrainAlpha = it; 365 } 366 No newline at end of file 365 } -
graphics/TerritoryTexture.cpp
183 183 CColor color(1, 0, 1, 1); 184 184 CmpPtr<ICmpPlayer> cmpPlayer(m_Simulation, cmpPlayerManager->GetPlayerByID(p)); 185 185 if (cmpPlayer) 186 color = cmpPlayer->GetColo ur();186 color = cmpPlayer->GetColor(); 187 187 colors.push_back(color); 188 188 } 189 189 -
graphics/TextureConverter.h
52 52 * 53 53 * 'normal' is 'true' or 'false'. 54 54 * 55 * 'alpha' is 'transparency' or 'player' (it determines whether the colo ur value of55 * 'alpha' is 'transparency' or 'player' (it determines whether the color value of 56 56 * 0-alpha pixels is significant or not). 57 57 * 58 58 * 'filter' is 'box', 'triangle' or 'kaiser'. -
graphics/TextureManager.cpp
189 189 size_t flags = 0; 190 190 (void)ogl_tex_get_format(h, &flags, NULL); 191 191 192 // Initialise base colo ur from the texture193 (void)ogl_tex_get_average_colo ur(h, &texture->m_BaseColour);192 // Initialise base color from the texture 193 (void)ogl_tex_get_average_color(h, &texture->m_BaseColor); 194 194 195 195 // Set GL upload properties 196 196 (void)ogl_tex_set_wrap(h, texture->m_Properties.m_WrapS, texture->m_Properties.m_WrapT); … … 516 516 }; 517 517 518 518 CTexture::CTexture(Handle handle, const CTextureProperties& props, CTextureManagerImpl* textureManager) : 519 m_Handle(handle), m_BaseColo ur(0), m_State(UNLOADED), m_Properties(props), m_TextureManager(textureManager)519 m_Handle(handle), m_BaseColor(0), m_State(UNLOADED), m_Properties(props), m_TextureManager(textureManager) 520 520 { 521 521 // Add a reference to the handle (it might be shared by multiple CTextures 522 522 // so we can't take ownership of it) … … 613 613 return (flags & TEX_ALPHA) != 0; 614 614 } 615 615 616 u32 CTexture::GetBaseColo ur() const616 u32 CTexture::GetBaseColor() const 617 617 { 618 return m_BaseColo ur;618 return m_BaseColor; 619 619 } 620 620 621 621 size_t CTexture::GetUploadedSize() const -
graphics/TextureManager.h
237 237 * average of the whole texture). 238 238 * Returns 0 if the texture has no mipmaps. 239 239 */ 240 u32 GetBaseColo ur() const;240 u32 GetBaseColor() const; 241 241 242 242 /** 243 243 * Returns total number of bytes uploaded for this texture. … … 287 287 const CTextureProperties m_Properties; 288 288 289 289 Handle m_Handle; 290 u32 m_BaseColo ur;290 u32 m_BaseColor; 291 291 292 292 enum { 293 293 UNLOADED, // loading has not started -
gui/CGUISprite.h
123 123 */ 124 124 GLint m_WrapMode; 125 125 126 // Visual effects (e.g. colo ur modulation)126 // Visual effects (e.g. color modulation) 127 127 SGUIImageEffects* m_Effects; 128 128 129 129 // Color -
gui/GUIRenderer.cpp
79 79 // "stretched:filename.ext" - stretched image 80 80 // "stretched:grayscale:filename.ext" - stretched grayscale image 81 81 // "cropped:(0.5, 0.25)" - stretch this ratio (x,y) of the top left of the image 82 // "colo ur:r g b a" - solid colour82 // "color:r g b a" - solid color 83 83 // 84 84 // and if so, try to create it as a new sprite. 85 85 if (SpriteName.substr(0, 10) == "stretched:") … … 141 141 CStrW value = wstring_from_utf8(SpriteName.substr(7)); 142 142 CColor color; 143 143 144 // Check colo ur is valid144 // Check color is valid 145 145 if (!GUI<CColor>::ParseString(value, color)) 146 146 { 147 LOGERROR(L"GUI: Error parsing sprite 'colo ur' (\"%ls\")", value.c_str());147 LOGERROR(L"GUI: Error parsing sprite 'color' (\"%ls\")", value.c_str()); 148 148 return; 149 149 } 150 150 -
gui/scripting/JSInterface_IGUIObject.cpp
161 161 162 162 case GUIST_CColor: 163 163 { 164 CColor colo ur;165 GUI<CColor>::GetSetting(e, propName, colo ur);164 CColor color; 165 GUI<CColor>::GetSetting(e, propName, color); 166 166 JS::RootedObject obj(cx, pScriptInterface->CreateCustomObject("GUIColor")); 167 167 vp.setObject(*obj); 168 168 JS::RootedValue c(cx); 169 169 // Attempt to minimise ugliness through macrosity 170 #define P(x) c = JS::NumberValue(colo ur.x); \170 #define P(x) c = JS::NumberValue(color.x); \ 171 171 if (c.isNull()) \ 172 172 return false; \ 173 173 JS_SetProperty(cx, obj, #x, c.address()) … … 528 528 } 529 529 else if (vp.isObject() && JS_InstanceOf(cx, &vp.toObject(), &JSI_GUIColor::JSI_class, NULL)) 530 530 { 531 CColor colo ur;531 CColor color; 532 532 JS::RootedObject (cx, &vp.toObject()); 533 533 JS::RootedValue t(cx); 534 534 double s; 535 535 #define PROP(x) JS_GetProperty(cx, obj, #x, t.address()); \ 536 536 s = t.toDouble(); \ 537 colo ur.x = (float)s537 color.x = (float)s 538 538 PROP(r); PROP(g); PROP(b); PROP(a); 539 539 #undef PROP 540 540 541 GUI<CColor>::SetSetting(e, propName, colo ur);541 GUI<CColor>::SetSetting(e, propName, color); 542 542 } 543 543 else 544 544 { -
lib/res/graphics/ogl_tex.cpp
1039 1039 return INFO::OK; 1040 1040 } 1041 1041 1042 // retrieve colo ur of 1x1 mipmap level1043 extern Status ogl_tex_get_average_colo ur(Handle ht, u32* p)1042 // retrieve color of 1x1 mipmap level 1043 extern Status ogl_tex_get_average_color(Handle ht, u32* p) 1044 1044 { 1045 1045 H_DEREF(ht, OglTex, ot); 1046 1046 warn_if_uploaded(ht, ot); 1047 1047 1048 *p = ot->t.get_average_colo ur();1048 *p = ot->t.get_average_color(); 1049 1049 return INFO::OK; 1050 1050 } 1051 1051 -
lib/res/graphics/ogl_tex.h
408 408 409 409 /** 410 410 * Retrieve ARGB value of 1x1 mipmap level of the texture, 411 * i.e. the average colo ur of the whole texture.411 * i.e. the average color of the whole texture. 412 412 * 413 413 * @param ht Texture handle 414 414 * @param p will be filled with ARGB value (or 0 if texture does not have mipmaps) … … 416 416 * 417 417 * Must be called before uploading (raises a warning if called afterwards). 418 418 */ 419 extern Status ogl_tex_get_average_colo ur(Handle ht, u32* p);419 extern Status ogl_tex_get_average_color(Handle ht, u32* p); 420 420 421 421 422 422 // -
lib/sysdep/os/win/wcursor.cpp
56 56 // CreateBitmap; bpp/format must be checked against those of the DC. 57 57 // this is the simplest way and we don't care about slight performance 58 58 // differences because this is typically only called once. 59 HBITMAP hbmColo ur = CreateBitmap(w, h, 1, 32, bgra_img);59 HBITMAP hbmColor = CreateBitmap(w, h, 1, 32, bgra_img); 60 60 61 61 // CreateIconIndirect doesn't access this; we just need to pass 62 62 // an empty bitmap. … … 69 69 ii.xHotspot = (DWORD)hx; 70 70 ii.yHotspot = (DWORD)hy; 71 71 ii.hbmMask = hbmMask; 72 ii.hbmColor = hbmColo ur;72 ii.hbmColor = hbmColor; 73 73 HICON hIcon = CreateIconIndirect(&ii); 74 74 75 75 // CreateIconIndirect makes copies, so we no longer need these. 76 76 DeleteObject(hbmMask); 77 DeleteObject(hbmColo ur);77 DeleteObject(hbmColor); 78 78 79 79 if(!wutil_IsValidHandle(hIcon)) 80 80 WARN_RETURN(ERR::FAIL); -
lib/sysdep/os/win/wsdl.cpp
330 330 static void video_SetPixelFormat(HDC hDC, int bpp) 331 331 { 332 332 const DWORD dwFlags = PFD_SUPPORT_OPENGL|PFD_DRAW_TO_WINDOW|PFD_DOUBLEBUFFER; 333 BYTE cColo urBits = (BYTE)bpp;333 BYTE cColorBits = (BYTE)bpp; 334 334 BYTE cAlphaBits = 0; 335 335 if(bpp == 32) 336 336 { 337 cColo urBits = 24;337 cColorBits = 24; 338 338 cAlphaBits = 8; 339 339 } 340 340 const BYTE cAccumBits = 0; … … 348 348 1, // version 349 349 dwFlags, 350 350 PFD_TYPE_RGBA, 351 cColo urBits, 0, 0, 0, 0, 0, 0, // c*Bits, c*Shift are unused351 cColorBits, 0, 0, 0, 0, 0, 0, // c*Bits, c*Shift are unused 352 352 cAlphaBits, 0, // cAlphaShift is unused 353 353 cAccumBits, 0, 0, 0, 0, // cAccum*Bits are unused 354 354 cDepthBits, -
lib/tex/tex.cpp
637 637 return p + m_Ofs; 638 638 } 639 639 640 // returns colo ur of 1x1 mipmap level641 u32 Tex::get_average_colo ur() const640 // returns color of 1x1 mipmap level 641 u32 Tex::get_average_color() const 642 642 { 643 643 // require mipmaps 644 644 if(!(m_Flags & TEX_MIPMAPS)) -
lib/tex/tex.h
337 337 * 338 338 * @return ARGB value (or 0 if texture does not have mipmaps) 339 339 **/ 340 u32 get_average_colo ur() const;340 u32 get_average_color() const; 341 341 342 342 /** 343 343 * return total byte size of the image pixels. (including mipmaps!) -
lib/tex/tex_bmp.cpp
94 94 } 95 95 96 96 97 // requirements: uncompressed, direct colo ur, bottom up97 // requirements: uncompressed, direct color, bottom up 98 98 Status TexCodecBmp::decode(rpU8 data, size_t UNUSED(size), Tex* RESTRICT t) const 99 99 { 100 100 const BmpHeader* hdr = (const BmpHeader*)data; -
lib/tex/tex_png.cpp
125 125 // read header and determine format 126 126 png_read_info(png_ptr, info_ptr); 127 127 png_uint_32 w, h; 128 int bit_depth, colo ur_type;129 png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &colo ur_type, 0, 0, 0);128 int bit_depth, color_type; 129 png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, 0, 0, 0); 130 130 const size_t pitch = png_get_rowbytes(png_ptr, info_ptr); 131 131 const u32 bpp = (u32)(pitch/w * 8); 132 132 … … 133 133 size_t flags = 0; 134 134 if(bpp == 32) 135 135 flags |= TEX_ALPHA; 136 if(colo ur_type == PNG_COLOR_TYPE_GRAY)136 if(color_type == PNG_COLOR_TYPE_GRAY) 137 137 flags |= TEX_GREY; 138 138 139 139 // make sure format is acceptable 140 140 if(bit_depth != 8) 141 141 WARN_RETURN(ERR::TEX_NOT_8BIT_PRECISION); 142 if(colo ur_type & PNG_COLOR_MASK_PALETTE)142 if(color_type & PNG_COLOR_MASK_PALETTE) 143 143 WARN_RETURN(ERR::TEX_INVALID_COLOR_TYPE); 144 144 145 145 const size_t img_size = pitch * h; … … 165 165 const png_uint_32 w = (png_uint_32)t->m_Width, h = (png_uint_32)t->m_Height; 166 166 const size_t pitch = w * t->m_Bpp / 8; 167 167 168 int colo ur_type;168 int color_type; 169 169 switch(t->m_Flags & (TEX_GREY|TEX_ALPHA)) 170 170 { 171 171 case TEX_GREY|TEX_ALPHA: 172 colo ur_type = PNG_COLOR_TYPE_GRAY_ALPHA;172 color_type = PNG_COLOR_TYPE_GRAY_ALPHA; 173 173 break; 174 174 case TEX_GREY: 175 colo ur_type = PNG_COLOR_TYPE_GRAY;175 color_type = PNG_COLOR_TYPE_GRAY; 176 176 break; 177 177 case TEX_ALPHA: 178 colo ur_type = PNG_COLOR_TYPE_RGB_ALPHA;178 color_type = PNG_COLOR_TYPE_RGB_ALPHA; 179 179 break; 180 180 default: 181 colo ur_type = PNG_COLOR_TYPE_RGB;181 color_type = PNG_COLOR_TYPE_RGB; 182 182 break; 183 183 } 184 184 185 185 png_set_write_fn(png_ptr, da, io_write, io_flush); 186 png_set_IHDR(png_ptr, info_ptr, w, h, 8, colo ur_type,186 png_set_IHDR(png_ptr, info_ptr, w, h, 8, color_type, 187 187 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 188 188 189 189 u8* data = t->get_data(); -
lib/tex/tex_tga.cpp
34 34 35 35 enum TgaImgType 36 36 { 37 TGA_TRUE_COLO UR = 2, // uncompressed 24 or 32 bit direct RGB38 TGA_GREY = 3// uncompressed 8 bit direct greyscale37 TGA_TRUE_COLOR = 2, // uncompressed 24 or 32 bit direct RGB 38 TGA_GREY = 3 // uncompressed 8 bit direct greyscale 39 39 }; 40 40 41 41 enum TgaImgDesc … … 47 47 typedef struct 48 48 { 49 49 u8 img_id_len; // 0 - no image identifier present 50 u8 colo ur_map_type; // 0 - no colour map present50 u8 color_map_type; // 0 - no color map present 51 51 u8 img_type; // see TgaImgType 52 u8 colo ur_map[5]; // unused52 u8 color_map[5]; // unused 53 53 54 54 u16 x_origin; // unused 55 55 u16 y_origin; // unused … … 62 62 } 63 63 TgaHeader; 64 64 65 // TGA file: header [img id] [colo ur map] image data65 // TGA file: header [img id] [color map] image data 66 66 67 67 #pragma pack(pop) 68 68 … … 79 79 80 80 // the first TGA header doesn't have a magic field; 81 81 // we can only check if the first 4 bytes are valid 82 // .. not direct colo ur83 if(hdr->colo ur_map_type != 0)82 // .. not direct color 83 if(hdr->color_map_type != 0) 84 84 return false; 85 // .. wrong colo ur type (not uncompressed greyscale or RGB)86 if(hdr->img_type != TGA_TRUE_COLO UR && hdr->img_type != TGA_GREY)85 // .. wrong color type (not uncompressed greyscale or RGB) 86 if(hdr->img_type != TGA_TRUE_COLOR && hdr->img_type != TGA_GREY) 87 87 return false; 88 88 89 // note: we can't check img_id_len or colo ur_map[0] - they are89 // note: we can't check img_id_len or color_map[0] - they are 90 90 // undefined and may assume any value. 91 91 92 92 return true; … … 127 127 flags |= TEX_ALPHA; 128 128 if(bpp == 8) 129 129 flags |= TEX_GREY; 130 if(type == TGA_TRUE_COLO UR)130 if(type == TGA_TRUE_COLOR) 131 131 flags |= TEX_BGR; 132 132 133 133 // sanity checks … … 151 151 img_desc |= TGA_TOP_DOWN; 152 152 if(t->m_Bpp == 32) 153 153 img_desc |= 8; // size of alpha channel 154 TgaImgType img_type = (t->m_Flags & TEX_GREY)? TGA_GREY : TGA_TRUE_COLO UR;154 TgaImgType img_type = (t->m_Flags & TEX_GREY)? TGA_GREY : TGA_TRUE_COLOR; 155 155 156 156 size_t transforms = t->m_Flags; 157 157 transforms &= ~TEX_ORIENTATION; // no flip needed - we can set top-down bit. … … 160 160 const TgaHeader hdr = 161 161 { 162 162 0, // no image identifier present 163 0, // no colo ur map present163 0, // no color map present 164 164 (u8)img_type, 165 {0,0,0,0,0}, // unused (colo ur map)165 {0,0,0,0,0}, // unused (color map) 166 166 0, 0, // unused (origin) 167 167 (u16)t->m_Width, 168 168 (u16)t->m_Height, -
ps/CConsole.cpp
340 340 // Cursor character is chosen to be an underscore 341 341 textRenderer.Put(0.0f, 0.0f, L"_"); 342 342 343 // Revert to the standard text colo ur343 // Revert to the standard text color 344 344 textRenderer.Color(1.0f, 1.0f, 1.0f); 345 345 } 346 346 } -
ps/Game.cpp
350 350 351 351 static CColor BrokenColor(0.3f, 0.3f, 0.3f, 1.0f); 352 352 353 void CGame::CachePlayerColo urs()353 void CGame::CachePlayerColors() 354 354 { 355 m_PlayerColo urs.clear();355 m_PlayerColors.clear(); 356 356 357 357 CmpPtr<ICmpPlayerManager> cmpPlayerManager(*m_Simulation2, SYSTEM_ENTITY); 358 358 if (!cmpPlayerManager) … … 359 359 return; 360 360 361 361 int numPlayers = cmpPlayerManager->GetNumPlayers(); 362 m_PlayerColo urs.resize(numPlayers);362 m_PlayerColors.resize(numPlayers); 363 363 364 364 for (int i = 0; i < numPlayers; ++i) 365 365 { 366 366 CmpPtr<ICmpPlayer> cmpPlayer(*m_Simulation2, cmpPlayerManager->GetPlayerByID(i)); 367 367 if (!cmpPlayer) 368 m_PlayerColo urs[i] = BrokenColor;368 m_PlayerColors[i] = BrokenColor; 369 369 else 370 m_PlayerColo urs[i] = cmpPlayer->GetColour();370 m_PlayerColors[i] = cmpPlayer->GetColor(); 371 371 } 372 372 } 373 373 374 374 375 CColor CGame::GetPlayerColo ur(int player) const375 CColor CGame::GetPlayerColor(int player) const 376 376 { 377 if (player < 0 || player >= (int)m_PlayerColo urs.size())377 if (player < 0 || player >= (int)m_PlayerColors.size()) 378 378 return BrokenColor; 379 379 380 return m_PlayerColo urs[player];380 return m_PlayerColors[player]; 381 381 } -
ps/Game.h
93 93 void SetPlayerID(int playerID); 94 94 95 95 /** 96 * Retrieving player colo urs from scripts is slow, so this updates an97 * internal cache of all players' colo urs.96 * Retrieving player colors from scripts is slow, so this updates an 97 * internal cache of all players' colors. 98 98 * Call this just before rendering, so it will always have the latest 99 * colo urs.99 * colors. 100 100 */ 101 void CachePlayerColo urs();101 void CachePlayerColors(); 102 102 103 CColor GetPlayerColo ur(int player) const;103 CColor GetPlayerColor(int player) const; 104 104 105 105 /** 106 106 * Get m_GameStarted. … … 166 166 void RegisterInit(const JS::HandleValue attribs, const std::string& savedState); 167 167 IReplayLogger* m_ReplayLogger; 168 168 169 std::vector<CColor> m_PlayerColo urs;169 std::vector<CColor> m_PlayerColors; 170 170 171 171 int LoadInitialState(); 172 172 std::string m_InitialSavedState; // valid between RegisterInit and LoadInitialState -
renderer/OverlayRenderer.cpp
260 260 PROFILE3("prepare overlays"); 261 261 262 262 // This is where we should do something like sort the overlays by 263 // colo ur/sprite/etc for more efficient rendering263 // color/sprite/etc for more efficient rendering 264 264 265 265 for (size_t i = 0; i < m->texlines.size(); ++i) 266 266 { -
renderer/PostprocManager.cpp
37 37 #if !CONFIG2_GLES 38 38 39 39 CPostprocManager::CPostprocManager() 40 : m_IsInitialised(false), m_PingFbo(0), m_PongFbo(0), m_PostProcEffect(L"default"), m_Colo urTex1(0), m_ColourTex2(0),40 : m_IsInitialised(false), m_PingFbo(0), m_PongFbo(0), m_PostProcEffect(L"default"), m_ColorTex1(0), m_ColorTex2(0), 41 41 m_DepthTex(0), m_BloomFbo(0), m_BlurTex2a(0), m_BlurTex2b(0), m_BlurTex4a(0), m_BlurTex4b(0), 42 42 m_BlurTex8a(0), m_BlurTex8b(0), m_WhichBuffer(true) 43 43 { … … 65 65 if (m_BloomFbo) pglDeleteFramebuffersEXT(1, &m_BloomFbo); 66 66 m_PingFbo = m_PongFbo = m_BloomFbo = 0; 67 67 68 if (m_Colo urTex1) glDeleteTextures(1, &m_ColourTex1);69 if (m_Colo urTex2) glDeleteTextures(1, &m_ColourTex2);68 if (m_ColorTex1) glDeleteTextures(1, &m_ColorTex1); 69 if (m_ColorTex2) glDeleteTextures(1, &m_ColorTex2); 70 70 if (m_DepthTex) glDeleteTextures(1, &m_DepthTex); 71 m_Colo urTex1 = m_ColourTex2 = m_DepthTex = 0;71 m_ColorTex1 = m_ColorTex2 = m_DepthTex = 0; 72 72 73 73 if (m_BlurTex2a) glDeleteTextures(1, &m_BlurTex2a); 74 74 if (m_BlurTex2b) glDeleteTextures(1, &m_BlurTex2b); … … 98 98 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 99 99 100 100 // Two fullscreen ping-pong textures. 101 GEN_BUFFER_RGBA(m_Colo urTex1, m_Width, m_Height);102 GEN_BUFFER_RGBA(m_Colo urTex2, m_Width, m_Height);101 GEN_BUFFER_RGBA(m_ColorTex1, m_Width, m_Height); 102 GEN_BUFFER_RGBA(m_ColorTex2, m_Width, m_Height); 103 103 104 104 // Textures for several blur sizes. It would be possible to reuse 105 105 // m_BlurTex2b, thus avoiding the need for m_BlurTex4b and m_BlurTex8b, though given … … 134 134 135 135 pglGenFramebuffersEXT(1, &m_PingFbo); 136 136 pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo); 137 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_Colo urTex1, 0);137 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ColorTex1, 0); 138 138 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); 139 139 140 140 GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); … … 145 145 146 146 pglGenFramebuffersEXT(1, &m_PongFbo); 147 147 pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo); 148 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_Colo urTex2, 0);148 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ColorTex2, 0); 149 149 pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0); 150 150 151 151 status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); … … 320 320 ApplyBlurGauss(tex2, temptex, width, height); 321 321 322 322 // We do the same thing for each scale, incrementally adding more and more blur. 323 SCALE_AND_BLUR(m_WhichBuffer ? m_Colo urTex1 : m_ColourTex2, m_BlurTex2a, m_BlurTex2b);323 SCALE_AND_BLUR(m_WhichBuffer ? m_ColorTex1 : m_ColorTex2, m_BlurTex2a, m_BlurTex2b); 324 324 SCALE_AND_BLUR(m_BlurTex2a, m_BlurTex4a, m_BlurTex4b); 325 325 SCALE_AND_BLUR(m_BlurTex4a, m_BlurTex8a, m_BlurTex8b); 326 326 … … 403 403 // We also bind a bunch of other textures and parameters, but since 404 404 // this only happens once per frame the overhead is negligible. 405 405 if (m_WhichBuffer) 406 shader->BindTexture(str_renderedTex, m_Colo urTex1);406 shader->BindTexture(str_renderedTex, m_ColorTex1); 407 407 else 408 shader->BindTexture(str_renderedTex, m_Colo urTex2);408 shader->BindTexture(str_renderedTex, m_ColorTex2); 409 409 410 410 shader->BindTexture(str_depthTex, m_DepthTex); 411 411 -
renderer/PostprocManager.h
28 28 // Two framebuffers, that we flip between at each shader pass. 29 29 GLuint m_PingFbo, m_PongFbo; 30 30 31 // Unique colo ur textures for the framebuffers.32 GLuint m_Colo urTex1, m_ColourTex2;31 // Unique color textures for the framebuffers. 32 GLuint m_ColorTex1, m_ColorTex2; 33 33 34 34 // The framebuffers share a depth/stencil texture. 35 35 GLuint m_DepthTex; … … 98 98 // Matching setter that calls LoadEffect. 99 99 void SetPostEffect(CStrW name); 100 100 101 // Clears the two colo ur buffers and depth buffer, and redirects all rendering101 // Clears the two color buffers and depth buffer, and redirects all rendering 102 102 // to our textures instead of directly to the system framebuffer. 103 103 void CaptureRenderOutput(); 104 104 -
renderer/RenderModifiers.cpp
117 117 shader->Uniform(m_BindingShadingColor, model->GetShadingColor()); 118 118 119 119 if (m_BindingPlayerColor.Active()) 120 shader->Uniform(m_BindingPlayerColor, g_Game->GetPlayerColo ur(model->GetPlayerID()));120 shader->Uniform(m_BindingPlayerColor, g_Game->GetPlayerColor(model->GetPlayerID())); 121 121 } -
renderer/Renderer.cpp
1318 1318 // has to be done in a separate pass. 1319 1319 // First we render all occluders into depth, then render all units with 1320 1320 // inverted depth test so any behind an occluder will get drawn in a constant 1321 // colo ur.1321 // color. 1322 1322 1323 1323 float silhouetteAlpha = 0.75f; 1324 1324 … … 1369 1369 else 1370 1370 { 1371 1371 // Since we can't sort, we'll use the stencil buffer to ensure we only draw 1372 // a pixel once (using the colo ur of whatever model happens to be drawn first).1372 // a pixel once (using the color of whatever model happens to be drawn first). 1373 1373 glEnable(GL_BLEND); 1374 1374 glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA); 1375 1375 pglBlendColorEXT(0, 0, 0, silhouetteAlpha); -
renderer/SilhouetteRenderer.cpp
55 55 } 56 56 57 57 /* 58 * Silhouettes are the solid-colo ured versions of units that are rendered when58 * Silhouettes are the solid-colored versions of units that are rendered when 59 59 * standing behind a building or terrain, so the player won't lose them. 60 60 * 61 61 * The rendering is done in CRenderer::RenderSilhouettes, by rendering the -
renderer/TerrainOverlay.cpp
180 180 #endif 181 181 } 182 182 183 void TerrainOverlay::RenderTile(const CColor& colo ur, bool draw_hidden)183 void TerrainOverlay::RenderTile(const CColor& color, bool draw_hidden) 184 184 { 185 RenderTile(colo ur, draw_hidden, m_i, m_j);185 RenderTile(color, draw_hidden, m_i, m_j); 186 186 } 187 187 188 void TerrainOverlay::RenderTile(const CColor& colo ur, bool draw_hidden, ssize_t i, ssize_t j)188 void TerrainOverlay::RenderTile(const CColor& color, bool draw_hidden, ssize_t i, ssize_t j) 189 189 { 190 190 // TODO: if this is unpleasantly slow, make it much more efficient 191 191 // (e.g. buffering data and making a single draw call? or at least … … 210 210 211 211 CVector3D pos; 212 212 glBegin(GL_TRIANGLES); 213 glColor4fv(colo ur.FloatArray());213 glColor4fv(color.FloatArray()); 214 214 if (m_Terrain->GetTriangulationDir(i, j)) 215 215 { 216 216 m_Terrain->CalcPosition(i, j, pos); glVertex3fv(pos.GetFloatArray()); … … 236 236 #endif 237 237 } 238 238 239 void TerrainOverlay::RenderTileOutline(const CColor& colo ur, int line_width, bool draw_hidden)239 void TerrainOverlay::RenderTileOutline(const CColor& color, int line_width, bool draw_hidden) 240 240 { 241 RenderTileOutline(colo ur, line_width, draw_hidden, m_i, m_j);241 RenderTileOutline(color, line_width, draw_hidden, m_i, m_j); 242 242 } 243 243 244 void TerrainOverlay::RenderTileOutline(const CColor& colo ur, int line_width, bool draw_hidden, ssize_t i, ssize_t j)244 void TerrainOverlay::RenderTileOutline(const CColor& color, int line_width, bool draw_hidden, ssize_t i, ssize_t j) 245 245 { 246 246 if (draw_hidden) 247 247 { … … 265 265 266 266 CVector3D pos; 267 267 glBegin(GL_QUADS); 268 glColor4fv(colo ur.FloatArray());268 glColor4fv(color.FloatArray()); 269 269 m_Terrain->CalcPosition(i, j, pos); glVertex3fv(pos.GetFloatArray()); 270 270 m_Terrain->CalcPosition(i+1, j, pos); glVertex3fv(pos.GetFloatArray()); 271 271 m_Terrain->CalcPosition(i+1, j+1, pos); glVertex3fv(pos.GetFloatArray()); -
renderer/TerrainOverlay.h
128 128 /** 129 129 * Draw a filled quad on top of the current tile. 130 130 * 131 * @param colo ur colour to draw. May be transparent (alpha < 1)131 * @param color color to draw. May be transparent (alpha < 1) 132 132 * @param draw_hidden true if hidden tiles (i.e. those behind other tiles) 133 133 * should be drawn 134 134 */ 135 void RenderTile(const CColor& colo ur, bool draw_hidden);135 void RenderTile(const CColor& color, bool draw_hidden); 136 136 137 137 /** 138 138 * Draw a filled quad on top of the given tile. 139 139 */ 140 void RenderTile(const CColor& colo ur, bool draw_hidden, ssize_t i, ssize_t j);140 void RenderTile(const CColor& color, bool draw_hidden, ssize_t i, ssize_t j); 141 141 142 142 /** 143 143 * Draw an outlined quad on top of the current tile. 144 144 * 145 * @param colo ur colour to draw. May be transparent (alpha < 1)145 * @param color color to draw. May be transparent (alpha < 1) 146 146 * @param line_width width of lines in pixels. 1 is a sensible value 147 147 * @param draw_hidden true if hidden tiles (i.e. those behind other tiles) 148 148 * should be drawn 149 149 */ 150 void RenderTileOutline(const CColor& colo ur, int line_width, bool draw_hidden);150 void RenderTileOutline(const CColor& color, int line_width, bool draw_hidden); 151 151 152 152 /** 153 153 * Draw an outlined quad on top of the given tile. 154 154 */ 155 void RenderTileOutline(const CColor& colo ur, int line_width, bool draw_hidden, ssize_t i, ssize_t j);155 void RenderTileOutline(const CColor& color, int line_width, bool draw_hidden, ssize_t i, ssize_t j); 156 156 157 157 private: 158 158 // Process all tiles -
renderer/TerrainRenderer.cpp
281 281 const CLightEnv& lightEnv = g_Renderer.GetLightEnv(); 282 282 283 283 pglClientActiveTextureARB(GL_TEXTURE0); 284 glEnableClientState(GL_COLOR_ARRAY); // diffuse lighting colo urs284 glEnableClientState(GL_COLOR_ARRAY); // diffuse lighting colors 285 285 286 286 // The vertex color is scaled by 0.5 to permit overbrightness without clamping. 287 287 // We therefore need to draw clamp((texture*lighting)*2.0), where 'texture' -
tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp
30 30 : DraggableListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 31 31 wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL) 32 32 { 33 // Set colo urs for row backgrounds (which vary depending on what columns33 // Set colors for row backgrounds (which vary depending on what columns 34 34 // have some data) 35 #define COLO UR(name, c0, c1) \36 m_ListItemAttr_##name[0].SetBackgroundColo ur(wxColour c0); \37 m_ListItemAttr_##name[1].SetBackgroundColo ur(wxColour c1)35 #define COLOR(name, c0, c1) \ 36 m_ListItemAttr_##name[0].SetBackgroundColor(wxColor c0); \ 37 m_ListItemAttr_##name[1].SetBackgroundColor(wxColor c1) 38 38 39 39 const int f=0xFF, e=0xEE, c=0xCC; 40 COLO UR(Model, (f,f,e), (f,f,c));41 COLO UR(Texture, (f,e,e), (f,c,c));42 COLO UR(Anim, (e,f,e), (c,f,c));43 COLO UR(Prop, (e,e,f), (c,c,f));44 COLO UR(Colour, (f,e,f), (f,c,f));45 COLO UR(None, (f,f,f), (f,f,f));40 COLOR(Model, (f,f,e), (f,f,c)); 41 COLOR(Texture, (f,e,e), (f,c,c)); 42 COLOR(Anim, (e,f,e), (c,f,c)); 43 COLOR(Prop, (e,e,f), (c,c,f)); 44 COLOR(Colour, (f,e,f), (f,c,f)); 45 COLOR(None, (f,f,f), (f,f,f)); 46 46 47 #undef COLO UR47 #undef COLOR 48 48 49 49 AddColumnType(_("Variant"), 90, "@name", new FieldEditCtrl_Text()); 50 50 AddColumnType(_("Ratio"), 50, "@frequency", new FieldEditCtrl_Text()); … … 52 52 AddColumnType(_("Textures"), 250, "textures", new FieldEditCtrl_Dialog(&TexListEditor::Create)); 53 53 AddColumnType(_("Animations"), 250, "animations", new FieldEditCtrl_Dialog(&AnimListEditor::Create)); 54 54 AddColumnType(_("Props"), 220, "props", new FieldEditCtrl_Dialog(&PropListEditor::Create)); 55 AddColumnType(_("Colour"), 80, "colour", new FieldEditCtrl_Colo ur());55 AddColumnType(_("Colour"), 80, "colour", new FieldEditCtrl_Color()); 56 56 } 57 57 58 58 void ActorEditorListCtrl::DoImport(AtObj& in) … … 104 104 { 105 105 AtObj row (m_ListData[item]); 106 106 107 // Colo ur-code the row, depending on the first non-empty column,107 // Color-code the row, depending on the first non-empty column, 108 108 // and also alternate between light/dark. 109 109 110 110 if (row["mesh"].hasContent()) … … 116 116 else if (row["props"].hasContent()) 117 117 return const_cast<wxListItemAttr*>(&m_ListItemAttr_Prop[item%2]); 118 118 else if (row["colour"].hasContent()) 119 return const_cast<wxListItemAttr*>(&m_ListItemAttr_Colo ur[item%2]);119 return const_cast<wxListItemAttr*>(&m_ListItemAttr_Color[item%2]); 120 120 } 121 121 122 122 return const_cast<wxListItemAttr*>(&m_ListItemAttr_None[item%2]); -
tools/atlas/AtlasUI/CustomControls/ColorDialog/ColorDialog.cpp
20 20 #include "wx/regex.h" 21 21 #include "wx/config.h" 22 22 23 #include "Colo urDialog.h"23 #include "ColorDialog.h" 24 24 25 Colo urDialog::ColourDialog(wxWindow* parent, const wxString& customColourConfigPath, const wxColour& defaultColour)26 : wxColourDialog(parent), m_ConfigPath(customColo urConfigPath)25 ColorDialog::ColorDialog(wxWindow* parent, const wxString& customColorConfigPath, const wxColour& defaultColor) 26 : wxColourDialog(parent), m_ConfigPath(customColorConfigPath) 27 27 { 28 GetColourData().SetColour(defaultColo ur);28 GetColourData().SetColour(defaultColor); 29 29 30 // Load custom colo urs from the config database30 // Load custom colors from the config database 31 31 32 32 wxRegEx re (_T("([0-9]+) ([0-9]+) ([0-9]+)"), wxRE_EXTENDED); 33 33 … … 36 36 { 37 37 for (int i = 0; i < 16; ++i) 38 38 { 39 wxString customColo ur;40 if (cfg->Read(wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i), &customColo ur)41 && re.Matches(customColo ur))39 wxString customColor; 40 if (cfg->Read(wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i), &customColor) 41 && re.Matches(customColor)) 42 42 { 43 43 long r, g, b; 44 re.GetMatch(customColo ur, 1).ToLong(&r);45 re.GetMatch(customColo ur, 2).ToLong(&g);46 re.GetMatch(customColo ur, 3).ToLong(&b);44 re.GetMatch(customColor, 1).ToLong(&r); 45 re.GetMatch(customColor, 2).ToLong(&g); 46 re.GetMatch(customColor, 3).ToLong(&b); 47 47 GetColourData().SetCustomColour(i, wxColour(r, g, b)); 48 48 } 49 49 } … … 50 50 } 51 51 } 52 52 53 int Colo urDialog::ShowModal()53 int ColorDialog::ShowModal() 54 54 { 55 55 int ret = wxColourDialog::ShowModal(); 56 56 if (ret == wxID_OK) 57 57 { 58 // Save all the custom colo urs back into the config database58 // Save all the custom colors back into the config database 59 59 60 60 wxConfigBase* cfg = wxConfigBase::Get(false); 61 61 if (cfg) … … 63 63 for (int i = 0; i < 16; ++i) 64 64 { 65 65 wxString name = wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i); 66 wxColour colo ur = GetColourData().GetCustomColour(i);66 wxColour color = GetColourData().GetCustomColour(i); 67 67 68 wxString customColo ur = wxString::Format(_T("%d %d %d"), colour.Red(), colour.Green(), colour.Blue());69 cfg->Write(name, customColo ur);68 wxString customColor = wxString::Format(_T("%d %d %d"), color.Red(), color.Green(), color.Blue()); 69 cfg->Write(name, customColor); 70 70 } 71 71 } 72 72 } -
tools/atlas/AtlasUI/CustomControls/ColorDialog/ColorDialog.h
15 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 17 18 #ifndef INCLUDED_COLO URDIALOG19 #define INCLUDED_COLO URDIALOG18 #ifndef INCLUDED_COLORDIALOG 19 #define INCLUDED_COLORDIALOG 20 20 21 21 #include <wx/colordlg.h> 22 22 23 class Colo urDialog : public wxColourDialog23 class ColorDialog : public wxColourDialog 24 24 { 25 25 public: 26 // Typical customColourConfigPath would be "Scenario Editor/LightingColour"27 Colo urDialog(wxWindow* parent, const wxString& customColourConfigPath, const wxColour& defaultColour);26 // A typical customColorConfigPath would be "Scenario Editor/LightingColor" 27 ColorDialog(wxWindow* parent, const wxString& customColorConfigPath, const wxColour& defaultColor); 28 28 29 29 int ShowModal(); 30 30 … … 32 32 wxString m_ConfigPath; 33 33 }; 34 34 35 #endif // INCLUDED_COLO URDIALOG35 #endif // INCLUDED_COLORDIALOG -
tools/atlas/AtlasUI/CustomControls/ColourDialog/ColourDialog.cpp
1 /* Copyright (C) 2009 Wildfire Games.2 * This file is part of 0 A.D.3 *4 * 0 A.D. is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 2 of the License, or7 * (at your option) any later version.8 *9 * 0 A.D. is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.16 */17 18 #include "precompiled.h"19 20 #include "wx/regex.h"21 #include "wx/config.h"22 23 #include "ColourDialog.h"24 25 ColourDialog::ColourDialog(wxWindow* parent, const wxString& customColourConfigPath, const wxColour& defaultColour)26 : wxColourDialog(parent), m_ConfigPath(customColourConfigPath)27 {28 GetColourData().SetColour(defaultColour);29 30 // Load custom colours from the config database31 32 wxRegEx re (_T("([0-9]+) ([0-9]+) ([0-9]+)"), wxRE_EXTENDED);33 34 wxConfigBase* cfg = wxConfigBase::Get(false);35 if (cfg)36 {37 for (int i = 0; i < 16; ++i)38 {39 wxString customColour;40 if (cfg->Read(wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i), &customColour)41 && re.Matches(customColour))42 {43 long r, g, b;44 re.GetMatch(customColour, 1).ToLong(&r);45 re.GetMatch(customColour, 2).ToLong(&g);46 re.GetMatch(customColour, 3).ToLong(&b);47 GetColourData().SetCustomColour(i, wxColour(r, g, b));48 }49 }50 }51 }52 53 int ColourDialog::ShowModal()54 {55 int ret = wxColourDialog::ShowModal();56 if (ret == wxID_OK)57 {58 // Save all the custom colours back into the config database59 60 wxConfigBase* cfg = wxConfigBase::Get(false);61 if (cfg)62 {63 for (int i = 0; i < 16; ++i)64 {65 wxString name = wxString::Format(_T("%s%d"), m_ConfigPath.c_str(), i);66 wxColour colour = GetColourData().GetCustomColour(i);67 68 wxString customColour = wxString::Format(_T("%d %d %d"), colour.Red(), colour.Green(), colour.Blue());69 cfg->Write(name, customColour);70 }71 }72 }73 74 return ret;75 } -
tools/atlas/AtlasUI/CustomControls/ColourDialog/ColourDialog.h
1 /* Copyright (C) 2009 Wildfire Games.2 * This file is part of 0 A.D.3 *4 * 0 A.D. is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 2 of the License, or7 * (at your option) any later version.8 *9 * 0 A.D. is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.16 */17 18 #ifndef INCLUDED_COLOURDIALOG19 #define INCLUDED_COLOURDIALOG20 21 #include <wx/colordlg.h>22 23 class ColourDialog : public wxColourDialog24 {25 public:26 // Typical customColourConfigPath would be "Scenario Editor/LightingColour"27 ColourDialog(wxWindow* parent, const wxString& customColourConfigPath, const wxColour& defaultColour);28 29 int ShowModal();30 31 private:32 wxString m_ConfigPath;33 };34 35 #endif // INCLUDED_COLOURDIALOG -
tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.cpp
37 37 const wxString& name) 38 38 : wxListCtrl(parent, id, pos, size, style | wxLC_VIRTUAL, validator, name) 39 39 { 40 m_ListItemAttr[0].SetBackgroundColo ur(wxColour(0xff, 0xff, 0xff));41 m_ListItemAttr[1].SetBackgroundColo ur(wxColour(0xee, 0xee, 0xee));40 m_ListItemAttr[0].SetBackgroundColor(wxColor(0xff, 0xff, 0xff)); 41 m_ListItemAttr[1].SetBackgroundColor(wxColor(0xee, 0xee, 0xee)); 42 42 43 43 wxASSERT_MSG(style & wxLC_REPORT, _T("EditableListCtrl must be LC_REPORT")); 44 44 UpdateDisplay(); … … 277 277 if (item >= (long)m_ListData.size()) 278 278 return const_cast<wxListItemAttr*>(&m_ListItemAttr[0]); 279 279 280 // Make the background colo urs of rows alternate280 // Make the background colors of rows alternate 281 281 else 282 282 return const_cast<wxListItemAttr*>(&m_ListItemAttr[item%2]); 283 283 } -
tools/atlas/AtlasUI/CustomControls/EditableListCtrl/EditableListCtrl.h
108 108 109 109 bool IsRowBlank(int n); 110 110 111 wxListItemAttr m_ListItemAttr[2]; // standard+alternate colo urs111 wxListItemAttr m_ListItemAttr[2]; // standard+alternate colors 112 112 113 113 DECLARE_EVENT_TABLE(); 114 114 }; -
tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp
157 157 void OnClick(wxCommandEvent& WXUNUSED(evt)) 158 158 { 159 159 ColourDialog dlg (this, _T("Scenario Editor/LightingColour"), 160 wxColo ur(m_Colour->r, m_Colour->g, m_Colour->b));160 wxColor(m_Color->r, m_Color->g, m_Color->b)); 161 161 162 162 if (dlg.ShowModal() == wxID_OK) 163 163 { 164 wxColo ur& c = dlg.GetColourData().GetColour();165 m_Colo ur = AtlasMessage::Colour(c.Red(), c.Green(), c.Blue());164 wxColor& c = dlg.GetColourData().GetColour(); 165 m_Color = AtlasMessage::Color(c.Red(), c.Green(), c.Blue()); 166 166 UpdateButton(); 167 167 168 168 g_EnvironmentSettings.NotifyObserversExcept(m_Conn); … … 171 171 172 172 void UpdateButton() 173 173 { 174 m_Button->SetBackgroundColo ur(wxColour(m_Colour->r, m_Colour->g, m_Colour->b));174 m_Button->SetBackgroundColor(wxColor(m_Color->r, m_Color->g, m_Color->b)); 175 175 m_Button->SetLabel(wxString::Format(_T("%02X %02X %02X"), m_Colour->r, m_Colour->g, m_Colour->b)); 176 176 177 177 int y = 3*m_Colour->r + 6*m_Colour->g + 1*m_Colour->b; -
tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.cpp
33 33 ID_PlayerMetal, 34 34 ID_PlayerStone, 35 35 ID_PlayerPop, 36 ID_PlayerColo ur,36 ID_PlayerColor, 37 37 38 38 ID_DefaultName, 39 39 ID_DefaultCiv, 40 ID_DefaultColo ur,40 ID_DefaultColor, 41 41 ID_DefaultAI, 42 42 ID_DefaultFood, 43 43 ID_DefaultWood, … … 130 130 gridSizer->Add(civChoice, wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT)); 131 131 m_Controls.civ = civChoice; 132 132 133 wxButton* colo urButton = new wxButton(this, ID_PlayerColour);134 gridSizer->Add(new DefaultCheckbox(this, ID_DefaultColo ur, colourButton), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));133 wxButton* colorButton = new wxButton(this, ID_PlayerColor); 134 gridSizer->Add(new DefaultCheckbox(this, ID_DefaultColor, colorButton), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL)); 135 135 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Colour")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 136 gridSizer->Add(Tooltipped(colo urButton,136 gridSizer->Add(Tooltipped(colorButton, 137 137 _("Set player colour")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT)); 138 m_Controls.colo ur = colourButton;138 m_Controls.color = colorButton; 139 139 140 140 wxChoice* aiChoice = new wxChoice(this, wxID_ANY); 141 141 gridSizer->Add(new DefaultCheckbox(this, ID_DefaultAI, aiChoice), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL)); -
tools/atlas/AtlasUI/ScenarioEditor/Sections/Player/Player.h
54 54 55 55 wxTextCtrl* name; 56 56 wxChoice* civ; 57 wxButton* colo ur;57 wxButton* color; 58 58 wxSpinCtrl* food; 59 59 wxSpinCtrl* wood; 60 60 wxSpinCtrl* stone; -
tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp
326 326 { 327 327 m_ScrolledPanel = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL); 328 328 m_ScrolledPanel->SetScrollRate(0, 10); 329 m_ScrolledPanel->SetBackgroundColo ur(wxColour(255, 255, 255));329 m_ScrolledPanel->SetBackgroundColor(wxColor(255, 255, 255)); 330 330 331 331 wxSizer* sizer = new wxBoxSizer(wxVERTICAL); 332 332 sizer->Add(m_ScrolledPanel, wxSizerFlags().Proportion(1).Expand()); … … 418 418 g_SelectedTexture.NotifyObservers(); 419 419 420 420 if (m_LastTerrainSelection) 421 m_LastTerrainSelection->SetBackgroundColo ur(wxNullColour);421 m_LastTerrainSelection->SetBackgroundColor(wxNullColor); 422 422 423 button->SetBackgroundColo ur(wxColour(255, 255, 0));423 button->SetBackgroundColor(wxColor(255, 255, 0)); 424 424 m_LastTerrainSelection = button; 425 425 426 426 // Slight hack: Default to Paint mode because that's probably what the user wanted … … 449 449 wxString m_Name; 450 450 wxScrolledWindow* m_ScrolledPanel; 451 451 wxGridSizer* m_ItemSizer; 452 wxButton* m_LastTerrainSelection; // button that was last selected, so we can undo its colo uring452 wxButton* m_LastTerrainSelection; // button that was last selected, so we can undo its coloring 453 453 454 454 DECLARE_EVENT_TABLE(); 455 455 }; -
tools/atlas/GameInterface/ActorViewer.cpp
440 440 m.CurrentUnitAnim = animation; 441 441 } 442 442 443 void ActorViewer::SetBackgroundColo ur(const SColor4ub& colour)443 void ActorViewer::SetBackgroundColor(const SColor4ub& color) 444 444 { 445 m.Background = colo ur;446 m.Terrain.SetBaseColo ur(colour);445 m.Background = color; 446 m.Terrain.SetBaseColor(color); 447 447 } 448 448 449 449 void ActorViewer::SetWalkEnabled(bool enabled) { m.WalkEnabled = enabled; } -
tools/atlas/GameInterface/ActorViewer.h
37 37 entity_id_t GetEntity(); 38 38 void SetActor(const CStrW& id, const CStrW& animation, player_id_t playerID); 39 39 void UnloadObjects(); 40 void SetBackgroundColo ur(const SColor4ub& colour);40 void SetBackgroundColor(const SColor4ub& color); 41 41 void SetWalkEnabled(bool enabled); 42 42 void SetGroundEnabled(bool enabled); 43 43 void SetWaterEnabled(bool enabled); -
tools/atlas/GameInterface/Brushes.cpp
56 56 { 57 57 ssize_t i0, j0; 58 58 m_Brush->GetBottomLeft(i0, j0); 59 // Colo ur this tile based on the average of the surrounding vertices59 // Color this tile based on the average of the surrounding vertices 60 60 float avg = ( 61 61 m_Brush->Get(i-i0, j-j0) + m_Brush->Get(i-i0+1, j-j0) + 62 62 m_Brush->Get(i-i0, j-j0+1) + m_Brush->Get(i-i0+1, j-j0+1) -
tools/atlas/GameInterface/Handlers/EnvironmentHandlers.cpp
49 49 s.watermurkiness = wm->m_Murkiness; 50 50 s.windangle = wm->m_WindAngle; 51 51 52 // CColor colo urs53 #define COLO UR(A, B) A = Colour((int)(B.r*255), (int)(B.g*255), (int)(B.b*255))54 COLO UR(s.watercolour, wm->m_WaterColor);55 COLO UR(s.watertint, wm->m_WaterTint);56 #undef COLO UR52 // CColor colors 53 #define COLOR(A, B) A = Color((int)(B.r*255), (int)(B.g*255), (int)(B.b*255)) 54 COLOR(s.watercolor, wm->m_WaterColor); 55 COLOR(s.watertint, wm->m_WaterTint); 56 #undef COLOR 57 57 58 58 float sunrotation = g_LightEnv.GetRotation(); 59 59 if (sunrotation > (float)M_PI) … … 73 73 s.saturation = g_LightEnv.m_Saturation; 74 74 s.bloom = g_LightEnv.m_Bloom; 75 75 76 // RGBColor (CVector3D) colo urs77 #define COLO UR(A, B) A = Colour((int)(B.X*255), (int)(B.Y*255), (int)(B.Z*255))76 // RGBColor (CVector3D) colors 77 #define COLOR(A, B) A = Color((int)(B.X*255), (int)(B.Y*255), (int)(B.Z*255)) 78 78 s.sunoverbrightness = MaxComponent(g_LightEnv.m_SunColor); 79 79 // clamp color to [0..1] before packing into u8 triplet 80 80 if(s.sunoverbrightness > 1.0f) … … 82 82 // no component was above 1.0, so reset scale factor (don't want to darken) 83 83 else 84 84 s.sunoverbrightness = 1.0f; 85 COLO UR(s.suncolour, g_LightEnv.m_SunColor);86 COLO UR(s.terraincolour, g_LightEnv.m_TerrainAmbientColor);87 COLO UR(s.unitcolour, g_LightEnv.m_UnitsAmbientColor);88 COLO UR(s.fogcolour, g_LightEnv.m_FogColor);89 #undef COLO UR85 COLOR(s.suncolor, g_LightEnv.m_SunColor); 86 COLOR(s.terraincolor, g_LightEnv.m_TerrainAmbientColor); 87 COLOR(s.unitcolor, g_LightEnv.m_UnitsAmbientColor); 88 COLOR(s.fogcolor, g_LightEnv.m_FogColor); 89 #undef COLOR 90 90 91 91 return s; 92 92 } … … 104 104 wm->m_WindAngle = s.windangle; 105 105 wm->m_WaterType = s.watertype._Unwrap(); 106 106 107 #define COLO UR(A, B) B = CColor(A->r/255.f, A->g/255.f, A->b/255.f, 1.f)108 COLO UR(s.watercolour, wm->m_WaterColor);109 COLO UR(s.watertint, wm->m_WaterTint);110 #undef COLO UR107 #define COLOR(A, B) B = CColor(A->r/255.f, A->g/255.f, A->b/255.f, 1.f) 108 COLOR(s.watercolor, wm->m_WaterColor); 109 COLOR(s.watertint, wm->m_WaterTint); 110 #undef COLOR 111 111 112 112 g_LightEnv.SetRotation(s.sunrotation); 113 113 g_LightEnv.SetElevation(s.sunelevation); … … 130 130 g_LightEnv.m_Saturation = s.saturation; 131 131 g_LightEnv.m_Bloom = s.bloom; 132 132 133 #define COLO UR(A, B) B = RGBColor(A->r/255.f, A->g/255.f, A->b/255.f)134 COLO UR(s.suncolour, g_LightEnv.m_SunColor);133 #define COLOR(A, B) B = RGBColor(A->r/255.f, A->g/255.f, A->b/255.f) 134 COLOR(s.suncolor, g_LightEnv.m_SunColor); 135 135 g_LightEnv.m_SunColor *= s.sunoverbrightness; 136 COLO UR(s.terraincolour, g_LightEnv.m_TerrainAmbientColor);137 COLO UR(s.unitcolour, g_LightEnv.m_UnitsAmbientColor);138 COLO UR(s.fogcolour, g_LightEnv.m_FogColor);139 #undef COLO UR136 COLOR(s.terraincolor, g_LightEnv.m_TerrainAmbientColor); 137 COLOR(s.unitcolor, g_LightEnv.m_UnitsAmbientColor); 138 COLOR(s.fogcolor, g_LightEnv.m_FogColor); 139 #undef COLOR 140 140 } 141 141 142 142 BEGIN_COMMAND(SetEnvironmentSettings) -
tools/atlas/GameInterface/Handlers/MapHandlers.cpp
231 231 { 232 232 int offset = y * mapLineSkip + x * bytesPP; 233 233 234 // pick colo ur channel with highest value234 // pick color channel with highest value 235 235 u16 value = std::max(mapdata[offset+bytesPP*2], std::max(mapdata[offset], mapdata[offset+bytesPP])); 236 236 237 237 heightmap[(terrainSize-y-1) * hmSize + x] = clamp(value * 256, 0, 65535); -
tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
101 101 // Helper function to find color of player owning the given entity, 102 102 // returns white if entity has no owner. Uses caching to avoid 103 103 // expensive script calls. 104 static CColor GetOwnerPlayerColor(PlayerColorMap& colo urMap, entity_id_t id)104 static CColor GetOwnerPlayerColor(PlayerColorMap& colorMap, entity_id_t id) 105 105 { 106 106 // Default color - white 107 107 CColor color(1.0f, 1.0f, 1.0f, 1.0f); … … 111 111 if (cmpOwnership) 112 112 { 113 113 player_id_t owner = cmpOwnership->GetOwner(); 114 if (colo urMap.find(owner) != colourMap.end())115 return colo urMap[owner];114 if (colorMap.find(owner) != colorMap.end()) 115 return colorMap[owner]; 116 116 else 117 117 { 118 118 CmpPtr<ICmpPlayerManager> cmpPlayerManager(sim, SYSTEM_ENTITY); … … 119 119 entity_id_t playerEnt = cmpPlayerManager->GetPlayerByID(owner); 120 120 CmpPtr<ICmpPlayer> cmpPlayer(sim, playerEnt); 121 121 if (cmpPlayer) 122 color = colo urMap[owner] = cmpPlayer->GetColour();122 color = colorMap[owner] = cmpPlayer->GetColor(); 123 123 } 124 124 } 125 125 return color; … … 129 129 { 130 130 CSimulation2& sim = *g_Game->GetSimulation2(); 131 131 132 // Cache player colo urs for performance132 // Cache player colors for performance 133 133 PlayerColorMap playerColors; 134 134 135 135 // Clear old selection rings -
tools/atlas/GameInterface/Messages.h
60 60 MESSAGE(SetViewParamC, 61 61 ((int, view)) // eRenderView 62 62 ((std::wstring, name)) 63 ((Colo ur, value))63 ((Color, value)) 64 64 ); 65 65 MESSAGE(SetViewParamS, 66 66 ((int, view)) // eRenderView … … 442 442 Shareable<float> watermurkiness; // range ??? 443 443 Shareable<float> windangle; 444 444 445 Shareable<Colo ur> watercolour;446 Shareable<Colo ur> watertint;445 Shareable<Color> watercolor; 446 Shareable<Color> watertint; 447 447 448 448 Shareable<float> sunrotation; // range -pi..+pi 449 449 Shareable<float> sunelevation; // range -pi/2 .. +pi/2 450 450 451 // emulate 'HDR' by allowing overly bright suncolo ur. this is452 // multiplied on to suncolo ur after converting to float453 // (struct Colo ur stores as normal u8, 0..255)451 // emulate 'HDR' by allowing overly bright suncolor. this is 452 // multiplied on to suncolor after converting to float 453 // (struct Color stores as normal u8, 0..255) 454 454 Shareable<float> sunoverbrightness; // range 1..3 455 455 456 456 // support different lighting models ("old" for the version compatible with old scenarios, … … 459 459 460 460 Shareable<std::wstring> skyset; 461 461 462 Shareable<Colo ur> suncolour;463 Shareable<Colo ur> terraincolour;464 Shareable<Colo ur> unitcolour;465 Shareable<Colo ur> fogcolour;462 Shareable<Color> suncolor; 463 Shareable<Color> terraincolor; 464 Shareable<Color> unitcolor; 465 Shareable<Color> fogcolor; 466 466 467 467 Shareable<float> fogfactor; 468 468 Shareable<float> fogmax; -
tools/atlas/GameInterface/SharedTypes.h
66 66 SHAREABLE_STRUCT(Position); 67 67 68 68 69 struct Colo ur69 struct Color 70 70 { 71 Colo ur()71 Color() 72 72 : r(255), g(0), b(255) 73 73 { 74 74 } 75 75 76 Colo ur(unsigned char r, unsigned char g, unsigned char b)76 Color(unsigned char r, unsigned char g, unsigned char b) 77 77 : r(r), g(g), b(b) 78 78 { 79 79 } … … 80 80 81 81 unsigned char r, g, b; 82 82 }; 83 SHAREABLE_STRUCT(Colo ur);83 SHAREABLE_STRUCT(Color); 84 84 85 85 86 86 typedef unsigned int ObjectID; -
tools/atlas/GameInterface/View.cpp
51 51 { 52 52 } 53 53 54 void AtlasView::SetParam(const std::wstring& UNUSED(name), const AtlasMessage::Colo ur& UNUSED(value))54 void AtlasView::SetParam(const std::wstring& UNUSED(name), const AtlasMessage::Color& UNUSED(value)) 55 55 { 56 56 } 57 57 … … 151 151 m_ActorViewer->SetPropPointsMode(value); 152 152 } 153 153 154 void AtlasViewActor::SetParam(const std::wstring& name, const AtlasMessage::Colo ur& value)154 void AtlasViewActor::SetParam(const std::wstring& name, const AtlasMessage::Color& value) 155 155 { 156 156 if (name == L"background") 157 157 { 158 m_ActorViewer->SetBackgroundColo ur(SColor4ub(value.r, value.g, value.b, 255));158 m_ActorViewer->SetBackgroundColor(SColor4ub(value.r, value.g, value.b, 255)); 159 159 } 160 160 } 161 161 -
tools/atlas/GameInterface/View.h
48 48 49 49 virtual void SetParam(const std::wstring& name, bool value); 50 50 virtual void SetParam(const std::wstring& name, int value); 51 virtual void SetParam(const std::wstring& name, const AtlasMessage::Colo ur& value);51 virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value); 52 52 virtual void SetParam(const std::wstring& name, const std::wstring& value); 53 53 54 54 // These always return a valid (not NULL) object … … 139 139 140 140 virtual void SetParam(const std::wstring& name, bool value); 141 141 virtual void SetParam(const std::wstring& name, int value); 142 virtual void SetParam(const std::wstring& name, const AtlasMessage::Colo ur& value);142 virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value); 143 143 144 144 void SetSpeedMultiplier(float speedMultiplier); 145 145 ActorViewer& GetActorViewer();