summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-03 12:51:52 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-03 12:51:52 +0300
commitfa0e1943d5a6eeb5502b0c68f0170f05d76d6a95 (patch)
tree115198fec7c0f86f4a4ccc87583946dbfb3e447e /plugins
parentf848419d66312abfcd32d26db138566b2359e468 (diff)
fixes #3779 (NewStory: обновлять текущий предпросмотр шаблона при применении изменений)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/res/reload.icobin2550 -> 0 bytes
-rw-r--r--plugins/NewStory/res/resource.rc7
-rw-r--r--plugins/NewStory/src/main.cpp1
-rw-r--r--plugins/NewStory/src/options.cpp44
-rw-r--r--plugins/NewStory/src/resource.h2
5 files changed, 24 insertions, 30 deletions
diff --git a/plugins/NewStory/res/reload.ico b/plugins/NewStory/res/reload.ico
deleted file mode 100644
index 1c2a01b2ca..0000000000
--- a/plugins/NewStory/res/reload.ico
+++ /dev/null
Binary files differ
diff --git a/plugins/NewStory/res/resource.rc b/plugins/NewStory/res/resource.rc
index 7b2953fbb6..c330de5a5c 100644
--- a/plugins/NewStory/res/resource.rc
+++ b/plugins/NewStory/res/resource.rc
@@ -60,8 +60,6 @@ IDI_CALENDAR ICON "calendar.ico"
IDI_RESET ICON "reset.ico"
-IDI_PREVIEW ICON "reload.ico"
-
IDI_VARHELP ICON "vars.ico"
IDI_TPLGROUP ICON "folder.ico"
@@ -161,9 +159,8 @@ BEGIN
EDITTEXT IDC_PREVIEW,162,20,138,42,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY
LTEXT "Graphic preview:",IDC_STATIC,157,67,143,8
CONTROL "",IDC_GPREVIEW,"MTextControl",WS_TABSTOP,162,80,138,57
- CONTROL "",IDC_RESET,"MButtonClass",WS_TABSTOP,230,202,16,16
- CONTROL "",IDC_DISCARD,"MButtonClass",WS_TABSTOP,248,202,16,16
- CONTROL "",IDC_UPDATEPREVIEW,"MButtonClass",WS_TABSTOP,266,202,16,16
+ CONTROL "",IDC_RESET,"MButtonClass",WS_TABSTOP,248,202,16,16
+ CONTROL "",IDC_DISCARD,"MButtonClass",WS_TABSTOP,266,202,16,16
CONTROL "",IDC_VARHELP,"MButtonClass",WS_DISABLED | WS_TABSTOP,284,202,16,16
END
diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp
index 1c8a82988b..75450a1c79 100644
--- a/plugins/NewStory/src/main.cpp
+++ b/plugins/NewStory/src/main.cpp
@@ -78,7 +78,6 @@ static IconItem icons[] =
{ LPGEN("Template group"), "tplgroup", IDI_TPLGROUP },
{ LPGEN("Cancel edit"), "reset", IDI_RESET },
- { LPGEN("Update preview"), "preview", IDI_PREVIEW },
{ LPGEN("Downloaded"), "downloaded", IDI_OK },
{ LPGEN("Help"), "varhelp", IDI_VARHELP }
};
diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp
index 6450143a6d..cf73b767e2 100644
--- a/plugins/NewStory/src/options.cpp
+++ b/plugins/NewStory/src/options.cpp
@@ -73,20 +73,9 @@ class CTemplateOptsDlg : public CBaseOptsDlg
TemplateInfo *m_curr = 0;
ItemData m_tempItem;
- void UpdatePreview(CCtrlButton *)
- {
- replaceStrW(m_curr->tmpValue, m_edit.GetText());
-
- m_tempItem.fill(int(m_curr - templates)); // copy data from template to event
-
- CMStringW wszText(m_tempItem.formatStringEx(m_curr->tmpValue));
- preview.SetText(wszText);
- gpreview.SendMsg(MTM_UPDATEEX, MTEXT_FLG_RTF, LPARAM(m_tempItem.formatRtf(wszText).c_str()));
- }
-
CCtrlBase preview, gpreview;
CCtrlEdit m_edit;
- CCtrlMButton btnDiscard, btnPreview, bthVarHelp, btnReset;
+ CCtrlMButton btnDiscard, bthVarHelp, btnReset;
CCtrlTreeView m_tree;
public:
@@ -98,13 +87,13 @@ public:
gpreview(this, IDC_GPREVIEW),
btnReset(this, IDC_RESET, Skin_LoadIcon(SKINICON_OTHER_UNDO), LPGEN("Reset to default")),
btnDiscard(this, IDC_DISCARD, g_plugin.getIcon(IDI_RESET), LPGEN("Cancel edit")),
- bthVarHelp(this, IDC_VARHELP, g_plugin.getIcon(IDI_VARHELP), LPGEN("Variables help")),
- btnPreview(this, IDC_UPDATEPREVIEW, g_plugin.getIcon(IDI_PREVIEW), LPGEN("Update preview"))
+ bthVarHelp(this, IDC_VARHELP, g_plugin.getIcon(IDI_VARHELP), LPGEN("Variables help"))
{
btnReset.OnClick = Callback(this, &CTemplateOptsDlg::onClick_Reset);
btnDiscard.OnClick = Callback(this, &CTemplateOptsDlg::onClick_Discard);
- btnPreview.OnClick = Callback(this, &CTemplateOptsDlg::UpdatePreview);
- bthVarHelp.OnClick = Callback(this, &CTemplateOptsDlg::onVarHelp);
+ bthVarHelp.OnClick = Callback(this, &CTemplateOptsDlg::onClick_Help);
+
+ m_edit.OnChange = Callback(this, &CTemplateOptsDlg::onChange_Edit);
m_tree.OnSelChanged = Callback(this, &CTemplateOptsDlg::onSelChanged);
}
@@ -173,6 +162,8 @@ public:
it.tmpValue = nullptr;
}
}
+
+ onChange_Edit();
SaveTemplates();
return true;
}
@@ -191,7 +182,7 @@ public:
m_edit.SetText(TranslateW(m_curr->defvalue));
}
- UpdatePreview(0);
+ onChange_Edit();
NotifyChange();
}
@@ -204,10 +195,10 @@ public:
else
m_edit.SetText(TranslateW(m_curr->defvalue));
- UpdatePreview(0);
+ onChange_Edit();
}
- void onVarHelp(CCtrlButton *)
+ void onClick_Help(CCtrlButton *)
{
CMStringW wszVarHelp;
wszVarHelp.Format(L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s",
@@ -234,6 +225,17 @@ public:
MessageBox(m_hwnd, wszVarHelp, TranslateT("Variables help"), MB_OK);
}
+ void onChange_Edit(CCtrlEdit* = 0)
+ {
+ replaceStrW(m_curr->tmpValue, m_edit.GetText());
+
+ m_tempItem.fill(int(m_curr - templates)); // copy data from template to event
+
+ CMStringW wszText(m_tempItem.formatStringEx(m_curr->tmpValue));
+ preview.SetText(wszText);
+ gpreview.SendMsg(MTM_UPDATEEX, MTEXT_FLG_RTF, LPARAM(m_tempItem.formatRtf(wszText).c_str()));
+ }
+
void onSelChanged(CCtrlTreeView::TEventInfo *)
{
TVITEMEX tvi;
@@ -246,7 +248,6 @@ public:
preview.Disable();
gpreview.Disable();
btnDiscard.Disable();
- btnPreview.Disable();
bthVarHelp.Disable();
HTREEITEM hItem = m_tree.GetChild(tvi.hItem);
@@ -259,7 +260,6 @@ public:
preview.Enable();
gpreview.Enable();
btnDiscard.Enable();
- btnPreview.Enable();
bthVarHelp.Enable();
if (m_curr != nullptr)
@@ -274,7 +274,7 @@ public:
else
m_edit.SetText(TranslateW(m_curr->defvalue));
- UpdatePreview(0);
+ onChange_Edit();
}
};
diff --git a/plugins/NewStory/src/resource.h b/plugins/NewStory/src/resource.h
index a8ddee3bc8..63edcc0340 100644
--- a/plugins/NewStory/src/resource.h
+++ b/plugins/NewStory/src/resource.h
@@ -27,7 +27,6 @@
#define IDI_CALENDAR 124
#define IDI_TPLGROUP 125
#define IDI_RESET 126
-#define IDI_PREVIEW 127
#define IDI_VARHELP 128
#define IDI_TIMETREE 129
#define IDC_USERINFO 1000
@@ -84,7 +83,6 @@
#define IDC_GPREVIEW 1051
#define IDC_RESET 1052
#define IDC_DISCARD 1053
-#define IDC_UPDATEPREVIEW 1054
#define IDC_VARHELP 1055
#define IDC_VSCROLL 1056
#define IDC_DRAWEDGE 1057