Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To lua pp #678

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/include/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
};

Expand Down
20 changes: 10 additions & 10 deletions src/tolua/ui.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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
Expand Down
44 changes: 24 additions & 20 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ static std::stack<MenuScreen *> MenuStack;
-- Functions
----------------------------------------------------------------------------*/

#if USING_TOLUAPP

void addActionListener(gcn::Widget *widget, gcn::ActionListener *actionListener)
{
// gcn::Widget::addActionListener is no longer virtual
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
----------------------------------------------------------------------------*/
Expand Down
Loading