Gets integer representation of color from ColorAdd corresponding to given index, or 0 if there's no color found. Code is pulled straight from game's draw functions that deal with the tint colors.
| 267 | // Gets integer representation of color from ColorAdd corresponding to given index, or 0 if there's no color found. |
| 268 | // Code is pulled straight from game's draw functions that deal with the tint colors. |
| 269 | int GeneralUtils::GetColorFromColorAdd(int colorIndex) |
| 270 | { |
| 271 | auto const& colorAdd = RulesClass::Instance->ColorAdd; |
| 272 | int colorValue = 0; |
| 273 | |
| 274 | if (colorIndex < 0 || colorIndex >= (sizeof(colorAdd) / sizeof(ColorStruct))) |
| 275 | return colorValue; |
| 276 | |
| 277 | auto const& color = colorAdd[colorIndex]; |
| 278 | |
| 279 | if (RulesExt::Global()->ColorAddUse8BitRGB) |
| 280 | return Drawing::RGB_To_Int(color); |
| 281 | |
| 282 | int red = color.R; |
| 283 | int green = color.G; |
| 284 | int blue = color.B; |
| 285 | |
| 286 | if (Drawing::ColorMode == RGBMode::RGB565) |
| 287 | colorValue |= blue | (32 * (green | (red << 6))); |
| 288 | |
| 289 | if (Drawing::ColorMode != RGBMode::RGB655) |
| 290 | colorValue |= blue | (((32 * red) | (green >> 1)) << 6); |
| 291 | |
| 292 | colorValue |= blue | (32 * ((32 * red) | (green >> 1))); |
| 293 | |
| 294 | return colorValue; |
| 295 | } |
| 296 | |
| 297 | int GeneralUtils::SafeMultiply(int value, int mult) |
| 298 | { |
nothing calls this directly
no outgoing calls
no test coverage detected