ManaPlus
Public Member Functions | Private Attributes
Setup_Theme Class Reference

#include <setup_theme.h>

Inheritance diagram for Setup_Theme:
SetupTab Container ActionListener WidgetListener BasicContainer2 BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 Setup_Theme (const Widget2 *const widget)
 
 ~Setup_Theme ()
 
void apply ()
 
void cancel ()
 
void action (const ActionEvent &event)
 
void updateInfo ()
 
- Public Member Functions inherited from SetupTab
const std::string & getName () const
 
virtual void externalUpdated ()
 
virtual void externalUnloaded ()
 
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 
 ~Container ()
 
bool safeRemove (Widget *const widget)
 
void removeControls ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Private Attributes

LabelmThemeLabel
 
ThemesModelmThemesModel
 
DropDownmThemeDropDown
 
std::string mTheme
 
ThemeInfomInfo
 
FontsModelmFontsModel
 
LabelmFontLabel
 
DropDownmFontDropDown
 
std::string mFont
 
LangListModelmLangListModel
 
LabelmLangLabel
 
DropDownmLangDropDown
 
std::string mLang
 
LabelmBoldFontLabel
 
DropDownmBoldFontDropDown
 
std::string mBoldFont
 
LabelmParticleFontLabel
 
DropDownmParticleFontDropDown
 
std::string mParticleFont
 
LabelmHelpFontLabel
 
DropDownmHelpFontDropDown
 
std::string mHelpFont
 
LabelmSecureFontLabel
 
DropDownmSecureFontDropDown
 
std::string mSecureFont
 
LabelmNpcFontLabel
 
DropDownmNpcFontDropDown
 
std::string mNpcFont
 
LabelmJapanFontLabel
 
DropDownmJapanFontDropDown
 
std::string mJapanFont
 
LabelmChinaFontLabel
 
DropDownmChinaFontDropDown
 
std::string mChinaFont
 
FontSizeChoiceListModelmFontSizeListModel
 
LabelmFontSizeLabel
 
int mFontSize
 
DropDownmFontSizeDropDown
 
FontSizeChoiceListModelmNpcFontSizeListModel
 
LabelmNpcFontSizeLabel
 
int mNpcFontSize
 
DropDownmNpcFontSizeDropDown
 
ButtonmInfoButton
 
std::string mThemeInfo
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from SetupTab
 SetupTab (const Widget2 *const widget)
 
void setName (const std::string &name)
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Definition at line 36 of file setup_theme.h.

Constructor & Destructor Documentation

◆ Setup_Theme()

Setup_Theme::Setup_Theme ( const Widget2 *const  widget)
explicit

Definition at line 60 of file setup_theme.cpp.

