mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Clean up pointer use:
* Use unique_ptr for Actions instead of manual memory management * Use unique_ptr in KeywordDatabase * Use unique_ptr instead of shared_ptr for file formats * Don't pass shared_ptr to Reader/Writer, use references instead Also * Switch to C++17 so we can use map::try_emplace
This commit is contained in:
@@ -325,7 +325,7 @@ void CardsPanel::onCommand(int id) {
|
||||
if (card_list->canSelectNext()) card_list->selectNext();
|
||||
break;
|
||||
case ID_CARD_ADD:
|
||||
set->actions.addAction(new AddCardAction(*set));
|
||||
set->actions.addAction(make_unique<AddCardAction>(*set));
|
||||
break;
|
||||
case ID_CARD_REMOVE:
|
||||
card_list->doDelete();
|
||||
|
||||
@@ -180,7 +180,7 @@ void KeywordsPanel::onCommand(int id) {
|
||||
list->selectNext();
|
||||
break;
|
||||
case ID_KEYWORD_ADD:
|
||||
set->actions.addAction(new AddKeywordAction(*set));
|
||||
set->actions.addAction(make_unique<AddKeywordAction>(*set));
|
||||
break;
|
||||
case ID_KEYWORD_REMOVE:
|
||||
if (list->canDelete()) {
|
||||
@@ -370,7 +370,7 @@ void KeywordsPanel::onModeChange(wxCommandEvent& ev) {
|
||||
if (!list->getKeyword()) return;
|
||||
int sel = mode->GetSelection();
|
||||
if (sel >= 0 && (size_t)sel < set->game->keyword_modes.size()) {
|
||||
set->actions.addAction(new ChangeKeywordModeAction(*list->getKeyword(), set->game->keyword_modes[sel]->name));
|
||||
set->actions.addAction(make_unique<ChangeKeywordModeAction>(*list->getKeyword(), set->game->keyword_modes[sel]->name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ void RandomPackPanel::onCommand(int id) {
|
||||
case ID_CUSTOM_PACK: {
|
||||
CustomPackDialog dlg(this, set, PackTypeP(), false);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
set->actions.addAction( new AddPackAction(ADD,*set,dlg.get()) );
|
||||
set->actions.addAction(make_unique<AddPackAction>(ADD,*set,dlg.get()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -544,12 +544,12 @@ void RandomPackPanel::onPackTypeClick(wxCommandEvent& ev) {
|
||||
// update pack
|
||||
for (size_t i = 0 ; i < set->pack_types.size() ; ++i) {
|
||||
if (set->pack_types[i] == pick.pack) {
|
||||
set->actions.addAction( new ChangePackAction(*set,i,dlg.get()) );
|
||||
set->actions.addAction(make_unique<ChangePackAction>(*set,i,dlg.get()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// delete pack
|
||||
set->actions.addAction( new AddPackAction(REMOVE,*set,pick.pack) );
|
||||
set->actions.addAction(make_unique<AddPackAction>(REMOVE,*set,pick.pack));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -238,7 +238,7 @@ void StatDimensionList::drawItem(DC& dc, int x, int y, size_t item) {
|
||||
StatsDimension& dim = *dimensions.at(item - show_empty);
|
||||
// draw icon
|
||||
if (!dim.icon_filename.empty() && !dim.icon.Ok()) {
|
||||
InputStreamP file = game->openIn(dim.icon_filename);
|
||||
auto file = game->openIn(dim.icon_filename);
|
||||
Image img(*file);
|
||||
if (img.HasMask()) img.InitAlpha(); // we can't handle masks
|
||||
Image resampled(21, 21);
|
||||
|
||||
@@ -171,18 +171,18 @@ void StylePanel::onStyleSelect(wxCommandEvent&) {
|
||||
// select no special style when selecting the same style as the set default
|
||||
stylesheet = StyleSheetP();
|
||||
}
|
||||
set->actions.addAction(new ChangeCardStyleAction(card, stylesheet));
|
||||
set->actions.addAction(make_unique<ChangeCardStyleAction>(card, stylesheet));
|
||||
Layout();
|
||||
}
|
||||
}
|
||||
|
||||
void StylePanel::onUseForAll(wxCommandEvent&) {
|
||||
set->actions.addAction(new ChangeSetStyleAction(*set, card));
|
||||
set->actions.addAction(make_unique<ChangeSetStyleAction>(*set, card));
|
||||
Layout();
|
||||
}
|
||||
|
||||
void StylePanel::onUseCustom(wxCommandEvent&) {
|
||||
set->actions.addAction(new ChangeCardHasStylingAction(*set, card));
|
||||
set->actions.addAction(make_unique<ChangeCardHasStylingAction>(*set, card));
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
||||
|
||||
Reference in New Issue
Block a user