Skip to content

Commit

Permalink
add "delete trigger for other players" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaDusknoir committed Jul 30, 2022
1 parent fb2733f commit 39bdaf2
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AoE2TCWin/AoE2TCWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
LoadStringMap(hInstance, TIPS_TRIGGER_SORT, stMap, MAX_LOADSTRING);
LoadStringMap(hInstance, IDS_SORT_COMPLETE, stMap, MAX_LOADSTRING);
LoadStringMap(hInstance, IDS_NAME_NEW_TRIGGER, stMap, MAX_LOADSTRING);
LoadStringMap(hInstance, TIPS_TRIGGER_DEL_FOR_ALL, stMap, MAX_LOADSTRING);
LoadStringMap(hInstance, IDS_DEL_FOR_ALL_WARNING, stMap, MAX_LOADSTRING);

MyRegisterClass(hInstance);

Expand Down
Binary file modified AoE2TCWin/AoE2TCWin.rc
Binary file not shown.
1 change: 1 addition & 0 deletions AoE2TCWin/AoE2TCWin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ xcopy .\string.json .\..\dist\ /y</Command>
<ItemGroup>
<Image Include="AoE2TCWin.ico" />
<Image Include="res\B_COPY_TO_ALL.ico" />
<Image Include="res\B_DEL_FOR_ALL.ico" />
<Image Include="res\B_DEL_TRIG.ico" />
<Image Include="res\B_NEW_COND.ico" />
<Image Include="res\B_NEW_EFFE.ico" />
Expand Down
3 changes: 3 additions & 0 deletions AoE2TCWin/AoE2TCWin.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
<Image Include="res\B_NEW_COND.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\B_DEL_FOR_ALL.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Library Include="..\util\libdeflate\libdeflatestatic.lib">
Expand Down
Binary file added AoE2TCWin/res/B_DEL_FOR_ALL.ico
Binary file not shown.
6 changes: 5 additions & 1 deletion AoE2TCWin/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
#define IDD_UNITS 131
#define IDS_OPEN_TEXT_FAIL 131
#define IDD_TRIGGERS 132
#define IDS_DEL_FOR_ALL_WARNING 132
#define IDD_MAPVIEW 133
#define TIPS_TRIGGER_DEL_FOR_ALL 133
#define IDB_COND 134
#define IDB_CONDITION 134
#define IDD_SCENINFO 134
Expand All @@ -60,13 +62,15 @@
#define IDI_B_SORT 144
#define IDI_B_NEW_EFFE 146
#define IDI_B_NEW_COND 147
#define IDI_B_DEL_FOR_ALL 149
#define IDC_TRIGGER_TREE 1007
#define IDC_ADD_TRIG 1009
#define IDC_DEL_TRIG 1010
#define IDC_COPY_TO_ALL 1011
#define IDC_SORT 1012
#define IDC_ADD_COND 1013
#define IDC_ADD_EFFE 1014
#define IDC_DEL_FOR_ALL 1015
#define IDC_EDIT4 1051
#define IDC_PT_DESC_STR 1051
#define IDC_EDIT5 1052
Expand Down Expand Up @@ -119,7 +123,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 148
#define _APS_NEXT_RESOURCE_VALUE 150
#define _APS_NEXT_COMMAND_VALUE 32786
#define _APS_NEXT_CONTROL_VALUE 1074
#define _APS_NEXT_SYMED_VALUE 110
Expand Down
53 changes: 53 additions & 0 deletions AoE2TCWin/view/editor_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,57 @@ INT_PTR Handle_WM_COMMAND(HWND dialog, WORD code, WORD id, HWND)
}
break;
}
case IDC_DEL_FOR_ALL:
{
auto to_del_cnt = Scen.scen.header.player_count - 1;
TreeItemIterator select(treeview);
if (select + to_del_cnt)
{
//misoperation check
auto& first_trig = Scen.triggers->at(((ItemData*)select.lparam())->idx);
auto& last_trig = Scen.triggers->at(((ItemData*)(select + to_del_cnt).lparam())->idx);
std::string to_find("(p8)");
to_find[2] = '0' + to_del_cnt + 1;
if (last_trig.trigger_name.s.find(to_find) == last_trig.trigger_name.s.npos
&& MessageBox(treeview, stMap[IDS_DEL_FOR_ALL_WARNING], stMap[TIPS_TRIGGER_DEL_FOR_ALL], MB_ICONWARNING | MB_OKCANCEL) == IDCANCEL)
{
break;
}
auto select_item = (ItemData*)select.lparam();
switch (select_item->type)
{
case ItemData::TRIGGER:
{
HTREEITEM next_item = select + (to_del_cnt + 1) ? select + (to_del_cnt + 1) : select;
auto deleted_cnt = Scen.triggers->del_for_all(select_item->idx);
assert(deleted_cnt == to_del_cnt);
for (decltype(to_del_cnt) i = 0; i < to_del_cnt; ++i)
{
TreeView_DeleteItem(treeview, select + 1);
}
auto to_iter = select;
while (++to_iter)
{
((ItemData*)to_iter.lparam())->idx -= to_del_cnt;
}
TreeView_Select(treeview, next_item, TVGN_CARET);
break;
}
case ItemData::CONDITION:
{
break;
}
case ItemData::EFFECT:
{
break;
}
default:
break;
}
SetFocus(treeview);
}
break;
}
case IDC_SORT:
{
Scen.triggers->sort_by_order();
Expand Down Expand Up @@ -648,6 +699,7 @@ BOOL MakeTrigDlg(HWND dialog)
SendMessage(GetDlgItem(dialog, IDC_ADD_COND), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_B_NEW_COND)));
SendMessage(GetDlgItem(dialog, IDC_DEL_TRIG), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_B_DEL_TRIG)));
SendMessage(GetDlgItem(dialog, IDC_COPY_TO_ALL), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_B_COPY_TO_ALL)));
SendMessage(GetDlgItem(dialog, IDC_DEL_FOR_ALL), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_B_DEL_FOR_ALL)));
SendMessage(GetDlgItem(dialog, IDC_SORT), BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_B_SORT)));

