mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Cleanup: rename ValueViewer::viewer -> parent; store CardP in ValueAction
This commit is contained in:
@@ -78,7 +78,7 @@ DropDownChoiceListBase::DropDownChoiceListBase
|
||||
|
||||
void DropDownChoiceListBase::onShow() {
|
||||
// update 'enabled'
|
||||
Context& ctx = cve.viewer.getContext();
|
||||
Context& ctx = cve.getContext();
|
||||
FOR_EACH(c, group->choices) {
|
||||
c->enabled.update(ctx);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void DropDownChoiceListBase::drawIcon(DC& dc, int x, int y, size_t item, bool se
|
||||
void DropDownChoiceListBase::generateThumbnailImages() {
|
||||
if (!isRoot()) return;
|
||||
// init choice images
|
||||
Context& ctx = cve.viewer.getContext();
|
||||
Context& ctx = cve.getContext();
|
||||
if (style().choice_images.empty() && style().image.isScripted()) {
|
||||
int n = field().choices->lastId();
|
||||
for (int i = 0 ; i < n; ++i) {
|
||||
@@ -230,7 +230,7 @@ size_t DropDownChoiceList::selection() const {
|
||||
} else {
|
||||
// run default script to find out what the default choice would be
|
||||
try {
|
||||
String default_choice = field().default_script.invoke( cve.viewer.getContext() )->toString();
|
||||
String default_choice = field().default_script.invoke(cve.getContext())->toString();
|
||||
default_id = group->choiceId(default_choice);
|
||||
} catch (ScriptError const& e) {
|
||||
handle_error(ScriptError(e.what() + _("\n in default script for '") + field().name + _("'")));
|
||||
|
||||
@@ -108,7 +108,7 @@ size_t DropDownColorList::selection() const {
|
||||
} else if (hasDefault()) {
|
||||
// evaluate script to find default color
|
||||
try {
|
||||
default_color = field().default_script.invoke(cve.viewer.getContext())->toColor();
|
||||
default_color = field().default_script.invoke(cve.getContext())->toColor();
|
||||
} catch (ScriptError const& e) {
|
||||
handle_error(ScriptError(e.what() + _("\n in default script for '") + field().name + _("'")));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
void ValueEditor::addAction(unique_ptr<ValueAction> a) {
|
||||
if (a) {
|
||||
a->isOnCard(editor().getCard().get());
|
||||
a->setCard(editor().getCard());
|
||||
editor().addAction(move(a));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ protected:
|
||||
private: \
|
||||
/** Retrieve the parent editor object */ \
|
||||
inline DataEditor& editor() const override { \
|
||||
return static_cast<DataEditor&>(viewer); \
|
||||
return static_cast<DataEditor&>(parent); \
|
||||
} \
|
||||
public:
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ bool ImageValueEditor::onLeftDClick(const RealPoint&, wxMouseEvent&) {
|
||||
void ImageValueEditor::sliceImage(const Image& image) {
|
||||
if (!image.Ok()) return;
|
||||
// mask
|
||||
GeneratedImage::Options options((int)style().width, (int)style().height, &viewer.getStylePackage(), &viewer.getLocalPackage());
|
||||
GeneratedImage::Options options((int)style().width, (int)style().height, &parent.getStylePackage(), &parent.getLocalPackage());
|
||||
AlphaMask mask;
|
||||
style().mask.getNoCache(options,mask);
|
||||
// slice
|
||||
|
||||
@@ -65,7 +65,7 @@ bool SymbolValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent&) {
|
||||
int button = findButton(pos);
|
||||
if (button != button_down) {
|
||||
button_down = button;
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ bool SymbolValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
int button = findButton(pos);
|
||||
if (button != button_down) {
|
||||
button_down = button;
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -85,13 +85,13 @@ bool SymbolValueEditor::onLeftUp(const RealPoint& pos, wxMouseEvent&) {
|
||||
if (button_down == 0) {
|
||||
// edit
|
||||
button_down = -2;
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
editSymbol();
|
||||
return true;
|
||||
} else if (button_down == 1) {
|
||||
// gallery
|
||||
button_down = -2;
|
||||
viewer.redraw(*this);
|
||||
parent.redraw(*this);
|
||||
// TODO
|
||||
return true;
|
||||
} else {
|
||||
@@ -117,5 +117,5 @@ void SymbolValueEditor::editSymbol() {
|
||||
}
|
||||
|
||||
ValueActionPerformer* SymbolValueEditor::getActionPerformer() {
|
||||
return new ValueActionPerformer(valueP(), editor().getCard().get(), editor().getSetForActions());
|
||||
return new ValueActionPerformer(valueP(), editor().getCard(), editor().getSetForActions());
|
||||
}
|
||||
|
||||
+12
-12
@@ -181,7 +181,7 @@ void DropDownWordList::setWords(const WordListWordP& words2) {
|
||||
void DropDownWordList::addWordsFromScript(const WordListWordP& w) {
|
||||
assert(w->script);
|
||||
// run script
|
||||
Context& ctx = tve.viewer.getContext();
|
||||
Context& ctx = tve.getContext();
|
||||
String str = w->script.invoke(ctx)->toString();
|
||||
// collect items
|
||||
vector<String> strings;
|
||||
@@ -317,7 +317,7 @@ IMPLEMENT_VALUE_EDITOR(Text)
|
||||
, scrollbar(nullptr), scroll_with_cursor(false)
|
||||
, hovered_words(nullptr)
|
||||
{
|
||||
if (viewer.nativeLook() && field().multi_line) {
|
||||
if (nativeLook() && field().multi_line) {
|
||||
scrollbar = new TextValueEditorScrollBar(*this);
|
||||
style->padding_right = max(style->padding_right(), (double)scrollbar->GetSize().x);
|
||||
}
|
||||
@@ -616,7 +616,7 @@ bool TextValueEditor::onCommand(int id) {
|
||||
wxMenu* TextValueEditor::getMenu(int type) const {
|
||||
if (type == ID_INSERT_SYMBOL && (style().always_symbol || style().allow_formating)
|
||||
&& style().symbol_font.valid()) {
|
||||
return style().symbol_font.font->insertSymbolMenu(viewer.getContext());
|
||||
return style().symbol_font.font->insertSymbolMenu(getContext());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -709,7 +709,7 @@ wxCursor TextValueEditor::cursor(const RealPoint& pos) const {
|
||||
hovered_words = p.get();
|
||||
const_cast<TextValueEditor*>(this)->redrawWordListIndicators();
|
||||
}
|
||||
Radians angle = viewer.getRotation().getAngle() + deg_to_rad(style().angle);
|
||||
Radians angle = parent.getRotation().getAngle() + deg_to_rad(style().angle);
|
||||
if (is_sideways(angle)) { // 90 or 270 degrees
|
||||
if (!rotated_ibeam.Ok()) {
|
||||
rotated_ibeam = wxCursor(load_resource_cursor(_("rot_text")));
|
||||
@@ -866,7 +866,7 @@ void TextValueEditor::showCaret() {
|
||||
return;
|
||||
}
|
||||
// Rotation
|
||||
Rotation rot(viewer.getRotation());
|
||||
Rotation rot(parent.getRotation());
|
||||
Rotater rot2(rot, getRotation());
|
||||
// The caret
|
||||
wxCaret* caret = editor().GetCaret();
|
||||
@@ -877,7 +877,7 @@ void TextValueEditor::showCaret() {
|
||||
// it is not 0 for empty text, because TextRenderer handles that case
|
||||
if (cursor.height == 0) {
|
||||
if (style().always_symbol && style().symbol_font.valid()) {
|
||||
style().symbol_font.font->update(viewer.getContext());
|
||||
style().symbol_font.font->update(getContext());
|
||||
RealSize s = style().symbol_font.font->defaultSymbolSize(rot.trS(style().symbol_font.size));
|
||||
cursor.height = s.height;
|
||||
} else {
|
||||
@@ -1033,7 +1033,7 @@ void TextValueEditor::replaceSelection(const String& replacement, const String&
|
||||
|
||||
void TextValueEditor::tryAutoReplace() {
|
||||
size_t end = selection_start_i;
|
||||
GameSettings& gs = settings.gameSettingsFor(viewer.getGame());
|
||||
GameSettings& gs = settings.gameSettingsFor(parent.getGame());
|
||||
if (!gs.use_auto_replace) return;
|
||||
FOR_EACH(ar, gs.auto_replaces) {
|
||||
if (ar->enabled && ar->match.size() <= end) {
|
||||
@@ -1217,7 +1217,7 @@ bool TextValueEditor::matchSubstr(const String& s, size_t pos, FindInfo& find) {
|
||||
fixSelection(TYPE_INDEX);
|
||||
was_selection = old_sel_start == selection_start && old_sel_end == selection_end;
|
||||
}
|
||||
if (find.handle(viewer.getCard(), valueP(), pos, was_selection)) {
|
||||
if (find.handle(parent.getCard(), valueP(), pos, was_selection)) {
|
||||
return true;
|
||||
} else {
|
||||
// TODO: string might have changed when doing replace all
|
||||
@@ -1253,7 +1253,7 @@ void TextValueEditor::determineSize(bool force_fit) {
|
||||
style().angle = 0; // force no rotation in nativeLook
|
||||
if (scrollbar) {
|
||||
// muliline, determine scrollbar size
|
||||
Rotation rot = viewer.getRotation();
|
||||
Rotation rot = parent.getRotation();
|
||||
Rotater r(rot, getRotation());
|
||||
if (!force_fit) style().height = 100;
|
||||
int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||
@@ -1329,7 +1329,7 @@ void TextValueEditor::prepareDrawScrollbar(RotatedDC& dc) {
|
||||
style().width.mutate() -= scrollbar_width;
|
||||
// prepare text, and remember scroll position
|
||||
double scroll_pos = v.getExactScrollPosition();
|
||||
v.prepare(dc, value().value(), style(), viewer.getContext());
|
||||
v.prepare(dc, value().value(), style(), getContext());
|
||||
v.setExactScrollPosition(scroll_pos);
|
||||
// scroll to the same place, but always show the caret
|
||||
ensureCaretVisible();
|
||||
@@ -1358,7 +1358,7 @@ void TextValueEditor::findWordLists() {
|
||||
String name = str.substr(pos + 11, type_end - pos - 11);
|
||||
WordListP word_list;
|
||||
// find word list type
|
||||
FOR_EACH(wl, viewer.getGame().word_lists) {
|
||||
FOR_EACH(wl, parent.getGame().word_lists) {
|
||||
if (wl->name == name) {
|
||||
word_list = wl;
|
||||
break;
|
||||
@@ -1399,7 +1399,7 @@ void TextValueEditor::redrawWordListIndicators(bool toggling_dropdown) {
|
||||
|
||||
void TextValueEditor::drawWordListIndicators(RotatedDC& dc, bool redrawing) {
|
||||
if (word_lists.empty()) return;
|
||||
DrawWhat what = viewer.drawWhat(this);
|
||||
DrawWhat what = drawWhat();
|
||||
bool current = what & DRAW_ACTIVE;
|
||||
// Draw lines around fields
|
||||
FOR_EACH(wl, word_lists) {
|
||||
|
||||
Reference in New Issue
Block a user