Esempio n. 1
0
bool CInterfaceUnit::AddButtonToSlot(CButton* pButton, int mX, int mY)
{
	//Only Items Can Be Added To Equpment
 //   if(pButton->GetButtonClass() != BUTTONCLASS_ITEM)
	//{
	//	if(CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW])
	//		CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW]->AddMsg("Mozes Dodac Do Equip Tylko Item");

 //       return false;
	//}

    //For bag slots
    for(int x = 0; x < SLOT_MAX_X; ++x) 
    {   
        for(int y = 0; y < SLOT_MAX_Y; ++y) 
        {   
            if( ( mX > nPosX + 170 + x*30) && ( mX < nPosX + 170 + x*30 + SLOT_W_H) && ( mY > nPosY + 40 + y*30 ) && ( mY < nPosY + 40 + y*30 + SLOT_W_H) )
            {      
                //ToDo: Need to check if on slot is any other button delete this button and add new button
                if(CButton *Button = GetButton(mX, mY))
                    if(Button != NULL)
                        CInterface::DeleteButtonFromSlot(Button);
				
				int nX = nPosX + 170 + x*30;
				int nY = nPosY + 40 + y*30;

				//Check If Button Is Already In Same Interface Just Change Place
				//Prevent Double Add 1 Button to Button List
				for(int i = 0;i < ButtonsList.size();i++) 
				{   
					if(!ButtonsList[i]) continue;
					if(ButtonsList[i] == pButton)
					{
						pButton->SetPositionX(nX);
						pButton->SetPositionY(nY);
						return true;
					}
				}

				//If Slot Is Empty We SetUp Porper Coordinates To Button
				CButton* pButtonShortcut = new CButtonShortcut(pButton);

				if(CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW])
					CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW]->AddMsg("DEBUG: Stworzono Shortcut Do Buttona");

                pButtonShortcut->SetPositionX(nX);
                pButtonShortcut->SetPositionY(nY);

                if(pButtonShortcut->OnLoad() == false)
					return false;

                ButtonsList.push_back(pButtonShortcut);
				if(CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW])
					CInterfaceMenager::InterfaceMenager.InterfaceList[INTERFACE_MASAGEWINDOW]->AddMsg("DEBUG: Dodano Shortcut do Listy butonow Interfacu");
                return false;
            }
        }
    }

	return false;
}
Esempio n. 2
0
void CInterface::LoadButtons()
{
    ButtonType eType = BUTTON_DEFAULT;

    int x = 0;
	int y = 0;

    switch(eInterfaceType)
    {
        case INTERFACE_MAINMENU:
		{
			for(int i=0; i<3; ++i)
			{
				switch(i)
				{
					case 0: eType = BUTTON_PLAY; break;
					case 1: eType = BUTTON_QUIT; break;
                    case 2: eType = BUTTON_MENU_CREATECHARACTER; break;
                    default: break;
				}
					
                x = nPosX + 640;
                y = nPosY + 300 + i*40;

				CButton *pButton = new CButton(x, y, eType);

                if(pButton->OnLoad() == false)
					return;

				ButtonsList.push_back(pButton);
			}

			break;
		}

        case INTERFACE_GAMEMENU:
        {
            for(int i=0; i<2; ++i)
            {
                switch(i)
                {
                    case 0: eType = BUTTON_GAMEMENU_QUIT; break;
                    case 1: eType = BUTTON_GAMEMENU_RETURN; break;
                    default: break;
                }

                x = nPosX + 100;
                y = nPosY + 100 + i*40;

				CButton *pButton = new CButton(x, y, eType);

                if(pButton->OnLoad() == false)
                    break;

                ButtonsList.push_back(pButton);
            }

            break;
        }

        case INTERFACE_CHARACTERPANEL:
        {
            for(int i=0; i<5; ++i)
            {
                switch(i)
                {
                    case 0: eType = BUTTON_CHARPANEL_CHARSHEET; break;
                    case 1: eType = BUTTON_CHARPANEL_EQUIPMENT; break;
                    case 2: eType = BUTTON_CHARPANEL_SPELLBOOK; break;
                    case 3: eType = BUTTON_CHARPANEL_QUESTDIARY; break;
                    case 4: eType = BUTTON_CHARPANEL_GAMEMENU; break;
                }

                x = nPosX + 5 + i * 33;
                y = nPosY + 5;

				CButton *pButton = new CButton(x, y, eType);

                if(pButton->OnLoad() == false)
                    break;
 
                ButtonsList.push_back(pButton);
            }

            break;
        }

        case INTERFACE_EQUIP:
		{
			for(int i=0; i<1; ++i)
			{
				switch(i)
				{
					case 0: eType = BUTTON_EQUIPMENT_QUIT; x = nPosX + nWidht - 30; y = nPosY; break;

                    default: break;
				}
					
                CButton *pButton = new CButton(x, y, eType);

				if(pButton->OnLoad() == false)
                    break;

                ButtonsList.push_back(pButton);
			}

			break;
		}

        case INTERFACE_LOOT:
        {
            for(int i=0; i<2; ++i)
            {
                switch(i)
                {
                    case 0: eType = BUTTON_LOOT_QUIT; x = nPosX + INTERFACE_LOOT_W_H - 30; y = nPosY; break;
                    case 1: eType = BUTTON_LOOT_LOOTALL; x = nPosX; y = nPosY + INTERFACE_LOOT_W_H - 30; break;
                    default: break;
                }

                CButton *pButton = new CButton(x, y, eType);

                if(pButton->OnLoad() == false)
                    break;

                ButtonsList.push_back(pButton);
            }
            break;
        }

        case INTERFACE_SPELLBOOK:
        {
            for(int i=0; i<1; ++i)
            {
                switch(i)
                {
                    case 0: eType = BUTTON_SPELLBOOK_QUIT; x = nPosX + INTERFACE_SPELLBOOK_W - 30; y = nPosY; break;

                    default: break;
                }

                CButton *pButton = new CButton(x, y, eType);

                if(pButton->OnLoad() == false)
                    break;

                ButtonsList.push_back(pButton);
            }
            break;
        }

        default: break;
    }
}