60  :
61  SetupTab(widget),
62  // TRANSLATORS: theme settings label
63  mThemeLabel(new Label(this, _("Gui theme"))),
66  false, Modal_false, nullptr, std::string())),
67  mTheme(config.getStringValue("theme")),
70  // TRANSLATORS: theme settings label
71  mFontLabel(new Label(this, _("Main Font"))),
73  false, Modal_false, nullptr, std::string())),
74  mFont(config.getStringValue("font")),
76  // TRANSLATORS: theme settings label
77  mLangLabel(new Label(this, _("Language"))),
79  true, Modal_false, nullptr, std::string())),
80  mLang(config.getStringValue("lang")),
81  // TRANSLATORS: theme settings label
82  mBoldFontLabel(new Label(this, _("Bold font"))),
84  false, Modal_false, nullptr, std::string())),
85  mBoldFont(config.getStringValue("boldFont")),
86  // TRANSLATORS: theme settings label
87  mParticleFontLabel(new Label(this, _("Particle font"))),
89  false, Modal_false, nullptr, std::string())),
90  mParticleFont(config.getStringValue("particleFont")),
91  // TRANSLATORS: theme settings label
92  mHelpFontLabel(new Label(this, _("Help font"))),
94  false, Modal_false, nullptr, std::string())),
95  mHelpFont(config.getStringValue("helpFont")),
96  // TRANSLATORS: theme settings label
97  mSecureFontLabel(new Label(this, _("Secure font"))),
99  false, Modal_false, nullptr, std::string())),
100  mSecureFont(config.getStringValue("secureFont")),
101  // TRANSLATORS: theme settings label
102  mNpcFontLabel(new Label(this, _("Npc font"))),
104  false, Modal_false, nullptr, std::string())),
105  mNpcFont(config.getStringValue("npcFont")),
106  // TRANSLATORS: theme settings label
107  mJapanFontLabel(new Label(this, _("Japanese font"))),
109  false, Modal_false, nullptr, std::string())),
110  mJapanFont(config.getStringValue("japanFont")),
111  // TRANSLATORS: theme settings label
112  mChinaFontLabel(new Label(this, _("Chinese font"))),
114  false, Modal_false, nullptr, std::string())),
115  mChinaFont(config.getStringValue("chinaFont")),
117  // TRANSLATORS: theme settings label
118  mFontSizeLabel(new Label(this, _("Font size"))),
119  mFontSize(config.getIntValue("fontSize")),
121  false, Modal_false, nullptr, std::string())),
123  // TRANSLATORS: theme settings label
124  mNpcFontSizeLabel(new Label(this, _("Npc font size"))),
125  mNpcFontSize(config.getIntValue("npcfontSize")),
127  false, Modal_false, nullptr, std::string())),
128  // TRANSLATORS: button name with information about selected theme
129  mInfoButton(new Button(this, _("i"), ACTION_INFO, BUTTON_SKIN, this)),
130  mThemeInfo()
131 {
132  // TRANSLATORS: theme settings tab name
133  setName(_("Theme"));
134 
159 
160  const std::string skin = Theme::getThemeName();
161  if (!skin.empty())
163  else
165 
166  const std::string str = config.getStringValue("lang");
167  for (int f = 0; f < langs_count; f ++)
168  {
169  if (LANG_NAME[f].value == str)
170  {
172  break;
173  }
174  }
175 
177  config.getStringValue("font")));
179  config.getStringValue("boldFont")));
181  config.getStringValue("particleFont")));
183  config.getStringValue("helpFont")));
185  config.getStringValue("secureFont")));
187  config.getStringValue("npcFont")));
189  config.getStringValue("japanFont")));
191  config.getStringValue("chinaFont")));
192 
193  updateInfo();
194 
195  // Do the layout
196  LayoutHelper h(this);
197  ContainerPlacer place = h.getPlacer(0, 0);
198 
199  place(0, 0, mThemeLabel, 5, 1);
200  place(0, 1, mLangLabel, 5, 1);
201  place(0, 2, mFontSizeLabel, 5, 1);
202  place(0, 3, mNpcFontSizeLabel, 5, 1);
203  place(0, 4, mFontLabel, 5, 1);
204  place(0, 5, mBoldFontLabel, 5, 1);
205  place(0, 6, mParticleFontLabel, 5, 1);
206  place(0, 7, mHelpFontLabel, 5, 1);
207  place(0, 8, mSecureFontLabel, 5, 1);
208  place(0, 9, mNpcFontLabel, 5, 1);
209  place(0, 10, mJapanFontLabel, 5, 1);
210  place(0, 11, mChinaFontLabel, 5, 1);
211 
212  place(6, 0, mThemeDropDown, 10, 1);
213  place(6, 1, mLangDropDown, 10, 1);
214  place(6, 2, mFontSizeDropDown, 10, 1);
215  place(6, 3, mNpcFontSizeDropDown, 10, 1);
216  place(6, 4, mFontDropDown, 10, 1);
217  place(6, 5, mBoldFontDropDown, 10, 1);
218  place(6, 6, mParticleFontDropDown, 10, 1);
219  place(6, 7, mHelpFontDropDown, 10, 1);
220  place(6, 8, mSecureFontDropDown, 10, 1);
221  place(6, 9, mNpcFontDropDown, 10, 1);
222  place(6, 10, mJapanFontDropDown, 10, 1);
223  place(6, 11, mChinaFontDropDown, 10, 1);
224 
225  place(17, 0, mInfoButton, 1, 1);
226 
227  int size = mainGraphics->mWidth - 10;
228  const int maxWidth = mFontSize * 30 + 290;
229  if (size < 465)
230  size = 465;
231  else if (size > maxWidth)
232  size = maxWidth;
233 
234  setDimension(Rect(0, 0, size, 500));
235 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
std::string getStringValue(const std::string &key) const
int getIntValue(const std::string &key) const
void adjustHeight()
Definition: dropdown.cpp:470
void setSelected(int selected)
Definition: dropdown.cpp:514
void setSelectedString(const std::string &str)
Definition: dropdown.cpp:445
int mWidth
Definition: graphics.h:484
Definition: label.h:91
Definition: rect.h:74
void setName(const std::string &name)
Definition: setuptab.h:68
SetupTab(const Widget2 *const widget)
Definition: setuptab.cpp:28
Label * mParticleFontLabel
Definition: setup_theme.h:75
DropDown * mSecureFontDropDown
Definition: setup_theme.h:84
std::string mThemeInfo
Definition: setup_theme.h:110
int mNpcFontSize
Definition: setup_theme.h:106
DropDown * mNpcFontDropDown
Definition: setup_theme.h:88
Label * mNpcFontLabel
Definition: setup_theme.h:87
DropDown * mParticleFontDropDown
Definition: setup_theme.h:76
std::string mLang
Definition: setup_theme.h:69
ThemeInfo * mInfo
Definition: setup_theme.h:58
DropDown * mLangDropDown
Definition: setup_theme.h:68
std::string mParticleFont
Definition: setup_theme.h:77
DropDown * mNpcFontSizeDropDown
Definition: setup_theme.h:107
std::string mBoldFont
Definition: setup_theme.h:73
std::string mTheme
Definition: setup_theme.h:57
std::string mFont
Definition: setup_theme.h:63
Label * mHelpFontLabel
Definition: setup_theme.h:79
Label * mSecureFontLabel
Definition: setup_theme.h:83
Label * mChinaFontLabel
Definition: setup_theme.h:95
FontsModel * mFontsModel
Definition: setup_theme.h:60
ThemesModel * mThemesModel
Definition: setup_theme.h:55
DropDown * mThemeDropDown
Definition: setup_theme.h:56
std::string mHelpFont
Definition: setup_theme.h:81
void updateInfo()
DropDown * mFontSizeDropDown
Definition: setup_theme.h:102
DropDown * mFontDropDown
Definition: setup_theme.h:62
DropDown * mChinaFontDropDown
Definition: setup_theme.h:96
LangListModel * mLangListModel
Definition: setup_theme.h:65
std::string mNpcFont
Definition: setup_theme.h:89
FontSizeChoiceListModel * mNpcFontSizeListModel
Definition: setup_theme.h:104
Label * mJapanFontLabel
Definition: setup_theme.h:91
Label * mLangLabel
Definition: setup_theme.h:67
std::string mJapanFont
Definition: setup_theme.h:93
DropDown * mJapanFontDropDown
Definition: setup_theme.h:92
Label * mNpcFontSizeLabel
Definition: setup_theme.h:105
FontSizeChoiceListModel * mFontSizeListModel
Definition: setup_theme.h:99
DropDown * mBoldFontDropDown
Definition: setup_theme.h:72
Button * mInfoButton
Definition: setup_theme.h:109
Label * mThemeLabel
Definition: setup_theme.h:54
Label * mFontSizeLabel
Definition: setup_theme.h:100
Label * mBoldFontLabel
Definition: setup_theme.h:71
std::string mChinaFont
Definition: setup_theme.h:97
DropDown * mHelpFontDropDown
Definition: setup_theme.h:80
Label * mFontLabel
Definition: setup_theme.h:61
std::string mSecureFont
Definition: setup_theme.h:85
static ThemeInfo * loadInfo(const std::string &themeName)
Definition: theme.cpp:1006
static std::string getThemeName()
Definition: theme.h:70
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
Configuration config
#define _(s)
Definition: gettext.h:35
Graphics * mainGraphics
Definition: graphics.cpp:109
const int langs_count
Definition: langlistmodel.h:42
const Language LANG_NAME[langs_count]
Definition: langlistmodel.h:44
const bool Modal_false
Definition: modal.h:30
int size()
Definition: emotedb.cpp:306
const char * ACTION_CHINA_FONT
Definition: setup_theme.cpp:57
const char * ACTION_HELP_FONT
Definition: setup_theme.cpp:53
const char * ACTION_PARTICLE_FONT
Definition: setup_theme.cpp:52
const char * ACTION_SECURE_FONT
Definition: setup_theme.cpp:54
const char * ACTION_FONT
Definition: setup_theme.cpp:49
const char * ACTION_BOLD_FONT
Definition: setup_theme.cpp:51
const char * ACTION_JAPAN_FONT
Definition: setup_theme.cpp:56
const char * ACTION_LANG
Definition: setup_theme.cpp:50
const char * ACTION_INFO
Definition: setup_theme.cpp:58
const char * ACTION_NPC_FONT
Definition: setup_theme.cpp:55
const char * ACTION_THEME
Definition: setup_theme.cpp:48
std::string getFileName(const std::string &path)

