MCPcopy Create free account
hub / github.com/TurningWheel/Barony / updateSignGUI

Method updateSignGUI

src/interface/bookgui.cpp:746–1195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744}
745
746void 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);

Callers 1

ingameHudFunction · 0.80

Calls 15

getColorFunction · 0.85
makeColorFunction · 0.85
getFPSScaleFunction · 0.85
isLocalPlayerAliveMethod · 0.80
findFrameMethod · 0.80
getSizeMethod · 0.80
findImageMethod · 0.80
camera_virtualx1Method · 0.80
camera_virtualy1Method · 0.80
camera_virtualWidthMethod · 0.80
camera_virtualHeightMethod · 0.80
getVirtualMouseMethod · 0.80

Tested by

no test coverage detected