Commit 4c937cb2 authored by Gerhard Stein's avatar Gerhard Stein

Save/Load Gamemenu improvements and less code

parent a20eed2e
......@@ -37,7 +37,7 @@ CBaseMenu( CRect<float>(0.1f, 0.0f, 0.8f, 1.0f) )
for( Uint32 i=1 ; i<=8 ; i++ )
{
std::string text = gpSaveGameController->getEmptyString();
std::string text = "Slot " + itoa(i);
if( i <= StateFileList.size() )
{
......
......@@ -19,15 +19,12 @@ CBaseMenu(CRect<float>(0.1f, 0.0f, 0.8f, 1.0f) ),
mp_OverwriteMenu(NULL),
m_overwrite(false)
{
std::string text;
// Load the state-file list
std::vector<std::string> StateFileList = gpSaveGameController->getSlotList();
for(Uint32 i=1;i<=8;i++)
{
text = "";
std::string text = "Slot " + itoa(i);
if(i <= StateFileList.size())
text = StateFileList.at(i-1);
......@@ -48,9 +45,17 @@ void CSaveMenu::sendEvent(SmartPointer<CEvent> command)
{
if(ev->mCommand == IC_JUMP || ev->mCommand == IC_STATUS)
{
const CGUIInputText *pInput = dynamic_cast<CGUIInputText*>(mpMenuDialog->CurrentControl());
gpSaveGameController->prepareSaveGame( sel, pInput->getText() );
g_pBehaviorEngine->EventList().add( new CloseAllMenusEvent() );
CGUIInputText *pInput = dynamic_cast<CGUIInputText*>(mpMenuDialog->CurrentControl());
if(pInput->Typing())
{
gpSaveGameController->prepareSaveGame( sel, pInput->getText() );
g_pBehaviorEngine->EventList().add( new CloseAllMenusEvent() );
}
else
{
pInput->setTypeMode(true);
}
return;
}
}
......
......@@ -24,14 +24,6 @@ CSaveGameController::CSaveGameController()
{
m_offset = 0;
const int spacelen = ((TEXT_WIDTH-6)/2);
for(int c=0 ; c<spacelen ; c++)
m_emptyString += " ";
m_emptyString += "EMPTY";
for(int c=0 ; c<spacelen ; c++)
m_emptyString += " ";
setGameDirectory(g_pBehaviorEngine->m_ExeFile.getDataDirectory());
setEpisode(g_pBehaviorEngine->getEpisode());
}
......@@ -57,9 +49,6 @@ Uint32 CSaveGameController::getDataSize(std::ifstream &StateFile) {
}
// Return a string that just says empty
std::string CSaveGameController::getEmptyString()
{ return m_emptyString; }
std::string CSaveGameController::getUnnamedSlotName()
{
std::string text;
......@@ -125,7 +114,7 @@ std::vector<std::string> CSaveGameController::getSlotList()
buf = getSlotName(*i);
if(pos+1 > filelist.size())
filelist.resize(pos+1, m_emptyString);
filelist.resize(pos+1, "");
filelist.at(pos) = buf;
}
......
......@@ -26,11 +26,6 @@
#define OLDSAVEGAMEVERSION5 '5'
#define OLDSAVEGAMEVERSION4 '4'
// Savegame/Loadgame Menu common stuff
const int MENU_WIDTH = 40;
const int TEXT_WIDTH = 32;
#define gpSaveGameController CSaveGameController::Get()
......@@ -79,7 +74,6 @@ public:
bool load();
bool alreadyExits();
std::string getEmptyString();
std::string getUnnamedSlotName();
private:
......@@ -97,7 +91,6 @@ private:
char m_Episode;
int m_Level;
Uint32 m_offset;
std::string m_emptyString;
std::vector<byte> m_datablock;
};
......
......@@ -43,10 +43,10 @@ drawButton(&CGUIInputText::drawNoStyle)
void CGUIInputText::sendEvent(const InputCommands command)
{
if(command == IC_STATUS)
/*if(command == IC_STATUS)
{
mTyping = !mTyping;
}
}*/
}
......@@ -78,8 +78,8 @@ void CGUIInputText::processLogic()
mButtonUp = false;
}
if(!mButtonDown)
mTyping = false;
/*if(!mButtonDown)
mTyping = false;*/
// Here we check if the mouse-cursor/Touch entry clicked on our Button
if( MouseMoveEvent *mouseevent = g_pInput->m_EventList.occurredEvent<MouseMoveEvent>() )
......@@ -180,10 +180,6 @@ void CGUIInputText::processRender(const CRect<float> &RectDispCoordFloat)
std::string CGUIInputText::getInputString()
{
if( mText == "" )
return gpSaveGameController->getEmptyString();
std::string text;
text = mText;
......
......@@ -37,6 +37,9 @@ public:
std::string getText() const
{ return mText; }
bool Typing() const { return mTyping; }
void setTypeMode( const bool value ) { mTyping = value; }
private:
// Returns the string that has to be displayed on the gui
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment