Skip to content

Commit

Permalink
Add question mark, use it in the mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarroDC committed Feb 9, 2024
1 parent e428aab commit 5706af2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
19 changes: 17 additions & 2 deletions SuitLog/SuitLogItemList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SuitLogItemList : MonoBehaviour
public OWAudioSource oneShotSource; // Well this is used for the custom modes I guess
public Text nameField;
public Image photo;
public Text questionMark;
public DescriptionField descriptionField;

public int selectedIndex;
Expand Down Expand Up @@ -50,13 +51,27 @@ public static void CreatePrefab(ScreenPromptList upperRightPromptList)

private void Setup(GameObject canvas, ScreenPromptList upperRightPromptList)
{
// TODO: Make this part of list
// Photo & Question Mark
Transform probeDisplay = canvas.transform.Find("HUDProbeDisplay");
GameObject photoRoot = Instantiate(probeDisplay.gameObject, transform);
photoRoot.transform.localPosition = probeDisplay.transform.localPosition - _commonParent.localPosition; // Offset to match the original
photoRoot.DestroyAllComponents<ProbeLauncherUI>();
photoRoot.SetActive(true);
photo = photoRoot.GetComponentInChildren<Image>();
photo.enabled = true;
photo.gameObject.SetActive(false);
questionMark = SuitLog.CreateText();
questionMark.name = "QuestionMark";
RectTransform questionMarkTransform = questionMark.transform as RectTransform;
SuitLog.SetParent(questionMarkTransform, photoRoot.transform);
questionMarkTransform!.SetAsFirstSibling(); // Bellow photo, like in Ship Log
questionMarkTransform.localPosition = photo.transform.localPosition;
questionMarkTransform.pivot = new Vector2(0.5f, 0.5f);
questionMark.alignment = TextAnchor.MiddleCenter;
questionMark.fontSize = 220;
questionMark.text = "?";
questionMark.color = new Color(1, 0.6f, 0); // Same as Ship Log's, although it looks different
questionMark.gameObject.SetActive(false);

// Title
nameField = SuitLog.CreateText();
Expand Down Expand Up @@ -199,7 +214,7 @@ public void UpdateListUI()
}

// TODO: Clarify this in docs
if (photo.enabled)
if (photo.gameObject.activeSelf || questionMark.gameObject.activeSelf)
{
SetPromptsPosition(-250f);
}
Expand Down
20 changes: 17 additions & 3 deletions SuitLog/SuitLogMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private void CloseEntryMenu()
itemList.DescriptionFieldClose();
LoadAstroObjectsMenu();
HidePhoto();
HideQuestionMark();
_displayedEntryItems.Clear(); // TODO: Why?
_isEntryMenuOpen = false;
_oneShotSource.PlayOneShot(AudioType.ShipLogDeselectPlanet);
Expand Down Expand Up @@ -352,29 +353,42 @@ private void UpdateSelectedEntry()
}
else
{
HidePhoto();
ShowQuestionMark();
}
}
else
{
// In MapModeMode, this would happen at OpenEntryMenu
itemList.DescriptionFieldGetNextItem()
.DisplayText(UITextLibrary.GetString(UITextType.LogNoDiscoveriesPrompt));
ShowQuestionMark();
}
}

private void ShowPhoto(ShipLogEntry entry)
{
itemList.photo.enabled = true;
HideQuestionMark();
itemList.photo.gameObject.SetActive(true);
itemList.photo.sprite = entry.GetSprite();
}

private void HidePhoto()
{
itemList.photo.enabled = false;
itemList.photo.gameObject.SetActive(false);
itemList.photo.sprite = null;
}

private void ShowQuestionMark()
{
HidePhoto();
itemList.questionMark.gameObject.SetActive(true);
}

private void HideQuestionMark()
{
itemList.questionMark.gameObject.SetActive(false);
}

public override bool AllowModeSwap()
{
return true;
Expand Down

0 comments on commit 5706af2

Please sign in to comment.