Ejemplo n.º 1
0
MenuMapOptions::MenuMapOptions(std::shared_ptr<Settings> &settings, std::shared_ptr<AcedSharedDLL::Map> &currentMap) : Menu((std::shared_ptr<AcedSharedDLL::BaseSettings>)settings) {
	SetMap(currentMap);

	SetMenuHeader(std::string("Map Options"));
	SetId(AcedSharedDLL::STATES::EDITORMAPOPTIONS);
	int widestItem = settings->GetFontWidth(GetMenuHeader());

	auto itemStoreCurrentWidth = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreCurrentWidth->SetMenuItemText(std::string("Current Width:"));

	//might need to delete this tempval char array? mmm looks to be in stack so should die when method finishs....
	std::string tempVal;
	tempVal = std::to_string(GetMap()->GetMapWidth());

	itemStoreCurrentWidth->InitMenuItemProperty(tempVal);
	itemStoreCurrentWidth->SetMenuItemTargetable(false);
	if (widestItem < settings->GetFontWidth(itemStoreCurrentWidth->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreCurrentWidth->GetMenuItemText());
	}
	AddMenuItem(itemStoreCurrentWidth);





	auto itemStoreNewWidth = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNewWidth->InitMenuItemProperty("");
	itemStoreNewWidth->SetOptionId(AcedSharedDLL::OPTIONTYPES::WIDTHOPTION);
	itemStoreNewWidth->SetMenuItemText(std::string("New Width:"));
	if (widestItem < settings->GetFontWidth(itemStoreNewWidth->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNewWidth->GetMenuItemText());
	}
	AddMenuItem(itemStoreNewWidth);




	auto itemStoreCurrentHeight = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreCurrentHeight->SetMenuItemText(std::string("Current Height:"));

	tempVal = std::to_string(GetMap()->GetMapHeight());

	itemStoreCurrentHeight->InitMenuItemProperty(tempVal);
	itemStoreCurrentHeight->SetMenuItemTargetable(false);
	if (widestItem < settings->GetFontWidth(itemStoreCurrentHeight->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreCurrentHeight->GetMenuItemText());
	}
	AddMenuItem(itemStoreCurrentHeight);






	auto itemStoreNewHeight = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNewHeight->InitMenuItemProperty("");
	itemStoreNewHeight->SetOptionId(AcedSharedDLL::OPTIONTYPES::HEIGHTOPTION);
	itemStoreNewHeight->SetMenuItemText(std::string("New Height:"));
	if (widestItem < settings->GetFontWidth(itemStoreNewHeight->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNewHeight->GetMenuItemText());
	}
	AddMenuItem(itemStoreNewHeight);




	auto itemStoreSave = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreSave->SetId(AcedSharedDLL::STATES::SAVE);
	itemStoreSave->SetMenuItemText(std::string("Save"));
	if (widestItem < settings->GetFontWidth(itemStoreSave->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreSave->GetMenuItemText());
	}
	AddMenuItem(itemStoreSave);

	auto itemStoreReturn = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreReturn->SetId(AcedSharedDLL::STATES::RETURN);
	itemStoreReturn->SetMenuItemText(std::string("Return"));
	if (widestItem < settings->GetFontWidth(itemStoreReturn->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreReturn->GetMenuItemText());
	}
	AddMenuItem(itemStoreReturn);

	widestItem += (AcedSharedDLL::Constants::TileSize() * 4);

	SetMenuX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuY(100);

	SetMenuHeaderX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuHeaderY(50 + AcedSharedDLL::Constants::TileSize());
	SetMenuHeaderHeight(50 - AcedSharedDLL::Constants::TileSize());

	int i = 0;
	int xloc = settings->GetScreenWidth() / 2;
	int yloc = 100 + AcedSharedDLL::Constants::TileSize();
	int yspacing = AcedSharedDLL::Constants::TileSize() * 2;

	auto menuSize = GetMenuItems().size();
	for (i = 0; i < menuSize; i++)
	{
		GetMenuItems()[i]->SetMenuItemX(xloc);
		GetMenuItems()[i]->SetMenuItemPropertyX(xloc + (settings->GetFontWidth(GetMenuItems()[i]->GetMenuItemText()) / 2) + (AcedSharedDLL::Constants::TileSize() * 1));
		GetMenuItems()[i]->SetMenuItemY(yloc);
		yloc = yloc + yspacing;
	}

	SetMenuWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeaderWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeight(yloc - GetMenuY());

	SetCurrentSelection();
}
Ejemplo n.º 2
0
	void MenuEditor::InitMenu(){
		SetFont(al_load_font("arial.ttf", 30, 0));

		SetMenuHeader("Editor Menu");
		SetId(STATES::EDITORMAINMENU);
		
		MenuItem* itemStore = new MenuItem;
		itemStore->SetId(STATES::RETURN);
		itemStore->SetMenuItemText("Return");
		AddMenuItem(itemStore);

		itemStore = new MenuItem;
		itemStore->SetId(STATES::NEW);
		itemStore->SetMenuItemText("New Map");
		AddMenuItem(itemStore);

		itemStore = new MenuItem;
		itemStore->SetId(STATES::SAVE);
		itemStore->SetMenuItemText("Save Map");
		AddMenuItem(itemStore);

		itemStore = new MenuItem;
		itemStore->SetId(STATES::LOAD);
		itemStore->SetMenuItemText("Load Map");
		AddMenuItem(itemStore);

		itemStore = new MenuItem;
		itemStore->SetId(STATES::MAPOPTIONS);
		itemStore->SetMenuItemText("Map Options");
		AddMenuItem(itemStore);

		itemStore = new MenuItem;
		itemStore->SetId(STATES::OPTIONS);
		itemStore->SetMenuItemText("Options");
		AddMenuItem(itemStore);

		/*itemStore = new MenuItem;
		itemStore->SetId(STATES::ABOUT);
		itemStore->SetMenuItemText("About");
		AddMenuItem(itemStore);*/
		
	

		itemStore = new MenuItem;
		itemStore->SetId(STATES::MAINMENU);
		itemStore->SetMenuItemText("Quit");
		AddMenuItem(itemStore);


		SetMenuX(300);
		SetMenuY(100);
		SetMenuWidth(250);
		SetMenuHeight(400);
	
		SetMenuHeaderX(300);
		SetMenuHeaderY(50);
		SetMenuHeaderWidth(250);
		SetMenuHeaderHeight(50);

		int i = 0;
		int xloc = 425;
		int yloc = 110;
		int yspacing = 50;
		for(i = 0; i < GetMenuItems().size(); i++)
		{
			//printf("%i\n",yloc);
			GetMenuItems()[i]->SetMenuItemX(xloc);
			GetMenuItems()[i]->SetMenuItemY(yloc);
			yloc = yloc + yspacing;
		}
		SetMenuHeight(yloc-GetMenuY());

		SetCurrentSelection();
	}
