Menu map fixes and resizable window on GLFW

This commit is contained in:
eray orçunus 2020-05-09 13:43:08 +03:00
parent e0b3418e65
commit f754da272f
4 changed files with 41 additions and 10 deletions

View File

@ -901,6 +901,25 @@ CMenuManager::Draw()
bool foundTheHoveringItem = false; bool foundTheHoveringItem = false;
wchar unicodeTemp[64]; wchar unicodeTemp[64];
#ifdef MENU_MAP
if (m_nCurrScreen == MENUPAGE_MAP) {
// Back button
wchar *backTx = TheText.Get("FEDS_TB");
CFont::SetDropShadowPosition(1);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(MENU_X(60.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), backTx);
CFont::SetDropShadowPosition(0);
if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) {
m_nHoverOption = HOVEROPTION_NOT_HOVERING;
m_nCurrOption = m_nPrevOption = 0;
} else {
m_nHoverOption = HOVEROPTION_RANDOM_ITEM;
m_nCurrOption = m_nPrevOption = 1;
}
return;
}
#endif
for (int i = 0; i < NUM_MENUROWS; ++i) { for (int i = 0; i < NUM_MENUROWS; ++i) {
if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') { if (aScreens[m_nCurrScreen].m_aEntries[i].m_Action != MENUACTION_LABEL && aScreens[m_nCurrScreen].m_aEntries[i].m_EntryName[0] != '\0') {
wchar *rightText = nil; wchar *rightText = nil;
@ -5381,13 +5400,13 @@ CMenuManager::PrintController(void)
#define ZOOM(x, y, in) \ #define ZOOM(x, y, in) \
do { \ do { \
if(fMapSize > SCREEN_WIDTH * 2 && in) \ if(fMapSize > SCREEN_HEIGHT * 3.0f && in) \
break; \ break; \
float z2 = in? 1.1f : 1.f/1.1f; \ float z2 = in? 1.1f : 1.f/1.1f; \
fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \ fMapCenterX += (x - fMapCenterX) * (1.0f - z2); \
fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \ fMapCenterY += (y - fMapCenterY) * (1.0f - z2); \
\ \
if (fMapSize < SCREEN_WIDTH / 3 && !in) \ if (fMapSize < SCREEN_HEIGHT / 2 && !in) \
break; \ break; \
\ \
fMapSize *= z2; \ fMapSize *= z2; \
@ -5400,10 +5419,18 @@ CMenuManager::PrintMap(void)
bMenuMapActive = true; bMenuMapActive = true;
CRadar::InitFrontEndMap(); CRadar::InitFrontEndMap();
// Just entered to map
if (!bMapLoaded) { if (!bMapLoaded) {
fMapCenterX = SCREEN_WIDTH / 2; fMapSize = SCREEN_HEIGHT * 2.0f;
fMapCenterY = SCREEN_HEIGHT / 3; fMapCenterX = 0.0f;
fMapSize = SCREEN_HEIGHT / CDraw::GetAspectRatio(); fMapCenterY = 0.0f;
CVector2D radarSpacePlayer;
CVector2D screenSpacePlayer;
CRadar::TransformRealWorldPointToRadarSpace(radarSpacePlayer, CVector2D(FindPlayerCoors()));
CRadar::TransformRadarPointToScreenSpace(screenSpacePlayer, radarSpacePlayer);
fMapCenterX = (-screenSpacePlayer.x) + SCREEN_WIDTH / 2;
fMapCenterY = (-screenSpacePlayer.y) + SCREEN_HEIGHT / 2;
bMapMouseShownOnce = false; bMapMouseShownOnce = false;
bMapLoaded = true; bMapLoaded = true;

View File

@ -459,6 +459,8 @@ const CMenuScreen aScreens[] = {
#ifdef MENU_MAP #ifdef MENU_MAP
// MENUPAGE_MAP = 59 // MENUPAGE_MAP = 59
{ "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2, { "FEG_MAP", 1, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2,
MENUACTION_UNK110, "", SAVESLOT_NONE, MENUPAGE_NONE, // to prevent cross/enter to go back
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
}, },
#endif #endif
}; };

View File

@ -1435,9 +1435,9 @@ CRadar::DrawYouAreHereSprite(float x, float y)
if (show) { if (show) {
float left = x - SCREEN_SCALE_X(12.0f); float left = x - SCREEN_SCALE_X(12.0f);
float top = y - SCREEN_SCALE_Y(2.0f); float top = y;
float right = SCREEN_SCALE_X(12.0) + x; float right = SCREEN_SCALE_X(12.0) + x;
float bottom = y - SCREEN_SCALE_Y(26.0f); float bottom = y - SCREEN_SCALE_Y(24.0f);
CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255)); CentreSprite.Draw(CRect(left, top, right, bottom), CRGBA(255, 255, 255, 255));
} }
MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE; MapLegendList[MapLegendCounter++] = RADAR_SPRITE_CENTRE;

View File

@ -1024,12 +1024,14 @@ void resizeCB(GLFWwindow* window, int width, int height) {
if (RwInitialised && height > 0 && width > 0) { if (RwInitialised && height > 0 && width > 0) {
RwRect r; RwRect r;
// TODO support resizing with mouse. Now enabling this makes weird things to trails and CameraSize messing with sizes // TODO fix artifacts of resizing with mouse
RsGlobal.maximumHeight = height;
RsGlobal.maximumWidth = width;
r.x = 0; r.x = 0;
r.y = 0; r.y = 0;
r.w = RsGlobal.maximumWidth; r.w = width;
r.h = RsGlobal.maximumHeight; r.h = height;
RsEventHandler(rsCAMERASIZE, &r); RsEventHandler(rsCAMERASIZE, &r);
} }