From 24a001ae3d255976c0e279ca9d50ce3ba147822e Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Mon, 20 May 2024 10:12:24 +0200 Subject: [PATCH 1/2] Remove tolua "renaming" into **same** name. --- src/tolua/ui.pkg | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tolua/ui.pkg b/src/tolua/ui.pkg index 79a8d16d90..56103abaaa 100644 --- a/src/tolua/ui.pkg +++ b/src/tolua/ui.pkg @@ -277,33 +277,33 @@ class Widget virtual void setY(int y); virtual int getY() const; virtual void setPosition(int x, int y); - virtual void setFrameSize@ setBorderSize(int width); + virtual void setFrameSize @ setBorderSize(int width); virtual unsigned int getFrameSize @ getBorderSize() const; virtual void setEnabled(bool enabled); virtual bool isEnabled() const; virtual void setVisible(bool visible); virtual bool isVisible() const; - tolua_outside virtual void setDirty @ setDirty(bool isDirty); + tolua_outside virtual void setDirty(bool isDirty); - tolua_outside virtual void setBaseColor @ setBaseColor(const Color color); + tolua_outside virtual void setBaseColor(const Color color); virtual const Color &getBaseColor() const; virtual void setForegroundColor(const Color color); virtual const Color &getForegroundColor() const; - tolua_outside virtual void setBackgroundColor @ setBackgroundColor(const Color color); + tolua_outside virtual void setBackgroundColor(const Color color); virtual const Color &getBackgroundColor() const; - tolua_outside virtual void setDisabledColor @ setDisabledColor(const Color color); + tolua_outside virtual void setDisabledColor(const Color color); static void setGlobalFont(CFont *font); - tolua_outside virtual void setFont @ setFont(CFont *font); + tolua_outside virtual void setFont(CFont *font); virtual int getHotKey() const; virtual void setHotKey(const int key); - tolua_outside virtual void setHotKey @ setHotKey(const char *key); + tolua_outside virtual void setHotKey(const char *key); virtual void requestFocus(); - tolua_outside virtual void addActionListener @ addActionListener(LuaActionListener *actionListener); + tolua_outside virtual void addActionListener(LuaActionListener *actionListener); virtual void addMouseListener(LuaActionListener *actionListener); virtual void addKeyListener(LuaActionListener *actionListener); }; @@ -348,8 +348,8 @@ class ScrollArea : public BasicContainer virtual Widget *getContent(); virtual void setScrollbarWidth(int width); virtual int getScrollbarWidth(); - tolua_outside virtual void scrollToBottom @ scrollToBottom(); - tolua_outside virtual void scrollToTop @ scrollToTop(); + tolua_outside virtual void scrollToBottom(); + tolua_outside virtual void scrollToTop(); }; class ImageWidget : public Widget From 025e9a510da5fcce535cdfea387f69e06f23d894 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Mon, 20 May 2024 23:55:28 +0200 Subject: [PATCH 2/2] Use `#if USING_TOLUAPP` in widgets.h/cpp --- src/include/widgets.h | 5 +++-- src/ui/widgets.cpp | 44 +++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/include/widgets.h b/src/include/widgets.h index ff7179a7b0..5e83d27394 100644 --- a/src/include/widgets.h +++ b/src/include/widgets.h @@ -45,7 +45,7 @@ void initGuichan(); void freeGuichan(); void handleInput(const SDL_Event *event); -#if 1 // ToLua++ +#if USING_TOLUAPP void addActionListener(gcn::Widget *, gcn::ActionListener *); void setBackgroundColor(gcn::Widget *, const gcn::Color &); void setBaseColor(gcn::Widget *, const gcn::Color &color); @@ -102,7 +102,8 @@ class ButtonWidget : public gcn::Button public: explicit ButtonWidget(const std::string &caption) : Button(caption) { - ::setHotKey(this, caption.c_str()); + gcn::Key key = GetHotKey(caption); + setHotKey(key.getValue()); } }; diff --git a/src/ui/widgets.cpp b/src/ui/widgets.cpp index 818e3b880a..5408fb06f1 100644 --- a/src/ui/widgets.cpp +++ b/src/ui/widgets.cpp @@ -63,6 +63,8 @@ static std::stack MenuStack; -- Functions ----------------------------------------------------------------------------*/ +#if USING_TOLUAPP + void addActionListener(gcn::Widget *widget, gcn::ActionListener *actionListener) { // gcn::Widget::addActionListener is no longer virtual @@ -129,6 +131,28 @@ void setFont(gcn::Widget *widget, gcn::Font *font) } } +void setHotKey(gcn::Widget* widget, const char *keyStr) +{ + if (widget && keyStr) { + gcn::Key key = GetHotKey(keyStr); + widget->setHotKey(key.getValue()); + } +} + +void scrollToBottom(gcn::ScrollArea *scrollArea) +{ + Assert(scrollArea); + scrollArea->setVerticalScrollAmount(scrollArea->getVerticalMaxScroll()); +} + +void scrollToTop(gcn::ScrollArea *scrollArea) +{ + Assert(scrollArea); + scrollArea->setVerticalScrollAmount(0); +} + +#endif + static void MenuHandleMouseMove(const PixelPos &screenPos) { PixelPos pos(screenPos); @@ -224,26 +248,6 @@ void DrawGuichanWidgets() } } -void setHotKey(gcn::Widget* widget, const char *keyStr) -{ - if (widget && keyStr) { - gcn::Key key = GetHotKey(keyStr); - widget->setHotKey(key.getValue()); - } -} - -void scrollToBottom(gcn::ScrollArea *scrollArea) -{ - Assert(scrollArea); - scrollArea->setVerticalScrollAmount(scrollArea->getVerticalMaxScroll()); -} - -void scrollToTop(gcn::ScrollArea *scrollArea) -{ - Assert(scrollArea); - scrollArea->setVerticalScrollAmount(0); -} - /*---------------------------------------------------------------------------- -- LuaActionListener ----------------------------------------------------------------------------*/