| 1000 | } |
| 1001 | |
| 1002 | void CityTileView::update() |
| 1003 | { |
| 1004 | TileView::update(); |
| 1005 | counter = (counter + 1) % COUNTER_MAX; |
| 1006 | |
| 1007 | // Pulsate palette colors |
| 1008 | colorCurrent += colorForward; |
| 1009 | if (colorCurrent <= 0 || colorCurrent >= 15) |
| 1010 | { |
| 1011 | colorCurrent = clamp(colorCurrent, 0, 15); |
| 1012 | colorForward = -colorForward; |
| 1013 | } |
| 1014 | |
| 1015 | // The palette fades from pal_03 at 3am to pal_02 at 6am then pal_01 at 9am |
| 1016 | // The reverse for 3pm, 6pm & 9pm |
| 1017 | |
| 1018 | auto hour = state.gameTime.getHours(); |
| 1019 | // Always noon in alien dimension |
| 1020 | if (state.current_city.id == "CITYMAP_ALIEN") |
| 1021 | { |
| 1022 | hour = 12; |
| 1023 | } |
| 1024 | |
| 1025 | if (hour < 3 || hour >= 21) |
| 1026 | { |
| 1027 | this->pal = this->mod_night_palette[colorCurrent]; |
| 1028 | } |
| 1029 | else if (hour >= 9 && hour < 15) |
| 1030 | { |
| 1031 | this->pal = this->mod_day_palette[colorCurrent]; |
| 1032 | } |
| 1033 | else |
| 1034 | { |
| 1035 | this->pal = this->mod_interpolated_palette[colorCurrent]; |
| 1036 | |
| 1037 | int minute = hour * 60 + state.gameTime.getMinutes(); |
| 1038 | if (std::abs(minute - interpolated_palette_minute[colorCurrent]) < 2) |
| 1039 | { |
| 1040 | return; |
| 1041 | } |
| 1042 | |
| 1043 | // recalc interpolated_palette every 2 minute |
| 1044 | interpolated_palette_minute[colorCurrent] = minute; |
| 1045 | mod_interpolated_palette[colorCurrent]->rendererPrivateData = nullptr; |
| 1046 | |
| 1047 | sp<Palette> palette1; |
| 1048 | sp<Palette> palette2; |
| 1049 | float factor = 0; |
| 1050 | // TODO: use integer calculation instead |
| 1051 | float hours_float = (float)minute / 60.0f; |
| 1052 | |
| 1053 | if (hour >= 3 && hour < 6) |
| 1054 | { |
| 1055 | palette1 = this->mod_night_palette[colorCurrent]; |
| 1056 | palette2 = this->mod_twilight_palette[colorCurrent]; |
| 1057 | factor = clamp((hours_float - 3.0f) / 3.0f, 0.0f, 1.0f); |
| 1058 | } |
| 1059 | else if (hour >= 6 && hour < 9) |
nothing calls this directly
no test coverage detected