1212import net .minecraftforge .common .config .Configuration ;
1313import net .minecraftforge .fml .common .eventhandler .SubscribeEvent ;
1414
15+ /**
16+ * Renders an interactive tutorial to the game overlay.
17+ *
18+ * @author ScribbleLP
19+ *
20+ */
1521public class TutorialHandler {
1622
1723 public static boolean istutorial ;
@@ -25,16 +31,23 @@ public class TutorialHandler {
2531
2632 public TutorialHandler () {
2733 }
34+
2835 public TutorialHandler (int state ) {
2936 this .state =state ;
3037 }
38+
3139 public void setState (int state ) {
3240 cooldown =cooldowntime ;
3341 this .state = state ;
3442 }
43+
3544 public int getState () {
3645 return state ;
3746 }
47+ /**
48+ * Get the current text depending on the state
49+ * @return String[]
50+ */
3851 public String [] getTutorialText () {
3952 String [] textout ;
4053 switch (state ) {
@@ -80,6 +93,9 @@ public String[] getTutorialText() {
8093 }
8194 return textout ;
8295 }
96+ /**
97+ * Checks for an action that advances or closes the tutorial
98+ */
8399 private void checkForKeys () {
84100 switch (state ) {
85101 case 0 :
@@ -90,7 +106,7 @@ private void checkForKeys() {
90106 case 8 :
91107 case 11 :
92108
93- if (Keyboard .isKeyDown (Keyboard .KEY_RETURN )&&cooldown ==0 ) {
109+ if (Keyboard .isKeyDown (Keyboard .KEY_RETURN )&&cooldown ==0 ) { //Checking for presses on the physical keyboard, since tickrate 0 is a thing
94110 advanceState ();
95111 }
96112 break ;
@@ -113,11 +129,19 @@ private void checkForKeys() {
113129 break ;
114130 }
115131 }
132+ /**
133+ * Advances the tutorial state and adds cooldown
134+ */
116135 public void advanceState () {
117136 cooldown =cooldowntime ;
118137 state ++;
119138 }
120139 Minecraft mc = Minecraft .getMinecraft ();
140+
141+ /**
142+ * Main rendering event. This is needed so it can function in tickrate 0
143+ * @param event
144+ */
121145 @ SubscribeEvent
122146 public void drawStuff (RenderGameOverlayEvent .Post event ) {
123147 if (istutorial ) {
@@ -129,17 +153,20 @@ public void drawStuff(RenderGameOverlayEvent.Post event) {
129153 int width = scaled .getScaledWidth ();
130154 int height = scaled .getScaledHeight ();
131155 String [] text = getTutorialText ();
132- for (int i = 0 ; i < text .length ; i ++) {
156+
157+
158+ for (int i = 0 ; i < text .length ; i ++) { //For every new element in the string array, a new line is created.
133159 String tex = text [i ];
134160 new Gui ().drawString (mc .fontRenderer , tex , width - mc .fontRenderer .getStringWidth (tex ) - 10 ,
135- 10 + 10 * i , 0xFFFFFF );
161+ 10 + 10 * i , 0xFFFFFF ); //Drawing the text on the screen
136162 }
137163
138164 if (cooldown != 0 ) {
139- cooldown --;
165+ cooldown --; //Decreasing the cooldown of the button cooldown until it reaches 0
140166 }
141167 }
142168 }
169+ //Every String in one place... maybe later with translations
143170 private final String [] text1 ={"1. Hi, welcome to this InTeRaCtIvE tutorial on how to use this mod." ,
144171 "" ,
145172 "If you have already enough of this text," ,
0 commit comments