References _, ACTION_BOLD_FONT, ACTION_CHINA_FONT, ACTION_FONT, ACTION_HELP_FONT, ACTION_JAPAN_FONT, ACTION_LANG, ACTION_NPC_FONT, ACTION_PARTICLE_FONT, ACTION_SECURE_FONT, ACTION_THEME, Widget::addActionListener(), DropDown::adjustHeight(), config, getFileName(), LayoutHelper::getPlacer(), Configuration::getStringValue(), Theme::getThemeName(), LANG_NAME, langs_count, mainGraphics, mBoldFontDropDown, mBoldFontLabel, mChinaFontDropDown, mChinaFontLabel, mFontDropDown, mFontLabel, mFontSize, mFontSizeDropDown, mFontSizeLabel, mHelpFontDropDown, mHelpFontLabel, mInfoButton, mJapanFontDropDown, mJapanFontLabel, mLangDropDown, mLangLabel, mNpcFontDropDown, mNpcFontLabel, mNpcFontSize, mNpcFontSizeDropDown, mNpcFontSizeLabel, mParticleFontDropDown, mParticleFontLabel, mSecureFontDropDown, mSecureFontLabel, mThemeDropDown, mThemeLabel, Graphics::mWidth, Widget::setActionEventId(), Widget::setDimension(), SetupTab::setName(), DropDown::setSelected(), DropDown::setSelectedString(), EmoteDB::size(), and updateInfo().

