| 744 | } |
| 745 | |
| 746 | void Player::SignGUI_t::updateSignGUI() |
| 747 | { |
| 748 | if ( !signFrame ) |
| 749 | { |
| 750 | createSignGUI(); |
| 751 | } |
| 752 | |
| 753 | bool errorOpening = false; |
| 754 | if ( signName == "" || ScriptTextParser.allEntries.find(signName) == ScriptTextParser.allEntries.end() ) |
| 755 | { |
| 756 | errorOpening = true; |
| 757 | } |
| 758 | |
| 759 | if ( player.GUI.activeModule != player.GUI.MODULE_SIGN_VIEW || player.gui_mode != GUI_MODE_SIGN ) |
| 760 | { |
| 761 | bSignOpen = false; |
| 762 | } |
| 763 | else if ( player.entity ) |
| 764 | { |
| 765 | real_t dist = sqrt(pow(signWorldCoordX - player.entity->x, 2) + pow(signWorldCoordY - player.entity->y, 2)); |
| 766 | if ( dist > TOUCHRANGE ) |
| 767 | { |
| 768 | errorOpening = true; |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | if ( !bSignOpen || errorOpening || !player.isLocalPlayerAlive() ) |
| 773 | { |
| 774 | auto innerFrame = signFrame->findFrame("sign frame"); |
| 775 | SDL_Rect pos = innerFrame->getSize(); |
| 776 | signFadeInAnimationY = 0.0; |
| 777 | pos.y = -pos.h; |
| 778 | innerFrame->setSize(pos); |
| 779 | |
| 780 | auto fade = signFrame->findImage("fade img"); |
| 781 | Uint8 r, g, b, a; |
| 782 | getColor(fade->color, &r, &g, &b, &a); |
| 783 | a = 0; |
| 784 | fade->color = makeColor(r, g, b, a); |
| 785 | |
| 786 | closeSignGUI(); |
| 787 | return; |
| 788 | } |
| 789 | |
| 790 | signFrame->setDisabled(false); |
| 791 | signFrame->setSize(SDL_Rect{ players[player.playernum]->camera_virtualx1(), |
| 792 | players[player.playernum]->camera_virtualy1(), |
| 793 | players[player.playernum]->camera_virtualWidth(), |
| 794 | players[player.playernum]->camera_virtualHeight() }); |
| 795 | |
| 796 | auto innerFrame = signFrame->findFrame("sign frame"); |
| 797 | SDL_Rect bookSize = innerFrame->getSize(); |
| 798 | bookSize.x = signFrame->getSize().w / 2 - bookSize.w / 2; |
| 799 | |
| 800 | const real_t fpsScale = getFPSScale(50.0); // ported from 50Hz |
| 801 | real_t setpointDiffX = fpsScale * std::max(.01, (1.0 - signFadeInAnimationY)) / 5.0; |
| 802 | signFadeInAnimationY += setpointDiffX; |
| 803 | signFadeInAnimationY = std::min(1.0, signFadeInAnimationY); |
no test coverage detected