//SendMessage(GetDlgItem(dialog, IDC_ADD_TRIG), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)icon_trig);
Expand All @@ -656,6 +708,7 @@ BOOL MakeTrigDlg(HWND dialog)
CreateToolTip(IDC_ADD_EFFE, dialog, stMap[TIPS_ADD_EFFECT]);
CreateToolTip(IDC_DEL_TRIG, dialog, stMap[TIPS_DEL_TREEITEM]);
CreateToolTip(IDC_COPY_TO_ALL, dialog, stMap[TIPS_TRIGGER_COPY_TO_ALL]);
CreateToolTip(IDC_DEL_FOR_ALL, dialog, stMap[TIPS_TRIGGER_DEL_FOR_ALL]);
CreateToolTip(IDC_SORT, dialog, stMap[TIPS_TRIGGER_SORT]);

return TRUE;
Expand Down
6 changes: 6 additions & 0 deletions model/aoe2scenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ namespace AoE2ScenarioNamespace
TriggerStructIdx added_cnt = list_by_order.size() - old_size;
return added_cnt;
}
TriggerStructIdx TriggerManager::del_for_all(TriggerStructIdx to_del)
{
TriggerStructIdx deleted_cnt = scen->header.player_count - 1;
del(to_del + 1, deleted_cnt);
return deleted_cnt;
}

string TextIO::string_escape(const string& src)
{
Expand Down
1 change: 1 addition & 0 deletions model/aoe2scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace AoE2ScenarioNamespace
void mov(TriggerStructIdx target, TriggerStructIdx idx_begin, TriggerStructIdx idx_end);
//push_back to vector, move the order to target
TriggerStructIdx copy_to_all(TriggerStructIdx to_copy, uint32_t mode);
TriggerStructIdx del_for_all(TriggerStructIdx to_del);
void sort_by_order();
void load();
void confirm();
Expand Down

0 comments on commit 39bdaf2

Please sign in to comment.