◆ ~Setup_Theme()

Setup_Theme::~Setup_Theme ( )

Member Function Documentation

◆ action()

void Setup_Theme::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 267 of file setup_theme.cpp.

268 {
269  const std::string &eventId = event.getId();
270  if (eventId == ACTION_THEME)
271  {
272  if (mThemeDropDown->getSelected() == 0)
273  mTheme.clear();
274  else
276  updateInfo();
277  }
278  else if (eventId == ACTION_FONT)
279  {
281  }
282  else if (eventId == ACTION_LANG)
283  {
284  const int id = mLangDropDown->getSelected();
285  if (id < 0 || id >= langs_count)
286  mLang.clear();
287  else
288  mLang = LANG_NAME[id].value;
289  }
290  else if (eventId == ACTION_BOLD_FONT)
291  {
293  }
294  else if (eventId == ACTION_PARTICLE_FONT)
295  {
297  }
298  else if (eventId == ACTION_HELP_FONT)
299  {
301  }
302  else if (eventId == ACTION_SECURE_FONT)
303  {
305  }
306  else if (eventId == ACTION_NPC_FONT)
307  {
309  }
310  else if (eventId == ACTION_JAPAN_FONT)
311  {
313  }
314  else if (eventId == ACTION_CHINA_FONT)
315  {
317  }
318  else if (eventId == ACTION_INFO)
319  {
321  // TRANSLATORS: theme info dialog header
322  _("Theme info"),
323  mThemeInfo,
324  // TRANSLATORS: ok dialog button
325  _("OK"),
327  Modal_true,
329  nullptr,
330  600);
331  }
332 }
std::string getSelectedString() const
Definition: dropdown.cpp:461
int getSelected() const
Definition: dropdown.cpp:509
#define CREATEWIDGET(type,...)
Definition: createwidget.h:29
const bool Modal_true
Definition: modal.h:30
const bool ShowCenter_true
Definition: showcenter.h:30
std::string value
Definition: langlistmodel.h:38

