Second commit for tests.

This commit is contained in:
Futuray-pgm 2024-04-13 10:33:52 +02:00
parent a0f70edc60
commit 7ca1afdbd0
2 changed files with 176 additions and 0 deletions

38
src/tutorial.cpp Normal file
View File

@ -0,0 +1,38 @@
/************************************************************************
* Minetest-c55
* Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* tutorial.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
*
* Created by Futuray
************************************************************************/
#include "tutorial.h"
#include <string>
Tutorial::Tutorial():
currentTutorial(0)
{
};
Tutorial::~Tutorial()
{
};

138
src/tutorial.h Normal file
View File

@ -0,0 +1,138 @@
/************************************************************************
* Minetest-c55
* Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
*
* tutorial.h
* voxelands - 3d voxel world sandbox game
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
* for Voxelands.
*
* Created by Futuray
************************************************************************/
/* 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());
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);
}
*/
// #include "tutorial.h"
// 395
// Tutorial *tutorial;
#ifndef TUTORIAL_HEADER
#define TUTORIAL_HEADER
#include "log.h"
#include "common.h"
#include <string>
#define TUTORIAL_WALK 0
#define TUTORIAL_LOOK 1
#define TUTORIAL_DIG_PLACE 2
#define TUTORIAL_EAT 3
#define TUTORIAL_INVENTORY 4
class Tutorial
{
public:
Tutorial();
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.";
case TUTORIAL_LOOK :
vlprintf(CN_INFO,"TUTORIAL_LOOK");
return "Move the mouse to look around you.";
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.";
case TUTORIAL_EAT :
vlprintf(CN_INFO,"TUTORIAL_EAT");
return "Use the [H] button to eat any food.";
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.";
default :
vlprintf(CN_INFO,"default");
return "Tutorial is done!";
};
}
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