示例#1
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();
	}
示例#2
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();
}