3 using System.Collections;
8 public Sprite SpriteLiver = null;
9 public Sprite SpriteBone = null;
10 public Sprite SpriteBrain = null;
11 public Sprite SpritePancreas = null;
12 public Sprite SpriteIntestine = null;
13 public Sprite SpriteUnknown = null;
15 private GameObject mScrollView;
17 private int notificationID;
23 mScrollView = transform.Find(
"Background/Scroll View").gameObject;
25 defaultPatientButton = mScrollView.transform.Find(
"Viewport/Content/ButtonPatient").gameObject;
26 defaultPatientButton.SetActive(
false);
28 PatientEventSystem.startListening (
29 PatientEventSystem.Event.PATIENT_NewPatientDirectoryFound,
33 PatientDirectoryLoader.setPath(
"../Patients/");
36 public void OnEnable()
38 notificationID = UI.Core.instance.addIndication ( GetComponent<Widget>().layoutScreen,
"Please choose patient");
40 public void OnDisable()
42 UI.Core.instance.clearIndication (notificationID);
45 void ChoosePatient(
int index )
49 PatientDirectoryLoader.loadPatient(index);
53 void addPatientEntry(
object obj = null )
57 foreach(Transform child
in defaultPatientButton.transform.parent) {
60 if( child.gameObject.activeSelf ) {
61 Destroy (child.gameObject);
66 for(
int index = 0; index < PatientDirectoryLoader.getCount(); index ++ )
68 PatientMeta patient = PatientDirectoryLoader.getEntry(index);
71 GameObject newButton = Instantiate(defaultPatientButton);
72 newButton.SetActive(
true);
75 newButton.transform.SetParent(defaultPatientButton.transform.parent, false );
78 Text t = newButton.transform.Find(
"Text").GetComponent<Text>();
79 t.text = patient.name +
"\n <color=#DDDDDD>" + patient.birthDate +
"</color>";
81 newButton.transform.Find (
"ImageFemale").gameObject.SetActive (
false);
82 newButton.transform.Find (
"ImageMale").gameObject.SetActive (
false);
83 if (patient.sex ==
"f") {
84 newButton.transform.Find (
"ImageFemale").gameObject.SetActive (
true);
85 }
else if (patient.sex ==
"m") {
86 newButton.transform.Find (
"ImageMale").gameObject.SetActive (
true);
89 Text ageText = newButton.transform.Find(
"AgeText").GetComponent<Text>();
90 if (patient.age >= 0) {
91 ageText.text = patient.age +
" a";
96 Text detailsText = newButton.transform.Find(
"TextDetails").GetComponent<Text>();
97 detailsText.text = patient.diagnosis +
"\n <color=#DDDDDD>" + patient.details +
"</color>";
99 Image operationTypeImage = newButton.transform.Find (
"IconBackground/OperationTypeImage").GetComponent<Image> ();
100 if (operationTypeImage != null) {
101 operationTypeImage.sprite = spriteForOperatedBodyPart (patient.operationBodyPart);
103 operationTypeImage.gameObject.SetActive (
false);
106 if (patient.warnings.Count > 0) {
107 string warnings =
"";
108 for (
int i = 0; i < patient.warnings.Count; i++) {
109 warnings = warnings + patient.warnings [i] +
"\n";
111 Text warningsText = newButton.transform.Find(
"TextWarnings").GetComponent<Text>();
112 warningsText.text = warnings;
116 int capturedIndex = index;
117 Button b = newButton.GetComponent<Button>();
118 b.onClick.AddListener(() => ChoosePatient(capturedIndex));
119 b.onClick.AddListener (() => gameObject.SetActive (
false));
133 Sprite spriteForOperatedBodyPart(
PatientMeta.OperationBodyPart ot )
137 }
else if (ot ==
PatientMeta.OperationBodyPart.Bone) {
139 }
else if (ot ==
PatientMeta.OperationBodyPart.Brain) {
141 }
else if (ot ==
PatientMeta.OperationBodyPart.Pancreas) {
142 return SpritePancreas;
143 }
else if (ot ==
PatientMeta.OperationBodyPart.Intestine) {
144 return SpriteIntestine;
146 return SpriteUnknown;
150 private GameObject defaultPatientButton = null;