From 28af2e03fc5fde73a82fbe5865beda786ea8ae66 Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Fri, 15 Nov 2019 22:23:12 +0100 Subject: [PATCH 1/7] remove double+ new lines: https://unix.stackexchange.com/a/12813 cat -s ./ctp2_code/ui/interface/diplomacywindow.cpp > ./ctp2_code/ui/interface/diplomacywindow.cpp_ mv ./ctp2_code/ui/interface/diplomacywindow.cpp_ ./ctp2_code/ui/interface/diplomacywindow.cpp cat -s ctp2_code/ui/interface/intelligencewindow.cpp > ctp2_code/ui/interface/intelligencewindow.cpp_ mv ctp2_code/ui/interface/intelligencewindow.cpp_ ctp2_code/ui/interface/intelligencewindow.cpp --- ctp2_code/ui/interface/diplomacywindow.cpp | 1300 +---------------- ctp2_code/ui/interface/intelligencewindow.cpp | 75 - 2 files changed, 49 insertions(+), 1326 deletions(-) diff --git a/ctp2_code/ui/interface/diplomacywindow.cpp b/ctp2_code/ui/interface/diplomacywindow.cpp index ab03ba842..a618ea081 100644 --- a/ctp2_code/ui/interface/diplomacywindow.cpp +++ b/ctp2_code/ui/interface/diplomacywindow.cpp @@ -109,10 +109,6 @@ DiplomacyWindow::DiplomacyWindow(AUI_ERRCODE *err) return; } - - - - m_goldRequestWindow = NULL; m_pollutionRequestWindow = NULL; m_percentRequestWindow = NULL; @@ -128,46 +124,6 @@ DiplomacyWindow::DiplomacyWindow(AUI_ERRCODE *err) aui_Ldl::SetActionFuncAndCookie(s_dipWindowBlock, "CloseButton", DiplomacyWindow::Close, NULL); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sm_messageButton = (ctp2_Button *)aui_Ldl::GetObject(s_dipWindowBlock, "DiplomacyTabs.Intelligence.TabPanel.MessageButton"); sm_messageButton->SetActionFuncAndCookie(SendMessage, NULL); sm_messageButton->Enable(FALSE); @@ -184,11 +140,6 @@ DiplomacyWindow::DiplomacyWindow(AUI_ERRCODE *err) sm_detailsButton->SetActionFuncAndCookie(Details, NULL); sm_detailsButton->Enable(FALSE); - - - - - SetSendProposal(-1); *err = AUI_ERRCODE_OK; @@ -292,14 +243,6 @@ AUI_ERRCODE DiplomacyWindow::Display() EnableButtons(FALSE); - - - - - - - - } return err; @@ -308,9 +251,6 @@ AUI_ERRCODE DiplomacyWindow::Display() AUI_ERRCODE DiplomacyWindow::Hide() { - - - if(!s_dipWindow) return AUI_ERRCODE_OK; @@ -326,21 +266,6 @@ void DiplomacyWindow::GotoTab(sint32 tabIndex) { Assert(FALSE); - - - - - - - - - - - - - - - } bool DiplomacyWindow::IsShown() @@ -360,16 +285,6 @@ bool DiplomacyWindow::IsShown() void DiplomacyWindow::ShowInitialSections() { - - - - - - - - - - } void DiplomacyWindow::ShowSection(MBCHAR *section, bool show) @@ -388,97 +303,6 @@ void DiplomacyWindow::ShowSection(MBCHAR *section, bool show) void DiplomacyWindow::ShowSections(uint32 sections) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Update(); } @@ -490,49 +314,6 @@ void DiplomacyWindow::Update() return; updating = true; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ctp2_ListBox *intList = (ctp2_ListBox *)aui_Ldl::GetObject(s_dipWindowBlock, "DiplomacyTabs.Intelligence.TabPanel.List"); Assert(intList); if(intList) { @@ -583,23 +364,6 @@ void DiplomacyWindow::UpdateProposalList(ctp2_ListBox *propList, bool toPlayer) prop = &Diplomat::GetDiplomat(i).GetMyLastNewProposal(player); - - - - - - - - - - - - - - - - - if(*prop == Diplomat::s_badNewProposal) continue; @@ -630,16 +394,6 @@ void DiplomacyWindow::UpdateProposalList(ctp2_ListBox *propList, bool toPlayer) if(*prop == Diplomat::s_badNewProposal) continue; - - - - - - - - - - propData = prop->detail; } @@ -805,579 +559,41 @@ void DiplomacyWindow::GetProposalSummary(const ProposalData &prop, void DiplomacyWindow::UpdateProposalsReceived() { - } void DiplomacyWindow::UpdateProposalsMade() { - } void DiplomacyWindow::UpdateProposalDetails() { +} +void DiplomacyWindow::UpdateCreateList() +{ +} +void DiplomacyWindow::UpdateSendProposalDetails() +{ +} +void DiplomacyWindow::SetViewingResponse(sint32 sender, sint32 receiver) +{ + m_viewResponseSender = sender; + m_viewResponseReceiver = receiver; +} +void DiplomacyWindow::UpdateResponseDetails() +{ +} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::UpdateCreateList() -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::UpdateSendProposalDetails() -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::SetViewingResponse(sint32 sender, sint32 receiver) -{ - m_viewResponseSender = sender; - m_viewResponseReceiver = receiver; -} - -void DiplomacyWindow::UpdateResponseDetails() -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::UpdateThreatList() -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DiplomacyWindow::UpdateThreatList() +{ } @@ -1388,7 +604,6 @@ StringId DiplomacyWindow::GetProposalText(sint32 proposal, DIPLOMATIC_TONE tone, if(!rec) return 0; - if(useReciprocal) { sint32 recipIndex; @@ -1475,7 +690,6 @@ StringId DiplomacyWindow::GetProposalSummaryText(sint32 proposal, DIPLOMATIC_TON if(!rec) return 0; - if(useReciprocal) { sint32 recipIndex; @@ -1499,9 +713,6 @@ bool DiplomacyWindow::AddProposalData(SlicObject &so, sint32 proposal, Diplomacy if(!rec) return false; - - - switch(rec->GetArg1()) { case k_DiplomacyProposal_Arg1_OwnCity_Bit: case k_DiplomacyProposal_Arg1_HisCity_Bit: @@ -1590,20 +801,6 @@ void DiplomacyWindow::Close(aui_Control *control, uint32 action, uint32 data, vo { if(action != AUI_BUTTON_ACTION_EXECUTE) return; - - - - - - - - - - - - - - DiplomacyWindow::Hide(); } @@ -1620,230 +817,55 @@ void DiplomacyWindow::ProposalsReceived(aui_Control *control, uint32 action, uin void DiplomacyWindow::ShowReceivedProposalDetails() { +} +void DiplomacyWindow::Respond(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ + if(action != AUI_BUTTON_ACTION_EXECUTE) return; + Assert(s_dipWindow); + if(s_dipWindow) { + s_dipWindow->ShowReceivedProposalDetails(); + } +} +void DiplomacyWindow::Respond(RESPONSE_TYPE disposition) +{ +} +void DiplomacyWindow::Accept(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ +} +void DiplomacyWindow::Reject(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ +} +void DiplomacyWindow::Counter(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ +} +void DiplomacyWindow::Create(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ +} +void DiplomacyWindow::SendProposal() +{ +} +void DiplomacyWindow::SendCounter() +{ +} - - - - - - - - -} - -void DiplomacyWindow::Respond(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - if(action != AUI_BUTTON_ACTION_EXECUTE) return; - - Assert(s_dipWindow); - if(s_dipWindow) { - s_dipWindow->ShowReceivedProposalDetails(); - } -} - -void DiplomacyWindow::Respond(RESPONSE_TYPE disposition) -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::Accept(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - - - - - - -} - -void DiplomacyWindow::Reject(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - - - - - - -} - -void DiplomacyWindow::Counter(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::Create(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - - - - - - - - - - - - - - - - -} - -void DiplomacyWindow::SendProposal() -{ - - - - - - - - - - - - -} - -void DiplomacyWindow::SendCounter() -{ - - - - - - - - - - - - - -} - -void DiplomacyWindow::Send(aui_Control *control, uint32 action, uint32 data, void *cookie) -{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DiplomacyWindow::Send(aui_Control *control, uint32 action, uint32 data, void *cookie) +{ } @@ -1968,9 +990,6 @@ STDEHANDLER(DipWinNewNegotiationEvent) void DiplomacyWindow::InitializeEvents() { - - - } void DiplomacyWindow::CleanupEvents() @@ -1980,7 +999,6 @@ void DiplomacyWindow::CleanupEvents() void DiplomacyWindow::Civ(aui_Control *control, uint32 action, uint32 data, void *cookie) { - } AUI_ERRCODE DiplomacyWindow::DrawCivColor(ctp2_Static *control, aui_Surface *surface, RECT &rect, void *cookie ) @@ -2001,85 +1019,26 @@ AUI_ERRCODE DiplomacyWindow::DrawCivColor(ctp2_Static *control, aui_Surface *sur void DiplomacyWindow::Tone(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - } void DiplomacyWindow::Request(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - - - - - - - - - } void DiplomacyWindow::Treaty(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - - - - - - - - - } void DiplomacyWindow::Gift(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - - - - - - - - - } void DiplomacyWindow::Exchange(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - } class DiplomacyWindowChangeModeAction : public aui_Action @@ -2105,133 +1064,16 @@ void DiplomacyWindowChangeModeAction::Execute(aui_Control *control, uint32 data) { - - - } void DiplomacyWindow::CreateList(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } void DiplomacyWindow::ClearForm(aui_Control *control, uint32 action, uint32 data, void *cookie) { - - - - - - - - - - - } void DiplomacyWindow::AddCityItems(ctp2_Menu *menu, sint32 player) @@ -2434,11 +1276,6 @@ bool DiplomacyWindow::ProposalContextMenu(sint32 proposal) AddAdvanceItems(m_curMenu, m_sendToCiv, g_selected_item->GetVisiblePlayer()); break; - - - - - case k_DiplomacyProposal_Arg1_OwnUnitType_Bit: break; @@ -2567,11 +1404,6 @@ void DiplomacyWindow::ProcessMenuSelection(sint32 itemIndex, void *cookie) void DiplomacyWindow::ProcessMenuCancel() { - - - - - } void DiplomacyWindow::MenuCallback(ctp2_Menu *menu, CTP2_MENU_ACTION action, sint32 itemIndex, void *cookie) @@ -2634,7 +1466,6 @@ void DiplomacyWindow::GoldCancel(aui_Control *control, uint32 action, uint32 dat g_c3ui->RemoveWindow(s_dipWindow->m_goldRequestWindow->Id()); } - s_dipWindow->ProcessMenuCancel(); } @@ -2673,7 +1504,6 @@ void DiplomacyWindow::PollutionCancel(aui_Control *control, uint32 action, uint3 g_c3ui->RemoveWindow(s_dipWindow->m_pollutionRequestWindow->Id()); } - s_dipWindow->ProcessMenuCancel(); } @@ -2712,7 +1542,6 @@ void DiplomacyWindow::PercentCancel(aui_Control *control, uint32 action, uint32 g_c3ui->RemoveWindow(s_dipWindow->m_percentRequestWindow->Id()); } - s_dipWindow->ProcessMenuCancel(); } @@ -2990,7 +1819,6 @@ void DiplomacyWindow::SendThreat() response.threat.type = diplomacyutil_GetThreatType(m_sendThreat); response.threat.arg = m_threatArg; - Diplomat::GetDiplomat(m_viewResponseSender).ExecuteResponse(response); } @@ -3099,36 +1927,6 @@ void DiplomacyWindow::SetSendProposal(sint32 prop) void DiplomacyWindow::EnableRequests(bool enable) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } void DiplomacyWindow::DeclareWar(aui_Control *control, uint32 action, uint32 data, void *cookie) diff --git a/ctp2_code/ui/interface/intelligencewindow.cpp b/ctp2_code/ui/interface/intelligencewindow.cpp index 9ffebc902..8530a1f7c 100644 --- a/ctp2_code/ui/interface/intelligencewindow.cpp +++ b/ctp2_code/ui/interface/intelligencewindow.cpp @@ -74,7 +74,6 @@ static MBCHAR *s_intelligenceBlock = "IntelligenceWindow"; static MBCHAR *s_intelligenceAdviceBlock = "IntelligenceAdvice"; ctp2_ListBox *IntelligenceWindow::sm_list = NULL; - aui_StringTable *IntelligenceWindow::sm_strengthImages = NULL; aui_StringTable *IntelligenceWindow::sm_embassyImages = NULL; @@ -120,7 +119,6 @@ IntelligenceWindow::IntelligenceWindow(AUI_ERRCODE *err) InitImageTables(); } - } IntelligenceWindow::~IntelligenceWindow() @@ -429,14 +427,6 @@ AUI_ERRCODE IntelligenceWindow::DrawPlayerRegard(ctp2_Static *control, char **toneIcons = DiplomacyWindow::GetToneIcons(); sint32 p = (sint32)cookie; - - - - - - - - switch(GetRegardThreshold(p, g_selected_item->GetVisiblePlayer())) { case HOTWAR_REGARD: imageName = toneIcons[DIPLOMATIC_TONE_ANGRY]; break; case COLDWAR_REGARD: imageName = toneIcons[DIPLOMATIC_TONE_INDIGNANT]; break; @@ -489,13 +479,6 @@ AUI_ERRCODE IntelligenceWindow::DrawPlayerStrength(ctp2_Static *control, if(!g_player[p]) return AUI_ERRCODE_OK; if(!g_player[g_selected_item->GetVisiblePlayer()]) return AUI_ERRCODE_OK; - - - - - - - DIPLOMATIC_STRENGTH relativeStrength = g_player[p]->GetRelativeStrength(g_selected_item->GetVisiblePlayer()); if(!sm_strengthImages) { @@ -654,61 +637,6 @@ AUI_ERRCODE IntelligenceWindow::DrawTreaties(ctp2_Static *control, return AUI_ERRCODE_OK; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void IntelligenceWindow::InitImageTables() { AUI_ERRCODE err; @@ -737,9 +665,6 @@ void IntelligenceWindow::SelectItem(aui_Control *control, uint32 action, uint32 DiplomacyWindow::EnableButtons( TRUE, (sint32)item->GetUserData() ); } - - - } void intelligence_DeclareWarCallback(bool response, void *cookie) From e42dbac5365e40b72ec73d9860e7491750937f7c Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Fri, 15 Nov 2019 22:27:20 +0100 Subject: [PATCH 2/7] corr. indentation (emacs ^qc) --- ctp2_code/ui/interface/intelligencewindow.cpp | 223 +++++++++--------- 1 file changed, 110 insertions(+), 113 deletions(-) diff --git a/ctp2_code/ui/interface/intelligencewindow.cpp b/ctp2_code/ui/interface/intelligencewindow.cpp index 8530a1f7c..92bd0087e 100644 --- a/ctp2_code/ui/interface/intelligencewindow.cpp +++ b/ctp2_code/ui/interface/intelligencewindow.cpp @@ -246,90 +246,90 @@ void IntelligenceWindow::SetRegardTip(MBCHAR *buf, const sint32 player, const si } void IntelligenceWindow::Update(ctp2_ListBox *theList) -{ + { PLAYER_INDEX visPl = g_selected_item->GetVisiblePlayer(); - Assert(g_player[visPl]); - if(!g_player[visPl]) return; + Assert(g_player[visPl]); + if(!g_player[visPl]) return; - theList->Clear(); - theList->SetAbsorbancy(FALSE); - sm_list = theList; + theList->Clear(); + theList->SetAbsorbancy(FALSE); + sm_list = theList; - for (sint32 p = 1; p < k_MAX_PLAYERS; p++) - { - if (p == visPl) continue; - if (!g_player[visPl]->HasContactWith(p)) continue; + for (sint32 p = 1; p < k_MAX_PLAYERS; p++) + { + if (p == visPl) continue; + if (!g_player[visPl]->HasContactWith(p)) continue; - ctp2_ListItem * item = + ctp2_ListItem * item = (ctp2_ListItem *)aui_Ldl::BuildHierarchyFromRoot("IntelligenceListItem"); - Assert(item); - if (!item) break; - - if (ctp2_Static * flag = (ctp2_Static *) item->GetChildByIndex(k_INT_FLAG_COL)) - { - flag->SetDrawCallbackAndCookie(DrawPlayerFlag, (void *)p, false); - flag->SetActionFuncAndCookie(SelectItem, item); - } - - if (ctp2_Static * nation = (ctp2_Static *)item->GetChildByIndex(k_INT_NATION_COL)) - { - MBCHAR buf[k_MAX_NAME_LEN]; + Assert(item); + if (!item) break; + + if (ctp2_Static * flag = (ctp2_Static *) item->GetChildByIndex(k_INT_FLAG_COL)) + { + flag->SetDrawCallbackAndCookie(DrawPlayerFlag, (void *)p, false); + flag->SetActionFuncAndCookie(SelectItem, item); + } + + if (ctp2_Static * nation = (ctp2_Static *)item->GetChildByIndex(k_INT_NATION_COL)) + { + MBCHAR buf[k_MAX_NAME_LEN]; g_player[p]->GetCivilisation()->GetCountryName(buf); - nation->SetText(buf); - nation->SetActionFuncAndCookie(SelectItem, item); + nation->SetText(buf); + nation->SetActionFuncAndCookie(SelectItem, item); + } + + if (ctp2_Static * regard = (ctp2_Static *)item->GetChildByIndex(k_INT_REGARD_COL)) + { + regard->SetDrawCallbackAndCookie(DrawPlayerRegard, (void *)p, true); + MBCHAR buf[k_MAX_NAME_LEN]; + SetRegardTip(buf, p, visPl); + ((aui_TipWindow *)regard->GetTipWindow())->SetTipText(buf); + regard->SetActionFuncAndCookie(SelectItem, item); + } + + if (ctp2_Static * strength = (ctp2_Static *)item->GetChildByIndex(k_INT_STRENGTH_COL)) + { + strength->SetDrawCallbackAndCookie(DrawPlayerStrength, (void *)p, true); + MBCHAR buf[k_MAX_NAME_LEN]; + DIPLOMATIC_STRENGTH relativeStrength = g_player[p]->GetRelativeStrength(visPl); + + if (relativeStrength < DIPLOMATIC_STRENGTH_WEAK) + { + strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_VWEK_BUTTON")); } - - if (ctp2_Static * regard = (ctp2_Static *)item->GetChildByIndex(k_INT_REGARD_COL)) - { - regard->SetDrawCallbackAndCookie(DrawPlayerRegard, (void *)p, true); - MBCHAR buf[k_MAX_NAME_LEN]; - SetRegardTip(buf, p, visPl); - ((aui_TipWindow *)regard->GetTipWindow())->SetTipText(buf); - regard->SetActionFuncAndCookie(SelectItem, item); + else if(relativeStrength < DIPLOMATIC_STRENGTH_AVERAGE) + { + strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_WEAK_BUTTON")); } - - if (ctp2_Static * strength = (ctp2_Static *)item->GetChildByIndex(k_INT_STRENGTH_COL)) - { - strength->SetDrawCallbackAndCookie(DrawPlayerStrength, (void *)p, true); - MBCHAR buf[k_MAX_NAME_LEN]; - DIPLOMATIC_STRENGTH relativeStrength = g_player[p]->GetRelativeStrength(visPl); - - if (relativeStrength < DIPLOMATIC_STRENGTH_WEAK) - { - strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_VWEK_BUTTON")); - } - else if(relativeStrength < DIPLOMATIC_STRENGTH_AVERAGE) - { - strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_WEAK_BUTTON")); - } - else if(relativeStrength < DIPLOMATIC_STRENGTH_STRONG) - { - strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_AVG_BUTTON")); - } - else - { - strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_STRN_BUTTON")); - } - - ((aui_TipWindow *)strength->GetTipWindow())->SetTipText(buf); - strength->SetActionFuncAndCookie(SelectItem, item); + else if(relativeStrength < DIPLOMATIC_STRENGTH_STRONG) + { + strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_AVG_BUTTON")); } - - if (ctp2_Static * embassy = (ctp2_Static *)item->GetChildByIndex(k_INT_EMBASSY_COL)) - { - embassy->SetDrawCallbackAndCookie(DrawEmbassy, (void *)p, true); - embassy->SetActionFuncAndCookie(SelectItem, item); + else + { + strcpy(buf, g_theStringDB->GetNameStr("TOOLTIP_DIPMAN_INTEL_STR_STRN_BUTTON")); } - if (ctp2_Static * treaty = (ctp2_Static *)item->GetChildByIndex(k_INT_TREATIES_COL)) - { - treaty->SetDrawCallbackAndCookie(DrawTreaties, (void *)p, true); - treaty->SetActionFuncAndCookie(SelectItem, item); - } - item->SetUserData((void*) p); - theList->AddItem(item); + ((aui_TipWindow *)strength->GetTipWindow())->SetTipText(buf); + strength->SetActionFuncAndCookie(SelectItem, item); + } + + if (ctp2_Static * embassy = (ctp2_Static *)item->GetChildByIndex(k_INT_EMBASSY_COL)) + { + embassy->SetDrawCallbackAndCookie(DrawEmbassy, (void *)p, true); + embassy->SetActionFuncAndCookie(SelectItem, item); + } + + if (ctp2_Static * treaty = (ctp2_Static *)item->GetChildByIndex(k_INT_TREATIES_COL)) + { + treaty->SetDrawCallbackAndCookie(DrawTreaties, (void *)p, true); + treaty->SetActionFuncAndCookie(SelectItem, item); + } + item->SetUserData((void*) p); + theList->AddItem(item); } -} + } void IntelligenceWindow::Close(aui_Control *control, uint32 action, uint32 data, void *cookie) { @@ -586,56 +586,53 @@ AUI_ERRCODE IntelligenceWindow::DrawEmbassy(ctp2_Static *control, return AUI_ERRCODE_OK; } -AUI_ERRCODE IntelligenceWindow::DrawTreaties(ctp2_Static *control, - aui_Surface *surface, - RECT &rect, - void *cookie) -{ - sint32 p = (sint32) cookie; - sint32 visP = g_selected_item->GetVisiblePlayer(); - sint32 slot; - - for (sint32 ag = 1; ag < PROPOSAL_MAX; ++ag) +AUI_ERRCODE IntelligenceWindow::DrawTreaties(ctp2_Static *control, aui_Surface *surface, RECT &rect, void *cookie) { - const DiplomacyProposalRecord *rec = - g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag)); + sint32 p = (sint32) cookie; + sint32 visP = g_selected_item->GetVisiblePlayer(); + sint32 slot; - if (!rec->GetImageSlot(slot)) - continue; + for (sint32 ag = 1; ag < PROPOSAL_MAX; ++ag) + { + const DiplomacyProposalRecord *rec = + g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag)); - if (rec->GetHasEmbargo()) - { - if (!Diplomat::GetDiplomat(p).GetEmbargo(visP)) - continue; - } - else if(!AgreementMatrix::s_agreements.HasAgreement(visP, p, (PROPOSAL_TYPE)ag)) - continue; - - aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); - Assert(image); - if(!image) - continue; - RECT srcRect = { - 0, 0, - image->TheSurface()->Width(), - image->TheSurface()->Height() - }; + if (!rec->GetImageSlot(slot)) + continue; - image->SetChromakey(255,0,255); + if (rec->GetHasEmbargo()) + { + if (!Diplomat::GetDiplomat(p).GetEmbargo(visP)) + continue; + } + else if(!AgreementMatrix::s_agreements.HasAgreement(visP, p, (PROPOSAL_TYPE)ag)) + continue; - sint32 x = image->TheSurface()->Width() * slot; + aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); + Assert(image); + if(!image) + continue; + RECT srcRect = { + 0, 0, + image->TheSurface()->Width(), + image->TheSurface()->Height() + }; - g_c3ui->TheBlitter()->Blt(surface, rect.left + x, - rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), - image->TheSurface(), - &srcRect, - k_AUI_BLITTER_FLAG_CHROMAKEY); + image->SetChromakey(255,0,255); - g_c3ui->UnloadImage(image); + sint32 x = image->TheSurface()->Width() * slot; + + g_c3ui->TheBlitter()->Blt(surface, rect.left + x, + rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), + image->TheSurface(), + &srcRect, + k_AUI_BLITTER_FLAG_CHROMAKEY); + + g_c3ui->UnloadImage(image); } - return AUI_ERRCODE_OK; -} + return AUI_ERRCODE_OK; + } void IntelligenceWindow::InitImageTables() { From 4e68513e5bde23d42fec67e7552e0530aeb60973 Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Fri, 15 Nov 2019 23:41:17 +0100 Subject: [PATCH 3/7] set agreement state in the sense of "DECLARE_EMBARGO" --- ctp2_code/ai/diplomacy/diplomat.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ctp2_code/ai/diplomacy/diplomat.cpp b/ctp2_code/ai/diplomacy/diplomat.cpp index 1f18c6938..260b57038 100644 --- a/ctp2_code/ai/diplomacy/diplomat.cpp +++ b/ctp2_code/ai/diplomacy/diplomat.cpp @@ -1863,6 +1863,15 @@ void Diplomat::SetEmbargo(const PLAYER_INDEX foreignerId, const bool state) } g_theTradePool->BreakOffTrade(m_playerId, foreignerId); + + ai::Agreement agreement; + agreement.senderId = foreignerId; + agreement.receiverId = m_playerId; + agreement.start = static_cast(NewTurnCount::GetCurrentRound()); + agreement.end = -1; + agreement.proposal.first_type = PROPOSAL_REQUEST_END_EMBARGO; //agreement type used in the sense of DECLARE_EMBARGO see diplomacyproposal.txt + + AgreementMatrix::s_agreements.SetAgreement(agreement); } m_foreigners[foreignerId].SetEmbargo(state); From cb05c149b48cbdca47f08f72c988c3103f710bf7 Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Sat, 16 Nov 2019 21:29:55 +0100 Subject: [PATCH 4/7] corr. indentation (emacs ^qc), remove double+ new lines (man.), comment on similar code parts --- ctp2_code/ui/interface/DiplomacyDetails.cpp | 117 ++++++++---------- ctp2_code/ui/interface/intelligencewindow.cpp | 1 + 2 files changed, 54 insertions(+), 64 deletions(-) diff --git a/ctp2_code/ui/interface/DiplomacyDetails.cpp b/ctp2_code/ui/interface/DiplomacyDetails.cpp index 36bec8585..824b15c07 100644 --- a/ctp2_code/ui/interface/DiplomacyDetails.cpp +++ b/ctp2_code/ui/interface/DiplomacyDetails.cpp @@ -860,71 +860,60 @@ AUI_ERRCODE DiplomacyDetails::DrawEmbassy(ctp2_Static *control, return AUI_ERRCODE_OK; } -AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, - aui_Surface *surface, - RECT &rect, - void *cookie) -{ - sint32 p = (sint32)cookie; - sint32 visP = g_selected_item->GetVisiblePlayer(); - - sint32 x = 0; - - sint32 ag; - sint32 slot; - for(ag = 1; ag < PROPOSAL_MAX; ag++) { - - - - - - - const DiplomacyProposalRecord *rec = - g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag)); - - if (!rec->GetImageSlot(slot)) - continue; - - if (p == visP) - { - if (slot > 4) - continue; - } - else - { - - if (slot < 4) - slot = 0; - else - slot -= 3; - } - - if(AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) { - aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); - Assert(image); - if(!image) - continue; - RECT srcRect = { - 0, 0, - image->TheSurface()->Width(), - image->TheSurface()->Height() - }; - - image->SetChromakey(255,0,255); - - x = image->TheSurface()->Width() * slot; - - g_c3ui->TheBlitter()->Blt(surface, rect.left + x, - rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), - image->TheSurface(), - &srcRect, - k_AUI_BLITTER_FLAG_CHROMAKEY); - - g_c3ui->UnloadImage(image); - } +AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, aui_Surface *surface, RECT &rect, void *cookie) + { + //// similar to IntelligenceWindow::DrawTreaties + sint32 p = (sint32)cookie; + sint32 visP = g_selected_item->GetVisiblePlayer(); + + sint32 x = 0; + + sint32 ag; + sint32 slot; + for(ag = 1; ag < PROPOSAL_MAX; ag++) { + const DiplomacyProposalRecord *rec = + g_theDiplomacyProposalDB->Get(diplomacyutil_GetDBIndex((PROPOSAL_TYPE)ag)); + + if (!rec->GetImageSlot(slot)) + continue; + + if (p == visP){ + if (slot > 4) + continue; + } + else{ + if (slot < 4) + slot = 0; + else + slot -= 3; + } + + if(AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) { + aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); + Assert(image); + if(!image) + continue; + RECT srcRect = { + 0, 0, + image->TheSurface()->Width(), + image->TheSurface()->Height() + }; + + image->SetChromakey(255,0,255); + + x = image->TheSurface()->Width() * slot; + + g_c3ui->TheBlitter()->Blt(surface, rect.left + x, + rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), + image->TheSurface(), + &srcRect, + k_AUI_BLITTER_FLAG_CHROMAKEY); + + g_c3ui->UnloadImage(image); + } } - return AUI_ERRCODE_OK; -} + return AUI_ERRCODE_OK; + } sint32 DiplomacyDetails::GetRegardThreshold(sint32 ofPlayer, sint32 forPlayer) { diff --git a/ctp2_code/ui/interface/intelligencewindow.cpp b/ctp2_code/ui/interface/intelligencewindow.cpp index 92bd0087e..7dd3dfd55 100644 --- a/ctp2_code/ui/interface/intelligencewindow.cpp +++ b/ctp2_code/ui/interface/intelligencewindow.cpp @@ -588,6 +588,7 @@ AUI_ERRCODE IntelligenceWindow::DrawEmbassy(ctp2_Static *control, AUI_ERRCODE IntelligenceWindow::DrawTreaties(ctp2_Static *control, aui_Surface *surface, RECT &rect, void *cookie) { + //// similar to DiplomacyDetails::DrawTreaties sint32 p = (sint32) cookie; sint32 visP = g_selected_item->GetVisiblePlayer(); sint32 slot; From d6f1dca73f75e4b6581e66ef986e45edae3ffcf1 Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Sat, 16 Nov 2019 21:41:33 +0100 Subject: [PATCH 5/7] there is space for the 5th agreement-matrix entry in the Diplomacy Details Tab --- ctp2_code/ui/interface/DiplomacyDetails.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ctp2_code/ui/interface/DiplomacyDetails.cpp b/ctp2_code/ui/interface/DiplomacyDetails.cpp index 824b15c07..a0ba2c781 100644 --- a/ctp2_code/ui/interface/DiplomacyDetails.cpp +++ b/ctp2_code/ui/interface/DiplomacyDetails.cpp @@ -878,14 +878,14 @@ AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, aui_Surface *su continue; if (p == visP){ - if (slot > 4) + if (slot > 5) continue; } else{ - if (slot < 4) + if (slot < 5) slot = 0; else - slot -= 3; + slot -= 4; } if(AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) { From fc69bb0edbe8ce0933381b894a640856fcaa76ca Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Sat, 16 Nov 2019 23:29:02 +0100 Subject: [PATCH 6/7] adjust code to match that of IntelligenceWindow::DrawTreaties (not sure if that is needed since 4e68513e5bd) --- ctp2_code/ui/interface/DiplomacyDetails.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ctp2_code/ui/interface/DiplomacyDetails.cpp b/ctp2_code/ui/interface/DiplomacyDetails.cpp index a0ba2c781..1bf035597 100644 --- a/ctp2_code/ui/interface/DiplomacyDetails.cpp +++ b/ctp2_code/ui/interface/DiplomacyDetails.cpp @@ -877,6 +877,12 @@ AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, aui_Surface *su if (!rec->GetImageSlot(slot)) continue; + if (rec->GetHasEmbargo()) + { + if (!Diplomat::GetDiplomat(p).GetEmbargo(detailPlayer)) + continue; + } + if (p == visP){ if (slot > 5) continue; From d2ccba80881439316c18315d070c7882029df2fd Mon Sep 17 00:00:00 2001 From: Lynx Abraxas Date: Sat, 16 Nov 2019 23:57:22 +0100 Subject: [PATCH 7/7] list all agreement icons, same list column widths as in diplomacywindow.ldl, height tuned --- ctp2_code/ui/interface/DiplomacyDetails.cpp | 50 ++++++++----------- .../uidata/layouts/DiplomacyDetails.ldl | 15 +++--- .../uidata/layouts/diplomacywindow.ldl | 14 +++--- 3 files changed, 34 insertions(+), 45 deletions(-) diff --git a/ctp2_code/ui/interface/DiplomacyDetails.cpp b/ctp2_code/ui/interface/DiplomacyDetails.cpp index 1bf035597..8b296cbe2 100644 --- a/ctp2_code/ui/interface/DiplomacyDetails.cpp +++ b/ctp2_code/ui/interface/DiplomacyDetails.cpp @@ -882,42 +882,32 @@ AUI_ERRCODE DiplomacyDetails::DrawTreaties(ctp2_Static *control, aui_Surface *su if (!Diplomat::GetDiplomat(p).GetEmbargo(detailPlayer)) continue; } + else if(!AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) + continue; - if (p == visP){ - if (slot > 5) - continue; - } - else{ - if (slot < 5) - slot = 0; - else - slot -= 4; - } - - if(AgreementMatrix::s_agreements.HasAgreement(detailPlayer, p, (PROPOSAL_TYPE)ag)) { - aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); - Assert(image); - if(!image) - continue; - RECT srcRect = { - 0, 0, - image->TheSurface()->Width(), - image->TheSurface()->Height() - }; + aui_Image *image = g_c3ui->LoadImage((char *)rec->GetImage()); + Assert(image); + if(!image) + continue; + RECT srcRect = { + 0, 0, + image->TheSurface()->Width(), + image->TheSurface()->Height() + }; - image->SetChromakey(255,0,255); + image->SetChromakey(255,0,255); - x = image->TheSurface()->Width() * slot; + x = image->TheSurface()->Width() * slot; - g_c3ui->TheBlitter()->Blt(surface, rect.left + x, - rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), - image->TheSurface(), - &srcRect, - k_AUI_BLITTER_FLAG_CHROMAKEY); + g_c3ui->TheBlitter()->Blt(surface, rect.left + x, + rect.top + (((rect.bottom - rect.top) - image->TheSurface()->Height()) / 2), + image->TheSurface(), + &srcRect, + k_AUI_BLITTER_FLAG_CHROMAKEY); - g_c3ui->UnloadImage(image); - } + g_c3ui->UnloadImage(image); } + return AUI_ERRCODE_OK; } diff --git a/ctp2_data/default/uidata/layouts/DiplomacyDetails.ldl b/ctp2_data/default/uidata/layouts/DiplomacyDetails.ldl index 0e60497e8..08f222012 100644 --- a/ctp2_data/default/uidata/layouts/DiplomacyDetails.ldl +++ b/ctp2_data/default/uidata/layouts/DiplomacyDetails.ldl @@ -127,17 +127,17 @@ DiplomacyDetails:CTP2_3TAB_DIALOG_WINDOW { # Start Foreign Relations Tab... ################################################################################ List:CTP2_LISTBOX { - int xpix 20 - int ypix 30 - int widthpix 450 - int heightpix 160 + int xpix 10 + int ypix 24 + int widthpix 470 + int heightpix 173 header { # MDS 090600 Added flag switch0:DIP_INTEL_HEADER { - int widthpix 40 + int widthpix 40 } switch1:DIP_INTEL_HEADER { - int widthpix 150 + int widthpix 110 string text "str_ldl_Nation" } switch2:DIP_INTEL_HEADER { @@ -152,9 +152,8 @@ DiplomacyDetails:CTP2_3TAB_DIALOG_WINDOW { int widthpix 50 string text "str_ldl_Embassy" } - switch5:DIP_INTEL_HEADER { - int widthpix 110 + int widthpix 172 #212 string text "str_ldl_AlliancesTreaties" } } diff --git a/ctp2_data/default/uidata/layouts/diplomacywindow.ldl b/ctp2_data/default/uidata/layouts/diplomacywindow.ldl index f07d80739..200210d0d 100644 --- a/ctp2_data/default/uidata/layouts/diplomacywindow.ldl +++ b/ctp2_data/default/uidata/layouts/diplomacywindow.ldl @@ -328,9 +328,9 @@ DiplomacyWindow:CTP2_DIALOG_WINDOW { List:CTP2_LISTBOX { int xpix 10 - int ypix 24 + int ypix 12 int widthpix 470 - int heightpix 398 + int heightpix 418 header { # MDS 090600 Adding color flag @@ -372,14 +372,14 @@ DiplomacyWindow:CTP2_DIALOG_WINDOW { DetailsButton:CTP2_POSITION_13_BUTTON { int xpix 5 #42 - int ypix 428 #510 #267 + int ypix 436 #510 #267 string text "str_ldl_Intelligence" string statustext "STATUSBAR_DIPMAN_TABLE_GOTO_INTEL_BUTTON" } MessageButton:CTP2_POSITION_23_BUTTON { int xpix 110 #150 - int ypix 428 #510 #267 + int ypix 436 #510 #267 string text "str_ldl_CreateProposal" # Tooltip string statustext "STATUSBAR_DIPMAN_TABLE_GOTO_CREATE_BUTTON" @@ -387,7 +387,7 @@ DiplomacyWindow:CTP2_DIALOG_WINDOW { WarButton:CTP2_POSITION_33_BUTTON { int xpix 214 #258 - int ypix 428 #510 #267 + int ypix 436 #510 #267 string text "str_ldl_DeclareWar" # Tooltip string statustext "STATUSBAR_DIPMAN_TABLE_DECLAREWAR_BUTTON" @@ -395,7 +395,7 @@ DiplomacyWindow:CTP2_DIALOG_WINDOW { EmbargoButton:CTP2_POSITION_33_BUTTON { int xpix 317 #366 - int ypix 428 #510 #267 + int ypix 436 #510 #267 string text "str_ldl_DeclareEmbargo" # Tooltip string statustext "STATUSBAR_DIPMAN_TABLE_EMBARGO_BUTTON" @@ -407,7 +407,7 @@ DiplomacyWindow:CTP2_DIALOG_WINDOW { CloseButton:CTP2_STANDARD_CLOSE { # Tooltip int xpix 455 - int ypix 481 + int ypix 489 string statustext "STATUSBAR_DIPMAN_TABLE_CLOSE_BUTTON" }