That means that I wrote code that VS2010 didn't support yet. You can't do anything about that.
I'm currently booting up my windows, I'll fix this as soon as possible.
I'm currently booting up my windows, I'll fix this as soon as possible.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: texus on 15 September 2013, 11:55:10Edit: just realized that that for loop is only supported since VS2012. It will be like this for you:for (auto it = items.cbegin(); it != items.cend(); ++it)
{
ofile << it->toAnsiString() << std::endl;
}
Callback = LeftMouseClicked
CallbackId = 1
Callback = Focused, Unfocused
Callback = LeftMouseClicked
CallbackId = 1
Callback = Focused, Unfocused
Quotecan i store the selected item from listBox in a character array or any character variable so that i may pass this character array in addItem() function of listBox, and it will store new animal name in the listBox !?I have no idea what you mean with this, but lets break it down in smaller parts.
Quotecan i store the selected item from listBox in a character array
std::string selectedItem = listBox->getSelectedItem();
Quoteso that i may pass this character array in addItem() function of listBox
listBox->addItem(selectedItem);
Quotehmmm, i didn't get you !You want to be able to keep your added animals even after the program was quit, right?
std::ifstream ifile("animals.txt");
if (ifile.is_open())
{
// Read the contents of the file and put the read animals in the listbox with addItem
}
std::ofstream ofile("animals.txt");
if (ifile.is_open())
{
auto& items = listBox->getItems();
for (auto& item : items)
{
ofile << item.toAnsiString() << std::endl;
}
}
for (auto it = items.cbegin(); it != items.cend(); ++it)
{
ofile << it->toAnsiString() << std::endl;
}
Quotebut when i close my window and compile my code again it will not show the recently added animal in the list box !Obviously. What you want to do is save a the contents of the list in a text file and load it again when starting the program (look at std::ifstream and std::ofstream).
tgui::EditBox::Ptr editBox(gui);
editBox->load("...");
listBox->setSelectedItem(listBox->getItems().size()-1); // Select the last item in the list box
std::list<sf::SoundBuffer> buffers;
std::list<sf::Sound> sounds;
buffers.push_back(sf::SoundBuffer());
buffers.back().loadFromFile(editBox->getText() + ".wav");
sounds.push_back(sf::Sound());
sounds.back().setBuffer(buffers.back());
sounds.back().setPitch(1.5f);
sounds.back().setVolume(80);
auto it = sounds.begin();
std::advance(it, listBox->getSelectedItemIndex());
it->play();