References _, ACTION_BOLD_FONT, ACTION_CHINA_FONT, ACTION_FONT, ACTION_HELP_FONT, ACTION_INFO, ACTION_JAPAN_FONT, ACTION_LANG, ACTION_NPC_FONT, ACTION_PARTICLE_FONT, ACTION_SECURE_FONT, ACTION_THEME, CREATEWIDGET, DropDown::getSelected(), DropDown::getSelectedString(), LANG_NAME, langs_count, mBoldFont, mBoldFontDropDown, mChinaFont, mChinaFontDropDown, mFont, mFontDropDown, mHelpFont, mHelpFontDropDown, mJapanFont, mJapanFontDropDown, mLang, mLangDropDown, mNpcFont, mNpcFontDropDown, Modal_true, mParticleFont, mParticleFontDropDown, mSecureFont, mSecureFontDropDown, mTheme, mThemeDropDown, mThemeInfo, DialogType::OK, ShowCenter_true, updateInfo(), and Language::value.

◆ apply()

void Setup_Theme::apply ( )
virtual

Called when the Apply button is pressed in the setup window.

Implements SetupTab.

Definition at line 351 of file setup_theme.cpp.

352 {
353  if (config.getStringValue("theme") != mTheme)
354  {
356  // TRANSLATORS: theme message dialog
357  _("Theme Changed"),
358  // TRANSLATORS: ok dialog message
359  _("Restart your client for the change to take effect."),
360  // TRANSLATORS: ok dialog button
361  _("OK"),
363  Modal_true,
365  nullptr,
366  260);
367  }
368 
369  config.setValue("selectedSkin", "");
370  if (config.getStringValue("theme") != mTheme && (mInfo != nullptr))
371  {
372  updateField(font, mFont);
374  updateField(particleFont, mParticleFont);
375  updateField(helpFont, mHelpFont);
376  updateField(secureFont, mSecureFont);
377  updateField(npcFont, mNpcFont);
378  updateField(japanFont, mJapanFont);
379  updateField(chinaFont, mChinaFont);
380  if (mInfo->fontSize != 0)
381  {
382  const int size = mInfo->fontSize - 9;
383  if (size >= 0)
385  }
386  if (mInfo->npcfontSize != 0)
387  {
388  const int size = mInfo->npcfontSize - 9;
389  if (size >= 0)
391  }
392  if (mInfo->guiAlpha > 0.01F)
393  config.setValue("guialpha", mInfo->guiAlpha);
394  }
395  config.setValue("theme", mTheme);
396  config.setValue("lang", mLang);
397  if (config.getValue("font", "dejavusans.ttf") != mFont
398  || config.getValue("boldFont", "dejavusans-bold.ttf") != mBoldFont
399  || config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
400  || config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont
401  || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont
402  || config.getValue("npcFont", "dejavusans.ttf") != mNpcFont
403  || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont
404  || config.getValue("chinaFont", "fonts/wqy-microhei.ttf")
405  != mChinaFont
406  || config.getIntValue("fontSize")
408  || config.getIntValue("npcfontSize")
410  {
411  config.setValue("font", "fonts/" + getFileName(mFont));
412  config.setValue("boldFont", "fonts/" + getFileName(mBoldFont));
413  config.setValue("particleFont", "fonts/" + getFileName(mParticleFont));
414  config.setValue("helpFont", "fonts/" + getFileName(mHelpFont));
415  config.setValue("secureFont", "fonts/" + getFileName(mSecureFont));
416  config.setValue("npcFont", "fonts/" + getFileName(mNpcFont));
417  config.setValue("japanFont", "fonts/" + getFileName(mJapanFont));
418  config.setValue("chinaFont", "fonts/" + getFileName(mChinaFont));
419  config.setValue("fontSize", mFontSizeDropDown->getSelected() + 9);
420  config.setValue("npcfontSize",
422  gui->updateFonts();
423  }
424 }
#define CAST_S32
Definition: cast.h:30
std::string getValue(const std::string &key, const std::string &deflt) const
void setValue(const std::string &key, const std::string &value)
void updateFonts()
Definition: gui.cpp:824
Gui * gui
Definition: gui.cpp:111
Font * boldFont
Definition: gui.cpp:112
#define updateField(name1, name2)
int npcfontSize
Definition: themeinfo.h:61
int fontSize
Definition: themeinfo.h:60
float guiAlpha
Definition: themeinfo.h:62

References _, boldFont, CAST_S32, config, CREATEWIDGET, ThemeInfo::fontSize, getFileName(), Configuration::getIntValue(), DropDown::getSelected(), Configuration::getStringValue(), ConfigurationObject::getValue(), gui, ThemeInfo::guiAlpha, mBoldFont, mChinaFont, mFont, mFontSizeDropDown, mHelpFont, mInfo, mJapanFont, mLang, mNpcFont, mNpcFontSizeDropDown, Modal_true, mParticleFont, mSecureFont, mTheme, ThemeInfo::npcfontSize, DialogType::OK, DropDown::setSelected(), Configuration::setValue(), ShowCenter_true, EmoteDB::size(), updateField, and Gui::updateFonts().

◆ cancel()

void Setup_Theme::cancel ( )
virtual

Called when the Cancel button is pressed in the setup window.

Implements SetupTab.

Definition at line 334 of file setup_theme.cpp.

335 {
336  mTheme = config.getStringValue("theme");
337  mLang = config.getStringValue("lang");
340  mParticleFont = getFileName(config.getStringValue("particleFont"));
342  mSecureFont = getFileName(config.getStringValue("secureFont"));
346 }

References config, getFileName(), Configuration::getStringValue(), mBoldFont, mChinaFont, mFont, mHelpFont, mJapanFont, mLang, mNpcFont, mParticleFont, mSecureFont, and mTheme.

◆ updateInfo()

void Setup_Theme::updateInfo ( )

Definition at line 247 of file setup_theme.cpp.

248 {
249  delete mInfo;
251  if (mInfo != nullptr)
252  {
253  // TRANSLATORS: theme name
254  mThemeInfo = std::string(_("Name: ")).append(mInfo->name)
255  // TRANSLATORS: theme copyright
256  .append("\n").append(_("Copyright:")).append("\n")
257  .append(mInfo->copyright);
258  }
259  else
260  {
261  mThemeInfo.clear();
262  }
263  replaceAll(mThemeInfo, "\\n", "\n");
264  mInfoButton->setEnabled(!mThemeInfo.empty());
265 }
void setEnabled(const bool enabled)
Definition: widget.h:352
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
std::string name
Definition: themeinfo.h:50
std::string copyright
Definition: themeinfo.h:51

References _, ThemeInfo::copyright, Theme::loadInfo(), mInfo, mInfoButton, mTheme, mThemeInfo, ThemeInfo::name, replaceAll(), and Widget::setEnabled().

Referenced by action(), and Setup_Theme().

Field Documentation

◆ mBoldFont

std::string Setup_Theme::mBoldFont
private

Definition at line 73 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mBoldFontDropDown

DropDown* Setup_Theme::mBoldFontDropDown
private

Definition at line 72 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mBoldFontLabel

Label* Setup_Theme::mBoldFontLabel
private

Definition at line 71 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mChinaFont

std::string Setup_Theme::mChinaFont
private

Definition at line 97 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mChinaFontDropDown

DropDown* Setup_Theme::mChinaFontDropDown
private

Definition at line 96 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mChinaFontLabel

Label* Setup_Theme::mChinaFontLabel
private

Definition at line 95 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mFont

std::string Setup_Theme::mFont
private

Definition at line 63 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mFontDropDown

DropDown* Setup_Theme::mFontDropDown
private

Definition at line 62 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mFontLabel

Label* Setup_Theme::mFontLabel
private

Definition at line 61 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mFontSize

int Setup_Theme::mFontSize
private

Definition at line 101 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mFontSizeDropDown

DropDown* Setup_Theme::mFontSizeDropDown
private

Definition at line 102 of file setup_theme.h.

Referenced by apply(), and Setup_Theme().

◆ mFontSizeLabel

Label* Setup_Theme::mFontSizeLabel
private

Definition at line 100 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mFontSizeListModel

FontSizeChoiceListModel* Setup_Theme::mFontSizeListModel
private

Definition at line 99 of file setup_theme.h.

Referenced by ~Setup_Theme().

◆ mFontsModel

FontsModel* Setup_Theme::mFontsModel
private

Definition at line 60 of file setup_theme.h.

Referenced by ~Setup_Theme().

◆ mHelpFont

std::string Setup_Theme::mHelpFont
private

Definition at line 81 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mHelpFontDropDown

DropDown* Setup_Theme::mHelpFontDropDown
private

Definition at line 80 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mHelpFontLabel

Label* Setup_Theme::mHelpFontLabel
private

Definition at line 79 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mInfo

ThemeInfo* Setup_Theme::mInfo
private

Definition at line 58 of file setup_theme.h.

Referenced by apply(), updateInfo(), and ~Setup_Theme().

◆ mInfoButton

Button* Setup_Theme::mInfoButton
private

Definition at line 109 of file setup_theme.h.

Referenced by Setup_Theme(), and updateInfo().

◆ mJapanFont

std::string Setup_Theme::mJapanFont
private

Definition at line 93 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mJapanFontDropDown

DropDown* Setup_Theme::mJapanFontDropDown
private

Definition at line 92 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mJapanFontLabel

Label* Setup_Theme::mJapanFontLabel
private

Definition at line 91 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mLang

std::string Setup_Theme::mLang
private

Definition at line 69 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mLangDropDown

DropDown* Setup_Theme::mLangDropDown
private

Definition at line 68 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mLangLabel

Label* Setup_Theme::mLangLabel
private

Definition at line 67 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mLangListModel

LangListModel* Setup_Theme::mLangListModel
private

Definition at line 65 of file setup_theme.h.

Referenced by ~Setup_Theme().

◆ mNpcFont

std::string Setup_Theme::mNpcFont
private

Definition at line 89 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mNpcFontDropDown

DropDown* Setup_Theme::mNpcFontDropDown
private

Definition at line 88 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mNpcFontLabel

Label* Setup_Theme::mNpcFontLabel
private

Definition at line 87 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mNpcFontSize

int Setup_Theme::mNpcFontSize
private

Definition at line 106 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mNpcFontSizeDropDown

DropDown* Setup_Theme::mNpcFontSizeDropDown
private

Definition at line 107 of file setup_theme.h.

Referenced by apply(), and Setup_Theme().

◆ mNpcFontSizeLabel

Label* Setup_Theme::mNpcFontSizeLabel
private

Definition at line 105 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mNpcFontSizeListModel

FontSizeChoiceListModel* Setup_Theme::mNpcFontSizeListModel
private

Definition at line 104 of file setup_theme.h.

Referenced by ~Setup_Theme().

◆ mParticleFont

std::string Setup_Theme::mParticleFont
private

Definition at line 77 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mParticleFontDropDown

DropDown* Setup_Theme::mParticleFontDropDown
private

Definition at line 76 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mParticleFontLabel

Label* Setup_Theme::mParticleFontLabel
private

Definition at line 75 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mSecureFont

std::string Setup_Theme::mSecureFont
private

Definition at line 85 of file setup_theme.h.

Referenced by action(), apply(), and cancel().

◆ mSecureFontDropDown

DropDown* Setup_Theme::mSecureFontDropDown
private

Definition at line 84 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mSecureFontLabel

Label* Setup_Theme::mSecureFontLabel
private

Definition at line 83 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mTheme

std::string Setup_Theme::mTheme
private

Definition at line 57 of file setup_theme.h.

Referenced by action(), apply(), cancel(), and updateInfo().

◆ mThemeDropDown

DropDown* Setup_Theme::mThemeDropDown
private

Definition at line 56 of file setup_theme.h.

Referenced by action(), and Setup_Theme().

◆ mThemeInfo

std::string Setup_Theme::mThemeInfo
private

Definition at line 110 of file setup_theme.h.

Referenced by action(), and updateInfo().

◆ mThemeLabel

Label* Setup_Theme::mThemeLabel
private

Definition at line 54 of file setup_theme.h.

Referenced by Setup_Theme().

◆ mThemesModel

ThemesModel* Setup_Theme::mThemesModel
private

Definition at line 55 of file setup_theme.h.

Referenced by ~Setup_Theme().


The documentation for this class was generated from the following files: