Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
 *
 *	Adventure Creator
 *	by Chris Burton, 2013-2014
 *	
 *	"MenuSavesList.cs"
 * 
 *	This MenuElement handles the display of any saved games recorded.
 * 
 */

using UnityEngine;
using AC;

#if UNITY_EDITOR
using UnityEditor;	
#endif

public class MenuSavesList : MenuElement
{
	
	public bool doOutline = false;
	public TextAnchor anchor;
	public AC_SaveListType saveListType;
	public int maxSaves = 5;

	private bool newSaveSlot = false;

	
	public override void Declare ()
	{
		isVisible = true;
		isClickable = true;
		numSlots = 1;
		maxSaves = 5;

		SetSize (new Vector2 (20f, 5f));
		anchor = TextAnchor.MiddleCenter;
		saveListType = AC_SaveListType.Save;

		newSaveSlot = false;

		base.Declare ();
	}
	
	
	public void CopySavesList (MenuSavesList _element)
	{
		doOutline = _element.doOutline;
		anchor = _element.anchor;
		saveListType = _element.saveListType;
		maxSaves = _element.maxSaves;
		
		base.Copy (_element);
	}
	
	
	#if UNITY_EDITOR
	
	public override void ShowGUI ()
	{
		EditorGUILayout.BeginVertical ("Button");
			numSlots = EditorGUILayout.IntSlider ("Test slots:", numSlots, 1, 10);
			maxSaves = EditorGUILayout.IntField ("Max saves:", maxSaves);
			anchor = (TextAnchor) EditorGUILayout.EnumPopup ("Text alignment:", anchor);
			doOutline = EditorGUILayout.Toggle ("Outline text?", doOutline);
			saveListType = (AC_SaveListType) EditorGUILayout.EnumPopup ("Click action:", saveListType);
			orientation = (ElementOrientation) EditorGUILayout.EnumPopup ("Slot orientation:", orientation);
			if (orientation == ElementOrientation.Grid)
			{
				gridWidth = EditorGUILayout.IntSlider ("Grid size:", gridWidth, 1, 10);
			}
		EditorGUILayout.EndVertical ();
		
		base.ShowGUI ();
	}
	
	#endif


	public override string GetLabel (int slot)
	{
		return SaveSystem.GetSaveSlotName (slot);
	}
	

	public override void Display (GUIStyle _style, int _slot, float zoom)
	{
		base.Display (_style, _slot, zoom);
		
		_style.alignment = anchor;
		if (zoom < 1f)
		{
			_style.fontSize = (int) ((float) _style.fontSize * zoom);
		}
		
		string slotLabel = SaveSystem.GetSaveSlotName (_slot);
		if (newSaveSlot && _slot == (numSlots - 1))
		{
			slotLabel = "New save";
		}
		
		if (doOutline)
		{
			AdvGame.DrawTextOutline (ZoomRect (GetSlotRectRelative (_slot), zoom), slotLabel, _style, Color.black, _style.normal.textColor, 2);
		}
		else
		{
			GUI.Label (ZoomRect (GetSlotRectRelative (_slot), zoom), slotLabel, _style);
		}
	}
	
	
	public override void RecalculateSize ()
	{
		newSaveSlot = false;

		if (Application.isPlaying)
		{
			numSlots = SaveSystem.GetNumSlots ();
			
			if (saveListType == AC_SaveListType.Save && numSlots < maxSaves)
			{
				newSaveSlot = true;
				numSlots ++;
			}
		}

		base.RecalculateSize ();
	}
	
	
	protected override void AutoSize ()
	{
		AutoSize (new GUIContent (SaveSystem.GetSaveSlotName (0)));
	}
	
}

Commits for Nextrek/SpaceCrew/SpaceCrew/Assets/AdventureCreator/Scripts/Menu/Menu classes/MenuSavesList.cs

Diff revisions: vs.
Revision Author Commited Message
83 FMMortaroli picture FMMortaroli Tue 13 May, 2014 11:32:51 +0000