Ejemplo n.º 3
0
MenuGameMain::MenuGameMain(std::shared_ptr<Settings> &settings) : Menu((std::shared_ptr<AcedSharedDLL::BaseSettings>)settings) {

	SetMenuHeader(std::string("Game Main Menu"));
	SetId(AcedSharedDLL::STATES::EDITORMAINMENU);
	int widestItem = settings->GetFontWidth(GetMenuHeader());

	auto itemStoreNew = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNew->SetId(AcedSharedDLL::STATES::NEW);
	itemStoreNew->SetMenuItemText(std::string("New Map"));
	if (widestItem < settings->GetFontWidth(itemStoreNew->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNew->GetMenuItemText());
	}
	AddMenuItem(itemStoreNew);


	auto itemStoreLoad = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreLoad->SetId(AcedSharedDLL::STATES::LOAD);
	itemStoreLoad->SetMenuItemText(std::string("Load Map"));
	if (widestItem < settings->GetFontWidth(itemStoreLoad->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreLoad->GetMenuItemText());
	}
	AddMenuItem(itemStoreLoad);

	auto itemStoreEdit = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreEdit->SetId(AcedSharedDLL::STATES::EDITORMAINMENU);
	itemStoreEdit->SetMenuItemText(std::string("Edit Mode"));
	if (widestItem < settings->GetFontWidth(itemStoreEdit->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreEdit->GetMenuItemText());
	}
	AddMenuItem(itemStoreEdit);

	auto itemStoreOptions = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreOptions->SetId(AcedSharedDLL::STATES::OPTIONS);
	itemStoreOptions->SetMenuItemText(std::string("Options"));
	if (widestItem < settings->GetFontWidth(itemStoreOptions->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreOptions->GetMenuItemText());
	}
	AddMenuItem(itemStoreOptions);


	auto itemStoreQuit = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreQuit->SetId(AcedSharedDLL::STATES::QUIT);
	itemStoreQuit->SetMenuItemText(std::string("Quit"));
	if (widestItem < settings->GetFontWidth(itemStoreQuit->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreQuit->GetMenuItemText());
	}
	AddMenuItem(itemStoreQuit);

	widestItem += (AcedSharedDLL::Constants::TileSize() * 4);

	SetMenuX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuY(100);

	SetMenuHeaderX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuHeaderY(50 + AcedSharedDLL::Constants::TileSize());
	SetMenuHeaderHeight(50 - AcedSharedDLL::Constants::TileSize());

	int i = 0;
	int xloc = settings->GetScreenWidth() /2;
	int yloc = 100 + AcedSharedDLL::Constants::TileSize();
	int yspacing = AcedSharedDLL::Constants::TileSize()*2;

	auto menuSize = GetMenuItems().size();
	for (i = 0; i < menuSize; i++)
	{
		GetMenuItems()[i]->SetMenuItemX(xloc);
		GetMenuItems()[i]->SetMenuItemY(yloc);
		yloc = yloc + yspacing;
	}

	SetMenuWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeaderWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeight(yloc - GetMenuY());


	SetCurrentSelection();
}
Ejemplo n.º 4
0
void MenuOptions::InitMenu() {
    SetFont(al_load_font("arial.ttf", 30, 0));

    SetMenuHeader("Options");
    SetId(STATES::EDITOROPTIONS);




    MenuItem* itemStore = new MenuItem;
    itemStore->SetMenuItemText("Current Width:");


    //might need to delete this tempval char array? mmm looks to be in stack so should die when method finishs....
    char tempVal[10];
    sprintf_s(tempVal, "%i", GetSettings()->GetScreenWidth());


    itemStore->InitMenuItemProperty(al_ustr_new(tempVal));
    itemStore->SetMenuItemTargetable(false);
    AddMenuItem(itemStore);





    itemStore = new MenuItem;
    itemStore->InitMenuItemProperty(al_ustr_new(""));
    itemStore->SetOptionId(OPTIONTYPES::WIDTHOPTION);
    itemStore->SetMenuItemText("New Width:");
    AddMenuItem(itemStore);




    itemStore = new MenuItem;
    itemStore->SetMenuItemText("Current Height:");

    sprintf_s(tempVal, "%i", GetSettings()->GetScreenHeight());

    itemStore->InitMenuItemProperty(al_ustr_new(tempVal));
    itemStore->SetMenuItemTargetable(false);
    AddMenuItem(itemStore);






    itemStore = new MenuItem;
    itemStore->InitMenuItemProperty(al_ustr_new(""));
    itemStore->SetOptionId(OPTIONTYPES::HEIGHTOPTION);
    itemStore->SetMenuItemText("New Height:");
    AddMenuItem(itemStore);




    itemStore = new MenuItem;
    itemStore->SetId(STATES::SAVE);
    itemStore->SetMenuItemText("Save");
    AddMenuItem(itemStore);

    itemStore = new MenuItem;
    itemStore->SetId(STATES::RETURN);
    itemStore->SetMenuItemText("Return");
    AddMenuItem(itemStore);



    SetMenuX(200);
    SetMenuY(100);
    SetMenuWidth(400);
    SetMenuHeight(400);

    SetMenuHeaderX(200);
    SetMenuHeaderY(50);
    SetMenuHeaderWidth(400);
    SetMenuHeaderHeight(50);

    int i = 0;
    int xloc = 355;
    int yloc = 110;
    int yspacing = 50;
    for(i = 0; i < GetMenuItems().size(); i++)
    {
        GetMenuItems()[i]->SetMenuItemX(xloc);
        GetMenuItems()[i]->SetMenuItemPropertyX(400+100);
        GetMenuItems()[i]->SetMenuItemY(yloc);
        yloc = yloc + yspacing;
    }
    SetMenuHeight(yloc-GetMenuY());

    SetCurrentSelection();
}