Пример #1
0
void CChatWnd::UpdateFriend(CFriend* toupdate)
{
	if (toupdate->GetLinkedClient().IsLinked()) {
		chatselector->RefreshFriend(GUI_ID(toupdate->GetIP(), toupdate->GetPort()), toupdate->GetName());
	} else {
		// drop Chat session
		chatselector->EndSession(GUI_ID(toupdate->GetIP(), toupdate->GetPort()));
	}
	friendlistctrl->UpdateFriend(toupdate);
}
Пример #2
0
void iwMilitary::Msg_ButtonClick(const unsigned ctrl_id)
{
    switch(ctrl_id)
    {
        default: return;
            // Default button
        case 20:
        {
            WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELP), _(
                "This is where you can make adjustments to all military matters. "
                "The upper value corresponds to the recruiting rate of your army. "
                "The higher it is, the more inhabitants are recruited as soldiers. "
                "Below this is the setting to protect your huts. If this value is "
                "set at maximum, your huts are defended by the strongest unit. To "
                "raise the number of attackers leaving your huts per attack, choose "
                "the next setting. The number of defenders who counter the enemy in "
                "the event of an attack is shown by the fourth display. The final "
                "three values correspond to the occupation of your huts in the "
                "interior, in the center of the country and on its borders.")));

        } break;
        case 21:
        {
            GAMECLIENT.visual_settings.military_settings = GAMECLIENT.default_settings.military_settings;
            UpdateSettings();
            settings_changed = true;
        } break;
    }
}
Пример #3
0
void iwDistribution::Msg_ButtonClick(const unsigned ctrl_id)
{
    if(GAMECLIENT.IsReplayModeOn())
        return;
    switch(ctrl_id)
    {
        default: return;

        case 2:
        {
            WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELP), _(
                "The priority of goods for the individual buildings can be set here. "
                "The higher the value, the quicker the required goods are delivered "
                "to the building concerned.")));

        } break;
            // Default button
        case 10:
        {
            GAMECLIENT.visual_settings.distribution = GAMECLIENT.default_settings.distribution;
            UpdateSettings();
            settings_changed = true;
        } break;
    }
}
Пример #4
0
void CChatWnd::StartSession(CFriend* friend_client, bool setfocus)
{

	if ( !friend_client->GetName().IsEmpty() ) {
		if (setfocus) {
			theApp->amuledlg->SetActiveDialog(CamuleDlg::DT_CHAT_WND, this);
		}
		chatselector->StartSession(GUI_ID(friend_client->GetIP(), friend_client->GetPort()), friend_client->GetName(), true);
	}

	// Check to enable the window controls if needed
	CheckNewButtonsState();	
}
void iwMilitaryBuilding::Msg_ButtonClick(const unsigned int ctrl_id)
{
	switch(ctrl_id)
	{
	case 4: // Hilfe
		{
			WindowManager::inst().Show(new iwHelp(GUI_ID(CGI_HELPBUILDING+building->GetBuildingType()),_(BUILDING_NAMES[building->GetBuildingType()]),
				_(BUILDING_HELP_STRINGS[building->GetBuildingType()])));
		} break;
	case 5: // Gebäude abbrennen
		{
			// Darf das Gebäude abgerissen werden?
			if(!building->IsDemolitionAllowed())
			{
				// Messagebox anzeigen
				DemolitionNotAllowed();
			}
			else
			{
				// Abreißen?
				Close();
				WindowManager::inst().Show(new iwDemolishBuilding(gwv, building));
			}
		} break;
	case 6: // Gold einstellen/erlauben
		{
			if(!GameClient::inst().IsReplayModeOn() && !GameClient::inst().IsPaused())
			{
				// visuell anzeigen
				building->StopGoldVirtual();
				// NC senden
				GAMECLIENT.AddGC(new gc::StopGold(building->GetX(), building->GetY()));
				// anderes Bild auf dem Button
				if(building->IsGoldDisabledVirtual())
					GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 226));
				else
					GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 227));
			}
		} break;
	case 7: // "Gehe Zu Ort"
		{
			gwv->MoveToMapObject(building->GetX(), building->GetY());
		} break;
	}
}
Пример #6
0
void iwBuildingSite::Msg_ButtonClick(const unsigned int ctrl_id)
{
    switch(ctrl_id)
    {
        case 2: // Hilfe
        {
            WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELP),
                                                  _(BUILDING_HELP_STRINGS[buildingsite->GetBuildingType()]) ) );
        } break;
        case 3: // Gebäude abbrennen
        {
            // Abreißen?
            Close();
            WINDOWMANAGER.Show(new iwDemolishBuilding(gwv, buildingsite));
        } break;
        case 4: // "Gehe Zu Ort"
        {
            gwv.MoveToMapPt(buildingsite->GetPos());
        } break;
    }
}
Пример #7
0
/**
 *  
 *
 *  @author OLiver
 */
void iwBuildingSite::Msg_ButtonClick(const unsigned int ctrl_id)
{
	switch(ctrl_id)
	{
	case 2: // Hilfe
		{
			WindowManager::inst().Show(new iwHelp(GUI_ID(CGI_HELPBUILDING + buildingsite->GetBuildingType()),
										_(BUILDING_NAMES[buildingsite->GetBuildingType()]),
										_(BUILDING_HELP_STRINGS[buildingsite->GetBuildingType()]) ) );
		} break;
	case 3: // Gebäude abbrennen
		{
			// Abreißen?
			Close();
			WindowManager::inst().Show(new iwDemolishBuilding(gwv, buildingsite));
		} break;
	case 4: // "Gehe Zu Ort"
		{
			gwv->MoveToMapObject(buildingsite->GetX(), buildingsite->GetY());	
		} break;
	}
}
Пример #8
0
void iwMilitaryBuilding::Msg_ButtonClick(const unsigned int ctrl_id)
{
    switch(ctrl_id)
    {
        case 4: // Hilfe
        {
            WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELPBUILDING + building->GetBuildingType()), _(BUILDING_NAMES[building->GetBuildingType()]),
                                                  _(BUILDING_HELP_STRINGS[building->GetBuildingType()])));
        } break;
        case 5: // Gebäude abbrennen
        {
            // Darf das Gebäude abgerissen werden?
            if(!building->IsDemolitionAllowed())
            {
                // Messagebox anzeigen
                DemolitionNotAllowed();
            }
            else
            {
                // Abreißen?
                Close();
                WINDOWMANAGER.Show(new iwDemolishBuilding(gwv, building));
            }
        } break;
        case 6: // Gold einstellen/erlauben
        {
            if(!GAMECLIENT.IsReplayModeOn() && !GAMECLIENT.IsPaused())
            {
                // visuell anzeigen
                building->ToggleCoinsVirtual();
                // NC senden
                GAMECLIENT.ToggleCoins(building->GetPos());
                // anderes Bild auf dem Button
                if(building->IsGoldDisabledVirtual())
                    GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 226));
                else
                    GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 227));
            }
        } break;
        case 7: // "Gehe Zu Ort"
        {
            gwv->MoveToMapObject(building->GetPos());
        } break;
		case 9: //go to next of same type
		{
			//is there at least 1 other building of the same type?
			if(GAMECLIENT.GetPlayer(building->GetPlayer())->GetMilitaryBuildings().size()>1)
			{
				//go through list once we get to current building -> open window for the next one and go to next location
				for(std::list<nobMilitary*>::const_iterator it=GAMECLIENT.GetPlayer(building->GetPlayer())->GetMilitaryBuildings().begin(); it != GAMECLIENT.GetPlayer(building->GetPlayer())->GetMilitaryBuildings().end(); it++)
				{
					if((*it)->GetX()==building->GetX() && (*it)->GetY()==building->GetY()) //got to current building in the list?
					{
						//close old window, open new window (todo: only open if it isnt already open), move to location of next building
						Close();
						it++;
						if(it == GAMECLIENT.GetPlayer(building->GetPlayer())->GetMilitaryBuildings().end()) //was last entry in list -> goto first												{
							it=GAMECLIENT.GetPlayer(building->GetPlayer())->GetMilitaryBuildings().begin();
						gwv->MoveToMapObject((*it)->GetPos());
						iwMilitaryBuilding* nextscrn=new iwMilitaryBuilding(gwv, gi, (*it));
						nextscrn->Move(x,y);
						WINDOWMANAGER.Show(nextscrn);
						break;
					}
				}
			}
		} break;
		case 10: //send home button (addon)
		{
			GAMECLIENT.SendSoldiersHome(building->GetPos());
		}
		break;
    }
}
Пример #9
0
void iwBuildings::Msg_ButtonClick(const unsigned int ctrl_id)
{	
    if (ctrl_id == 32) // Help button
    {
        WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELP), 
            _("The building statistics window gives you an insight into "
              "the number of buildings you have, by type. The number on "
              "the left is the total number of this type of building "
              "completed, the number on the right shows how many are "
              "currently under construction.")));
        return;
    }

	//no buildings of type complete? -> do nothing
    const GamePlayer& localPlayer = gwv.GetViewer().GetPlayer();
	BuildingCount bc = localPlayer.GetBuildingCount();//-V807
	if(bc.buildings[bts[ctrl_id]] < 1)
		return;

	//military building open first of type if available
	if(ctrl_id < 4)
	{
		for(std::list<nobMilitary*>::const_iterator it=localPlayer.GetMilitaryBuildings().begin(); it != localPlayer.GetMilitaryBuildings().end(); ++it)
		{
			if((*it)->GetBuildingType()==bts[ctrl_id]) // got first of type -> open building window (military)
			{
				gwv.MoveToMapPt((*it)->GetPos());
				iwMilitaryBuilding* nextscrn=new iwMilitaryBuilding(gwv, gcFactory, *it);
				WINDOWMANAGER.Show(nextscrn);
				return;
			}
		}
		return;
	}
	//not warehouse, harbor (military excluded) -> so it is a nobusual!
	if(ctrl_id != 21 && ctrl_id != 31)
	{
		nobUsual* it=*localPlayer.GetBuildings(bts[ctrl_id]).begin();
		gwv.MoveToMapPt(it->GetPos());
		iwBuilding* nextscrn=new iwBuilding(gwv, gcFactory, it);
		WINDOWMANAGER.Show(nextscrn);
		return;
	}
	else if(ctrl_id == 21)//warehouse?
	{
		//go through list until we get to a warehouse
		for(std::list<nobBaseWarehouse*>::const_iterator it=localPlayer.GetStorehouses().begin(); it != localPlayer.GetStorehouses().end(); ++it)
		{
			if((*it)->GetBuildingType()==bts[ctrl_id])
			{
				gwv.MoveToMapPt((*it)->GetPos());
				iwStorehouse* nextscrn=new iwStorehouse(gwv, gcFactory, dynamic_cast<nobStorehouse*>(*it));
				nextscrn->Move(pos_);
				WINDOWMANAGER.Show(nextscrn);
				return;
			}
		}
	}
	else if(ctrl_id==31)//harbor
	{
		//go through list until we get to a harbor
		for(std::list<nobBaseWarehouse*>::const_iterator it=localPlayer.GetStorehouses().begin(); it != localPlayer.GetStorehouses().end(); ++it)
		{
			if((*it)->GetBuildingType()==bts[ctrl_id])
			{
				gwv.MoveToMapPt((*it)->GetPos());
				iwHarborBuilding* nextscrn = new iwHarborBuilding(gwv, gcFactory, dynamic_cast<nobHarborBuilding*>(*it));
				nextscrn->Move(pos_);
				WINDOWMANAGER.Show(nextscrn);
				return;
			}
		}
	}

	
}
Пример #10
0
void iwBaseWarehouse::Msg_ButtonClick(const unsigned int ctrl_id)
{
    switch(ctrl_id)
    {
        case 1: // Gebäude abreißen
        {
            // Abreißen?
            Close();
            WindowManager::inst().Show(new iwDemolishBuilding(gwv, wh));
        } break;
        case 11: // "Alle auswählen"
        {
            if(this->page < 2)
            {
                ctrlOptionGroup* optiongroup = GetCtrl<ctrlOptionGroup>(10);
                unsigned int data = 0;
                switch(optiongroup->GetSelection())
                {
                    case 0: data = 8; break;
                    case 1: data = 4; break;
                    case 2: data = 2; break;
                }
                if(data != 0)
                {
                    // Nicht bei Replays setzen
                    if(GAMECLIENT.AddGC(new gc::ChangeAllInventorySettings(wh->GetX(), wh->GetY(), page, data)))
                    {
                        // optisch setzen
                        unsigned short count = ((page == 0) ? WARE_TYPES_COUNT : JOB_TYPES_COUNT);
                        for(unsigned char i = 0; i < count; ++i)
                            ChangeOverlay(i, data);
                    }
                }

            }
        } break;
        case 12: // "Hilfe"
        {
            WindowManager::inst().Show(new iwHelp(GUI_ID(CGI_HELPBUILDING + wh->GetBuildingType()), _(BUILDING_NAMES[wh->GetBuildingType()]),
                                                  _(BUILDING_HELP_STRINGS[wh->GetBuildingType()])));
        } break;
        case 13: // "Gehe Zu Ort"
        {
            gwv->MoveToMapObject(wh->GetX(), wh->GetY());
        } break;
		case 14: //go to next of same type
		{
			//is there at least 1 other building of the same type?
			if(GameClient::inst().GetPlayer(wh->GetPlayer())->GetStorehouses().size()>1)
			{
				//go through list once we get to current building -> open window for the next one and go to next location
				for(std::list<nobBaseWarehouse*>::const_iterator it=GameClient::inst().GetPlayer(wh->GetPlayer())->GetStorehouses().begin(); it != GameClient::inst().GetPlayer(wh->GetPlayer())->GetStorehouses().end(); it++)
				{
					if((*it)->GetX()==wh->GetX() && (*it)->GetY()==wh->GetY()) //got to current building in the list?
					{
						//close old window, open new window (todo: only open if it isnt already open), move to location of next building
						Close();
						it++;
						if(it == GameClient::inst().GetPlayer(wh->GetPlayer())->GetStorehouses().end()) //was last entry in list -> goto first												{
							it=GameClient::inst().GetPlayer(wh->GetPlayer())->GetStorehouses().begin();
						gwv->MoveToMapObject((*it)->GetX(),(*it)->GetY());
						if((*it)->GetBuildingType()==BLD_HEADQUARTERS)
						{
							iwHQ* nextscrn=new iwHQ(gwv, gi, (*it),_("Headquarters"), 3);
							nextscrn->Move(x,y);
							WindowManager::inst().Show(nextscrn);
						}
						else if((*it)->GetBuildingType()==BLD_HARBORBUILDING)
						{
							iwHarborBuilding* nextscrn = new iwHarborBuilding(gwv,gi,dynamic_cast<nobHarborBuilding*>((*it)));
							nextscrn->Move(x,y);
							WindowManager::inst().Show(nextscrn);
						}
						else if((*it)->GetBuildingType()==BLD_STOREHOUSE) 
						{
							iwStorehouse* nextscrn=new iwStorehouse(gwv,gi,dynamic_cast<nobStorehouse*>((*it)));
							nextscrn->Move(x,y);
							WindowManager::inst().Show(nextscrn);
						}
						break;
					}
				}
			}
		} break;
        default: // an Basis weiterleiten
        {
            iwWares::Msg_ButtonClick(ctrl_id);
        } break;
    }
}
Пример #11
0
void iwPostWindow::Msg_ButtonClick(const unsigned ctrl_id)
{
    switch(ctrl_id)
    {
        case ID_HELP:
            WINDOWMANAGER.Show(
              std::make_unique<iwHelp>(GUI_ID(CGI_HELP), _("All important messages are collected in this window and "
                                                           "sorted into groups. If this window is not open, the dove "
                                                           "symbol at the bottom of the screen indicates the arrival of a new message.")));
            break;
        case ID_SHOW_ALL:
            showAll = true;
            FilterMessages();
            curMsgId = curMsgIdxs.size();
            DisplayPostMessage();
            break;
        case ID_SHOW_GOAL:
            if(!postBox.GetCurrentMissionGoal().empty())
                WINDOWMANAGER.Show(
                  std::make_unique<iwMissionStatement>(_("Diary"), postBox.GetCurrentMissionGoal(), false, iwMissionStatement::IM_AVATAR9));
            break;
        case ID_SHOW_MIL: SwitchCategory(PostCategory::Military); break;
        case ID_SHOW_GEO: SwitchCategory(PostCategory::Geologist); break;
        case ID_SHOW_ECO: SwitchCategory(PostCategory::Economy); break;
        case ID_SHOW_GEN: SwitchCategory(PostCategory::General); break;
        case ID_GO_START:
            // To oldest
            curMsgId = 0;
            DisplayPostMessage();
            break;
        case ID_GO_BACK:
            // Back
            curMsgId = (curMsgId > 0) ? curMsgId - 1 : 0;
            DisplayPostMessage();
            break;
        case ID_GO_FWD:
            // Forward
            ++curMsgId;
            DisplayPostMessage();
            break;
        case ID_GO_END:
            // To newest
            curMsgId = postBox.GetNumMsgs();
            DisplayPostMessage();
            break;
        case ID_GOTO:
        {
            // Goto
            if(!ValidateMessages())
                return;
            if(curMsg && curMsg->GetPos().isValid())
                gwv.MoveToMapPt(curMsg->GetPos());
        }
        break;

        case ID_DELETE: // Delete
        case ID_DENY:   // Cross (Deny)
        {
            if(!ValidateMessages() || !curMsg)
                return;
            const auto* dcurMsg = dynamic_cast<const DiplomacyPostQuestion*>(curMsg);
            if(dcurMsg)
            {
                // If it is a question about a new contract, tell the other player we denied it
                if(dcurMsg->IsAccept())
                    GAMECLIENT.CancelPact(dcurMsg->GetPactType(), dcurMsg->GetPlayerId());
            }
            postBox.DeleteMsg(curMsg);
        }
        break;

        // Haken-Button ("Ja")
        case ID_ACCEPT:
        {
            if(!ValidateMessages())
                return;
            const auto* dcurMsg = dynamic_cast<const DiplomacyPostQuestion*>(GetMsg(curMsgId));
            if(dcurMsg)
            {
                // New contract?
                if(dcurMsg->IsAccept())
                    GAMECLIENT.AcceptPact(dcurMsg->GetPactId(), dcurMsg->GetPactType(), dcurMsg->GetPlayerId());
                else
                    GAMECLIENT.CancelPact(dcurMsg->GetPactType(), dcurMsg->GetPlayerId());
                postBox.DeleteMsg(dcurMsg);
            }
        }
        break;
    }
}
Пример #12
0
void iwBuilding::Msg_ButtonClick(const unsigned int ctrl_id)
{
    switch(ctrl_id)
    {
        case 4: // Hilfe
        {
            WINDOWMANAGER.Show(new iwHelp(GUI_ID(CGI_HELP), _(BUILDING_HELP_STRINGS[building->GetBuildingType()])));
        } break;
        case 5: // Gebäude abbrennen
        {
            // Abreißen?
            Close();
            WINDOWMANAGER.Show(new iwDemolishBuilding(gwv, building));
        } break;
        case 6:
        {
            // Produktion einstellen/fortführen
            // NC senden
            if(gcFactory.SetProductionEnabled(building->GetPos(), building->IsProductionDisabledVirtual()))
            {
                // visuell anzeigen, falls erfolgreich
                building->ToggleProductionVirtual();

                // anderes Bild auf dem Button
                if(building->IsProductionDisabledVirtual())
                    GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 197));
                else
                    GetCtrl<ctrlImageButton>(6)->SetImage(LOADER.GetImageN("io", 196));

                ctrlText* text = GetCtrl<ctrlText>(10);
                if(building->IsProductionDisabledVirtual() && building->HasWorker())
                    text->SetText(_("(House unoccupied)"));
                else if(building->HasWorker())
                    text->SetVisible(false);
            }

        } break;
        case 7: // "Gehe Zum Ort"
        {
            gwv.MoveToMapPt(building->GetPos());
        } break;
        case 11: // Schiff/Boot umstellen bei Schiffsbauer
        {
            if(gcFactory.ToggleShipYardMode(building->GetPos()))
            {
                // Auch optisch den Button umstellen
                ctrlImageButton* button = GetCtrl<ctrlImageButton>(11);
                if(button->GetButtonImage() == LOADER.GetImageN("io", IODAT_BOAT_ID))
                    button->SetImage(LOADER.GetImageN("io", IODAT_SHIP_ID));
                else
                    button->SetImage(LOADER.GetImageN("io", IODAT_BOAT_ID));
            }

        } break;
		case 12: //go to next of same type
		{
            const std::list<nobUsual*>& buildings = gwv.GetWorld().GetPlayer(building->GetPlayer()).GetBuildings(building->GetBuildingType());
			//go through list once we get to current building -> open window for the next one and go to next location
			for(std::list<nobUsual*>::const_iterator it=buildings.begin(); it != buildings.end(); ++it)
			{
				if((*it)->GetPos()==building->GetPos()) //got to current building in the list?
				{
					//close old window, open new window (todo: only open if it isnt already open), move to location of next building
					Close();
					++it;
					if(it == buildings.end()) //was last entry in list -> goto first
						it=buildings.begin();
					gwv.MoveToMapPt((*it)->GetPos());
					iwBuilding* nextscrn=new iwBuilding(gwv, gcFactory, *it);
					nextscrn->Move(x_,y_);
					WINDOWMANAGER.Show(nextscrn);
					break;
				}
			}
		} break;
    }
}
Пример #13
0
void CChatWnd::RemoveFriend(CFriend* todel)
{
	chatselector->EndSession(GUI_ID(todel->GetIP(), todel->GetPort()));
	friendlistctrl->RemoveFriend(todel);
}