Update tutorial system - Part 4 : Tutorial.h

Update tutorial system to made it works (I hope).
This commit is contained in:
Futuray-pgm 2024-07-04 21:43:18 +02:00
parent 811956a449
commit cc6ef1b7c4
1 changed files with 14 additions and 64 deletions

View File

@ -26,35 +26,29 @@
************************************************************************/
/* 2304
// Tutorial TODO
{
vlprintf(CN_INFO,"Tuto Begin");
core::dimension2d<u32> screensize = driver->getScreenSize();
s32 x = (screensize.Width/2);
s32 y = (screensize.Height/2);
LocalPlayer* player = client.getLocalPlayer();
vlprintf(CN_INFO,"Tuto 1 OK");
Tutorial* tuto = player->tutorial;
vlprintf(CN_INFO,"Tuto 1 get OK & ");
vlprintf(CN_INFO, (char*)std::to_string(tuto->getCurrentTutorialNumber()).c_str());
Tutorial *tuto = player->tutorial;
std::string tutotext = tuto->getCurrentTutorialText();
vlprintf(CN_INFO,"Tuto 1 bis OK");
std::wstring text = narrow_to_wide(tutotext);
vlprintf(CN_INFO,"Tuto 1 bis bis OK");
core::dimension2d<u32> textsize = guienv->getSkin()->getFont()->getDimension(text.c_str());
vlprintf(CN_INFO,"Tuto 2 OK");
core::rect<s32> rect((x-412)-(textsize.Width/2), y+10, (x-412)+(textsize.Width/2), y+10+textsize.Height);
guienv->addStaticText(text.c_str(),rect);
vlprintf(CN_INFO,"Tuto 3 OK"); //chatline_add(&chat_lines,narrow_to_wide(gettext("HUD shown")),-103.00);
vlprintf(CN_INFO,"Tuto OK"); //chatline_add(&chat_lines,narrow_to_wide(gettext("HUD shown")),-103.00);
}
*/
// 395 [player.h]
// #include "tutorial.h"
// 395
// Tutorial *tutorial;
// 76 [player.cpp]
// tutorial(new Tutorial())
#ifndef TUTORIAL_HEADER
#define TUTORIAL_HEADER
@ -74,65 +68,21 @@ class Tutorial
public:
Tutorial();
Tutorial(int current);
virtual ~Tutorial();
std::string getText(int num)
{
vlprintf(CN_INFO,std::to_string(num).c_str());
switch(num) // TODO : translations
{
case TUTORIAL_WALK :
vlprintf(CN_INFO,"TUTORIAL_WALK");
return "Press the [W] button to walk forward and the spacebar to jump.";
std::string getText(int num);
case TUTORIAL_LOOK :
vlprintf(CN_INFO,"TUTORIAL_LOOK");
return "Move the mouse to look around you.";
void setCurrentTutorialToNext();
case TUTORIAL_DIG_PLACE :
vlprintf(CN_INFO,"TUTORIAL_DIG_PLACE");
return "Use the left click to dig nodes and the right click to place them.";
void setCurrentTutorialToNumber(int number);
case TUTORIAL_EAT :
vlprintf(CN_INFO,"TUTORIAL_EAT");
return "Use the [H] button to eat any food.";
int getCurrentTutorialNumber();
case TUTORIAL_INVENTORY :
vlprintf(CN_INFO,"TUTORIAL_INVENTORY");
return "Press the [I] button to open your inventory and the [Q] button to interact with nodes.";
std::string getCurrentTutorialText();
default :
vlprintf(CN_INFO,"default");
return "Tutorial is done!";
};
}
std::string getNumberText(int number);
void setCurrentTutorialToNext()
{
currentTutorial++;
}
void setCurrentTutorialToNumber(int number)
{
currentTutorial = number;
}
int getCurrentTutorialNumber()
{
return currentTutorial;
}
std::string getCurrentTutorialText()
{
vlprintf(CN_INFO, (char*)std::to_string(currentTutorial).c_str());
return getText(currentTutorial);
}
std::string getNumberText(int number)
{
return getText(number);
}
protected:
int currentTutorial;
};
#endif