Exemple #1
0
PModel MainLoop::loadPrevious(bool erase) {
  vector<View::ListElem> options;
  vector<SaveFileInfo> files;
  getSaveOptions({
      {Model::GameType::AUTOSAVE, "Recovered games:"},
      {Model::GameType::KEEPER, "Keeper games:"},
      {Model::GameType::ADVENTURER, "Adventurer games:"}}, options, files);
  optional<SaveFileInfo> savedGame = chooseSaveFile(options, files, "No save files found.", view);
  if (savedGame)
    return loadModel(savedGame->filename, erase);
  else
    return nullptr;
}
Exemple #2
0
PModel MainLoop::adventurerGame() {
  vector<View::ListElem> elems;
  vector<SaveFileInfo> files;
  getSaveOptions({
      {Model::GameType::RETIRED_KEEPER, "Retired local games:"}}, elems, files);
  if (options->getBoolValue(OptionId::ONLINE))
    getDownloadOptions(elems, files, "Retired online games:");
  optional<SaveFileInfo> savedGame = chooseSaveFile(elems, files, "No retired games found.", view);
  if (savedGame) {
    if (savedGame->download)
      if (!downloadGame(savedGame->filename))
        return nullptr;
    return loadModel(savedGame->filename, false);
  }
  else
    return nullptr;
}
Exemple #3
0
//The primary conroller for the game. Using the progress value passed in,
//the function knows what the current stat of the game is. Currently, there
//is nothing after progress value = 3, and the game isn't saved after the fight
//ends, but this can be changed/expanded
void playGame(Hero* heroes, char* playerName, Boss* boss, int progress, int choice)
{

	//Added flavor 
	if(progress > 0)
	{
		printf("\nWelcome back %s.\n\n", playerName);
	}

	//holds what the last thing done was.
	int initialprogress = progress;

	Hero* chosenHeroes;
	Shop* s;
	//another check for how the data is laid out. This is so we can immediately print out
	//heroes if we have already selected heroes. 
	if(progress > 1)
	{
		chosenHeroes = heroes;
	}	
	
	switch(progress)
	{
		//initial player identification
		case 0:
			playerName = getPlayerName();
			choice = chooseSaveFile();
			saveFileData(choice, choiceToFile(choice-1), NULL, playerName, 1);
		//hero selection
		case 1:
			chosenHeroes = pickHeroes(heroes);
			saveFileData(choice, choiceToFile(choice-1), chosenHeroes, playerName, 2);
			free(heroes);
		//equip heroes with items 
		case 2:
			//shop
			s = loadShop();
			goShopping(chosenHeroes, s);
			saveFileData(choice, choiceToFile(choice-1), chosenHeroes, playerName, 3);
		//fight the boss (a boss? Maybe find some way to get more than one boss in there?)
		case 3: 
			boss = loadBoss();
			int result = fight(boss, chosenHeroes);
			result == 0 ? printf("You won! Congrats!\n") : printf("Oh no, you lost! Reload to try again.\n");
			//If you're in here, it's probably to delete this line first
			printf("\n\n**********CONGRATS! YOU MADE IT TO THE END OF 2050!*************\n\n");
			freeHeroesAndItems(chosenHeroes);
			freeBossTree(boss->root);
			free(boss);
			break;
		default:
			//What?
			printf("Something fatal happened with the progress value. Check gamestate.txt.\n");
			break;
	}
	

	//I don't actually remember why I did this, but it works. 
	//I think because if it's a save file, it's freed elsewhere?
	if(initialprogress == 0)
	{
		free(playerName);
	}
	return;
}
Exemple #4
0
void playGame(Hero* heroes, char* playerName, Boss* boss, int progress, int choice)
{

	//Added flavor 
	if(progress > 0)
	{
		printf("\nWelcome back %s.\n\n", playerName);
	}

	//holds what the last thing done was.
	int initialprogress = progress;

	Hero* chosenHeroes;
	Shop* s;
	//another check for how the data is laid out. This is so we can immediately print out
	//heroes if we have already selected heroes. 
	if(progress > 1)
	{
		chosenHeroes = heroes;
	}	
	
	switch(progress)
	{
		//initial player identification
		case 0:
			playerName = getPlayerName();
			choice = chooseSaveFile();
			saveFileData(choice, choiceToFile(choice-1), NULL, playerName, 1);
		//hero selection
		case 1:
			chosenHeroes = pickHeroes(heroes);
			saveFileData(choice, choiceToFile(choice-1), chosenHeroes, playerName, 2);
			free(heroes);
		//equip heroes with items 
		case 2:
			//shop
			s = loadShop();
			//Maybe?
			//testShop(s);
			goShopping(chosenHeroes, s);
			saveFileData(choice, choiceToFile(choice-1), chosenHeroes, playerName, 3);
		//fight the boss (a boss? Maybe find some way to get more than one boss in there?)
		case 3: 
			printHeroes(chosenHeroes, NUMCHOSENHEROES);
			freeHeroesAndItems(chosenHeroes);
			//fight	
			break;
		default:
			//What?
			printf("Something fatal happened with the progress value. Check gamestate.txt.\n");
			break;
	}
	
	printf("\n\n**********Until Next Homework!*************\n\n");

	//I don't actually remember why I did this, but it works. 
	//I think because if it's a save file, it's freed elsewhere?
	if(initialprogress == 0)
	{
		free(playerName);
	}
	return;
}
}

void SliderGenerator::slotChooseLabelTemplate()
{
	chooseOpenFile(parentWindow, editLabelTemplate, "Label Template", "*.html")
}

void SliderGenerator::slotChooseCSSControlTemplate()
{
	chooseOpenFile(parentWindow, editCSSControlTemplate, "CSS template", "*.css")
}


void SliderGenerator::slotChooseOutfile()
{
	chooseSaveFile(parentWindow, editOutFile, "Output file", "*.html")
}

void SliderGenerator::slotCreate()
{
	if (verifyFields())
	{
		saveConfig();
		openDB::BackendConnector::Iterator slider_it = getSliderParameter();
		openDB::Table& _slider = slider_it.result().resultTable();

		if (_slider.storage().records() > 0)
		{
			// lettura dei vari template
			std::string main_template, slide_template, label_template, radio_template, checkedradio_template, css_template;
			openDB::readTemplate(main_template, editMainTemplate->text().toStdString());

void DescrGeneratorInterface::slotScegliMainTemplate() {
    chooseOpenFile(parentWindow, editMainTemplate, "Main Template", "*.html")
}
void DescrGeneratorInterface::slotScegliResourcesTemplate() {
    chooseOpenFile(parentWindow, editResourcesTemplate, "Resources Template", "*.html")
}
void DescrGeneratorInterface::slotScegliVideoResourcesTemplate() {
    chooseOpenFile(parentWindow, editVideoResourcesTemplate, "Video Resources Template", "*.html")
}
void DescrGeneratorInterface::slotScegliVideoTemplate() {
    chooseOpenFile(parentWindow, editVideoTemplate, "Video Template", "*.html")
}
void DescrGeneratorInterface::slotScegliFile() {
    chooseSaveFile(parentWindow, editFile, "Salva su file", "*.csv")
}


void DescrGeneratorInterface::slotCrea()
{
    if (verificaCampi())
    {
        if (worker_thread == 0 && generator == 0)
        {
            saveConfig();

            openDB::BackendConnector* connector = &parentWindow->backendConnector();
            std::string cat_merc = editCatMerc->text().toStdString();
            std::string natura = editNatura->text().toStdString();
            std::string mainTemFile = editMainTemplate->text().toStdString();