Menu::Menu() : io( IOManager::getInstance() ), words(), parser( "xmlSpec/menu.xml" ), position( parser.getXmlInt("wordsX"), parser.getXmlInt("wordsY") ), space(), surfaceOff(io.loadAndSet( parser.getXmlStr("clickoffFile"), true)), surfaceOn(io.loadAndSet( parser.getXmlStr("clickonFile"), true)), clicks(), nextIcon(0), click(OFF) { unsigned int n = parser.getXmlInt("wordsNumber"); std::stringstream strm; for ( unsigned i = 0; i < n; ++i ) { strm << "words" << i; words.push_back( parser.getXmlStr(strm.str()) ); strm.clear(); // clear error flags strm.str(std::string()); // clear contents } space[0] = parser.getXmlInt("wordsSpaceX"); space[1] = parser.getXmlInt("wordsSpaceY"); //frame( FrameFactory::getInstance().getFrame(name) ), //Frame( const std::string&, SDL_Surface*); Frame clickoff("clickoff" , surfaceOff); clicks.push_back( clickoff ); Frame clickon("clickon" , surfaceOn); clicks.push_back( clickon ); /* Frame clickoff(surfaceOff, parser.getXmlInt("clickoffWidth"), parser.getXmlInt("clickoffHeight"), parser.getXmlInt("clickoffSrcX"), parser.getXmlInt("clickoffSrcX")); clicks.push_back( clickoff ); Frame clickon(surfaceOn, parser.getXmlInt("clickonWidth"), parser.getXmlInt("clickonHeight"), parser.getXmlInt("clickonSrcX"), parser.getXmlInt("clickonSrcX")); clicks.push_back( clickon ); */ }
Menu::Menu() : io( IOManager::getInstance() ), words(), position(), space(), clicks(), nextIcon(0), click(0) { std::cout<<"in the constructor of Menu"<<std::endl; ParseXML parser( "xmlSpec/menu.xml" ); unsigned int n = parser.getXmlInt("wordsNumber"); position[0] = parser.getXmlInt("wordsX"); position[1] = parser.getXmlInt("wordsY"); std::stringstream strm; for ( unsigned i = 0; i < n; ++i ) { strm << "words" << i; words.push_back( parser.getXmlStr(strm.str()) ); strm.clear(); // clear error flags strm.str(std::string()); // clear contents } space[0] = parser.getXmlInt("wordsSpaceX"); space[1] = parser.getXmlInt("wordsSpaceY"); string filename = parser.getXmlStr("clickoffFile"); SDL_Surface* surfaceOff(io.loadAndSet(filename, true)); Frame clickoff(surfaceOff, parser.getXmlInt("clickoffWidth"), parser.getXmlInt("clickoffHeight"), parser.getXmlInt("clickoffSrcX"), parser.getXmlInt("clickoffSrcX")); clicks.push_back( clickoff ); filename = parser.getXmlStr("clickonFile"); SDL_Surface* surfaceOn(io.loadAndSet(filename, true)); Frame clickon(surfaceOn, parser.getXmlInt("clickonWidth"), parser.getXmlInt("clickonHeight"), parser.getXmlInt("clickonSrcX"), parser.getXmlInt("clickonSrcX")); clicks.push_back( clickon ); }
Gui::Gui() : io( IOManager::getInstance() ), gdata( Gamedata::getInstance() ), // parser( "xmlSpec/menu.xml" ), buttons(), clicks(), nextIcon(0), click(0) { float x = gdata->getXmlInt("newX"); float y = gdata->getXmlInt("newY"); string filename = gdata->getXmlStr("newFile"); SDL_Surface* surfaceNew(io->loadAndSet(filename, true)); Frame newFrame(surfaceNew, gdata->getXmlInt("newWidth"), gdata->getXmlInt("newHeight"), gdata->getXmlInt("pterSrcX"), gdata->getXmlInt("pterSrcX")); buttons.push_back( Button("New", newFrame, Vector2f(x, y)) ); x = gdata->getXmlInt("openX"); y = gdata->getXmlInt("openY"); filename = gdata->getXmlStr("openFile"); SDL_Surface* surfaceOpen(io->loadAndSet(filename, true)); Frame openFrame(surfaceOpen, gdata->getXmlInt("openWidth"), gdata->getXmlInt("openHeight"), gdata->getXmlInt("openSrcX"), gdata->getXmlInt("openSrcY")); //buttons.push_back( Button("Open", openFrame, Vector2f(x, y)) ); x = gdata->getXmlInt("helpX"); y = gdata->getXmlInt("helpY"); filename = gdata->getXmlStr("helpFile"); SDL_Surface* surfaceHelp(io->loadAndSet(filename, true)); Frame helpFrame(surfaceHelp, gdata->getXmlInt("helpWidth"), gdata->getXmlInt("helpHeight"), gdata->getXmlInt("helpSrcX"), gdata->getXmlInt("helpSrcY")); buttons.push_back( Button("Help", helpFrame, Vector2f(x, y)) ); filename = gdata->getXmlStr("clickoffFile"); SDL_Surface* surfaceOff(io->loadAndSet(filename, true)); Frame clickoff(surfaceOff, gdata->getXmlInt("clickoffWidth"), gdata->getXmlInt("clickoffHeight"), gdata->getXmlInt("clickoffSrcX"), gdata->getXmlInt("clickoffSrcX")); clicks.push_back( clickoff ); filename = gdata->getXmlStr("clickonFile"); SDL_Surface* surfaceOn(io->loadAndSet(filename, true)); Frame clickon(surfaceOn, gdata->getXmlInt("clickonWidth"), gdata->getXmlInt("clickonHeight"), gdata->getXmlInt("clickonSrcX"), gdata->getXmlInt("clickonSrcX")); clicks.push_back( clickon ); }