improve window moving, minor changes to enable others apps use otclient framework
This commit is contained in:
parent
3f4ad7977c
commit
fc65f99ead
|
@ -3,7 +3,6 @@ Module
|
||||||
description: Create the about window
|
description: Create the about window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- core
|
- core
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,8 @@ Module
|
||||||
description: Handles the background of the login screen
|
description: Handles the background of the login screen
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- core
|
- core
|
||||||
- topmenu
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'background'
|
require 'background'
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Manage chat window
|
description: Manage chat window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'chat'
|
require 'chat'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -6,6 +6,7 @@ Window < UIWindow
|
||||||
head height: 20
|
head height: 20
|
||||||
head text align: center
|
head text align: center
|
||||||
move policy: free
|
move policy: free
|
||||||
|
stackable: true
|
||||||
border-image:
|
border-image:
|
||||||
source: /core_styles/images/window.png
|
source: /core_styles/images/window.png
|
||||||
border: 4
|
border: 4
|
||||||
|
|
|
@ -3,12 +3,6 @@ Module
|
||||||
description: Manages enter game and character list windows
|
description: Manages enter game and character list windows
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
- topmenu
|
|
||||||
- background
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'entergame'
|
require 'entergame'
|
||||||
require 'characterlist'
|
require 'characterlist'
|
||||||
|
|
|
@ -17,6 +17,7 @@ function Game.createInterface()
|
||||||
Background.hide()
|
Background.hide()
|
||||||
CharacterList.destroyLoadBox()
|
CharacterList.destroyLoadBox()
|
||||||
Game.gameUi = loadUI('/game/game.otui', UI.root)
|
Game.gameUi = loadUI('/game/game.otui', UI.root)
|
||||||
|
UI.root:moveChildToIndex(Game.gameUi, 1)
|
||||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
||||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
||||||
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
||||||
|
|
|
@ -3,14 +3,6 @@ Module
|
||||||
description: Create the game interface, where the ingame stuff starts
|
description: Create the game interface, where the ingame stuff starts
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
- tibiafiles
|
|
||||||
- topmenu
|
|
||||||
- entergame
|
|
||||||
- background
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'game'
|
require 'game'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Displays health and mana points
|
description: Displays health and mana points
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'health_mana'
|
require 'health_mana'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
Module
|
Module
|
||||||
name: equipments
|
name: inventory
|
||||||
description: View local player equipments window
|
description: View local player equipments window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'inventory'
|
require 'inventory'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Create the options window
|
description: Create the options window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- core
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'options'
|
require 'options'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
Module
|
||||||
|
name: otclient
|
||||||
|
description: Load all other otclient modules
|
||||||
|
author: OTClient team
|
||||||
|
website: https://github.com/edubart/otclient
|
||||||
|
dependencies:
|
||||||
|
- core
|
||||||
|
- background
|
||||||
|
- topmenu
|
||||||
|
- game
|
||||||
|
- health_mana
|
||||||
|
- inventory
|
||||||
|
- skills
|
||||||
|
- viplist
|
||||||
|
- textmessage
|
||||||
|
- chat
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Manage skills window
|
description: Manage skills window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'skills'
|
require 'skills'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Manage game text messages
|
description: Manage game text messages
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'textmessage'
|
require 'textmessage'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -3,9 +3,11 @@ Module
|
||||||
description: Create the top menu
|
description: Create the top menu
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- core
|
- core
|
||||||
|
- entergame
|
||||||
|
- options
|
||||||
|
- about
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'topmenu'
|
require 'topmenu'
|
||||||
|
|
|
@ -3,10 +3,6 @@ Module
|
||||||
description: Manage vip list window
|
description: Manage vip list window
|
||||||
author: OTClient team
|
author: OTClient team
|
||||||
website: https://github.com/edubart/otclient
|
website: https://github.com/edubart/otclient
|
||||||
autoLoad: true
|
|
||||||
dependencies:
|
|
||||||
- game
|
|
||||||
|
|
||||||
onLoad: |
|
onLoad: |
|
||||||
require 'viplist'
|
require 'viplist'
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -8,6 +8,7 @@ MiniWindow
|
||||||
|
|
||||||
TextList
|
TextList
|
||||||
id: vipList
|
id: vipList
|
||||||
|
border-image: ~
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
margin.top: 26
|
margin.top: 26
|
||||||
margin.bottom: 6
|
margin.bottom: 6
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
ResourceManager g_resources;
|
ResourceManager g_resources;
|
||||||
|
|
||||||
void ResourceManager::init(const char* argv0)
|
void ResourceManager::init(const char* argv0, const char *appName)
|
||||||
{
|
{
|
||||||
PHYSFS_init(argv0);
|
PHYSFS_init(argv0);
|
||||||
|
|
||||||
|
@ -39,11 +39,12 @@ void ResourceManager::init(const char* argv0)
|
||||||
std::string possibleDirs[] = { "modules",
|
std::string possibleDirs[] = { "modules",
|
||||||
baseDir + "modules",
|
baseDir + "modules",
|
||||||
baseDir + "../modules",
|
baseDir + "../modules",
|
||||||
baseDir + "../share/otclient/modules",
|
baseDir + "../share/" + appName + "/otclient/modules",
|
||||||
"" };
|
"" };
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for(const std::string& dir : possibleDirs) {
|
for(const std::string& dir : possibleDirs) {
|
||||||
|
dump << dir;
|
||||||
if(g_resources.addToSearchPath(dir)) {
|
if(g_resources.addToSearchPath(dir)) {
|
||||||
logInfo("Using modules directory '", dir.c_str(), "'");
|
logInfo("Using modules directory '", dir.c_str(), "'");
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
class ResourceManager
|
class ResourceManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init(const char* argv0);
|
void init(const char* argv0, const char *appName);
|
||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
/// Set output files directory
|
/// Set output files directory
|
||||||
|
|
|
@ -49,6 +49,7 @@ void LuaInterface::registerFunctions()
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setSize", &UIWidget::resize);
|
g_lua.bindClassMemberFunction<UIWidget>("setSize", &UIWidget::resize);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getPosition", &UIWidget::getPosition);
|
g_lua.bindClassMemberFunction<UIWidget>("getPosition", &UIWidget::getPosition);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("moveTo", &UIWidget::moveTo);
|
g_lua.bindClassMemberFunction<UIWidget>("moveTo", &UIWidget::moveTo);
|
||||||
|
g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getParent", &UIWidget::getParent);
|
g_lua.bindClassMemberFunction<UIWidget>("getParent", &UIWidget::getParent);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("setParent", &UIWidget::setParent);
|
g_lua.bindClassMemberFunction<UIWidget>("setParent", &UIWidget::setParent);
|
||||||
g_lua.bindClassMemberFunction<UIWidget>("getBackgroundColor", &UIWidget::getBackgroundColor);
|
g_lua.bindClassMemberFunction<UIWidget>("getBackgroundColor", &UIWidget::getBackgroundColor);
|
||||||
|
|
|
@ -28,6 +28,7 @@ UIVerticalLayout::UIVerticalLayout(UIWidgetPtr parentWidget)
|
||||||
: UILayout(parentWidget)
|
: UILayout(parentWidget)
|
||||||
{
|
{
|
||||||
m_alignBottom = false;
|
m_alignBottom = false;
|
||||||
|
m_padding = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
|
void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
|
@ -37,6 +38,8 @@ void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||||
if(node->tag() == "align bottom")
|
if(node->tag() == "align bottom")
|
||||||
m_alignBottom = node->value<bool>();
|
m_alignBottom = node->value<bool>();
|
||||||
|
else if(node->tag() == "padding")
|
||||||
|
m_padding = node->value<int>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +48,6 @@ void UIVerticalLayout::update()
|
||||||
UIWidgetPtr parentWidget = getParentWidget();
|
UIWidgetPtr parentWidget = getParentWidget();
|
||||||
UIWidgetList widgets = parentWidget->getChildren();
|
UIWidgetList widgets = parentWidget->getChildren();
|
||||||
|
|
||||||
// sort by Y pos
|
|
||||||
std::sort(widgets.begin(), widgets.end(),
|
|
||||||
[](const UIWidgetPtr& first, const UIWidgetPtr& second) -> bool {
|
|
||||||
return first->getY() < second->getY();
|
|
||||||
});
|
|
||||||
|
|
||||||
if(m_alignBottom)
|
if(m_alignBottom)
|
||||||
std::reverse(widgets.begin(), widgets.end());
|
std::reverse(widgets.begin(), widgets.end());
|
||||||
|
|
||||||
|
@ -68,13 +65,12 @@ void UIVerticalLayout::update()
|
||||||
}
|
}
|
||||||
widget->setRect(Rect(pos, size));
|
widget->setRect(Rect(pos, size));
|
||||||
pos.y += (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
|
pos.y += (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
|
||||||
|
pos.y += m_padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIVerticalLayout::addWidget(const UIWidgetPtr& widget)
|
void UIVerticalLayout::addWidget(const UIWidgetPtr& widget)
|
||||||
{
|
{
|
||||||
// needed to be correctly sorted on the following update
|
|
||||||
widget->setY(9999);
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_alignBottom;
|
bool m_alignBottom;
|
||||||
|
int m_padding;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -497,6 +497,18 @@ void UIWidget::moveChildToTop(const UIWidgetPtr& child)
|
||||||
m_children.push_back(child);
|
m_children.push_back(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIWidget::moveChildToIndex(const UIWidgetPtr& child, int index)
|
||||||
|
{
|
||||||
|
if(!child)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// remove and push child again
|
||||||
|
auto it = std::find(m_children.begin(), m_children.end(), child);
|
||||||
|
assert(it != m_children.end());
|
||||||
|
m_children.erase(it);
|
||||||
|
m_children.insert(m_children.begin() + index - 1, child);
|
||||||
|
}
|
||||||
|
|
||||||
void UIWidget::lockChild(const UIWidgetPtr& child)
|
void UIWidget::lockChild(const UIWidgetPtr& child)
|
||||||
{
|
{
|
||||||
if(!child)
|
if(!child)
|
||||||
|
@ -572,6 +584,17 @@ bool UIWidget::isChildLocked(const UIWidgetPtr& child)
|
||||||
return it != m_lockedChildren.end();
|
return it != m_lockedChildren.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int UIWidget::getChildIndex(const UIWidgetPtr& child)
|
||||||
|
{
|
||||||
|
int index = 1;
|
||||||
|
for(auto it = m_children.begin(); it != m_children.end(); ++it) {
|
||||||
|
if(*it == child)
|
||||||
|
return index;
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void UIWidget::updateParentLayout()
|
void UIWidget::updateParentLayout()
|
||||||
{
|
{
|
||||||
if(UIWidgetPtr parent = getParent())
|
if(UIWidgetPtr parent = getParent())
|
||||||
|
|
|
@ -139,9 +139,11 @@ public:
|
||||||
void focusNextChild(Fw::FocusReason reason);
|
void focusNextChild(Fw::FocusReason reason);
|
||||||
void focusPreviousChild(Fw::FocusReason reason);
|
void focusPreviousChild(Fw::FocusReason reason);
|
||||||
void moveChildToTop(const UIWidgetPtr& child);
|
void moveChildToTop(const UIWidgetPtr& child);
|
||||||
|
void moveChildToIndex(const UIWidgetPtr& child, int index);
|
||||||
void lockChild(const UIWidgetPtr& child);
|
void lockChild(const UIWidgetPtr& child);
|
||||||
void unlockChild(const UIWidgetPtr& child);
|
void unlockChild(const UIWidgetPtr& child);
|
||||||
bool isChildLocked(const UIWidgetPtr& child);
|
bool isChildLocked(const UIWidgetPtr& child);
|
||||||
|
int getChildIndex(const UIWidgetPtr& child);
|
||||||
|
|
||||||
void updateParentLayout();
|
void updateParentLayout();
|
||||||
void updateLayout();
|
void updateLayout();
|
||||||
|
|
|
@ -32,6 +32,7 @@ void UIWindow::setup()
|
||||||
m_moving = false;
|
m_moving = false;
|
||||||
m_movePolicy = DONT_MOVE;
|
m_movePolicy = DONT_MOVE;
|
||||||
m_headHeight = 0;
|
m_headHeight = 0;
|
||||||
|
m_oldIndex = -1;
|
||||||
m_titleAlign = Fw::AlignCenter;
|
m_titleAlign = Fw::AlignCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,15 +104,6 @@ void UIWindow::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
|
||||||
setRect(boundRect);
|
setRect(boundRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWindow::onFocusChange(bool focused, Fw::FocusReason reason)
|
|
||||||
{
|
|
||||||
// when a window is focused it goes to the top
|
|
||||||
if(focused) {
|
|
||||||
if(UIWidgetPtr parent = getParent())
|
|
||||||
parent->moveChildToTop(asUIWidget());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
{
|
{
|
||||||
if(m_movePolicy != DONT_MOVE) {
|
if(m_movePolicy != DONT_MOVE) {
|
||||||
|
@ -120,6 +112,9 @@ bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
if(!clickedChild || clickedChild->isPhantom()) {
|
if(!clickedChild || clickedChild->isPhantom()) {
|
||||||
m_moving = true;
|
m_moving = true;
|
||||||
m_movingReference = mousePos - getRect().topLeft();
|
m_movingReference = mousePos - getRect().topLeft();
|
||||||
|
m_oldIndex = getParent()->getChildIndex(asUIWidget());
|
||||||
|
m_oldPos = getPosition();
|
||||||
|
getParent()->moveChildToTop(asUIWidget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UIWidget::onMousePress(mousePos, button);
|
return UIWidget::onMousePress(mousePos, button);
|
||||||
|
@ -128,6 +123,25 @@ bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
bool UIWindow::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
bool UIWindow::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||||
{
|
{
|
||||||
if(m_moving) {
|
if(m_moving) {
|
||||||
|
if(m_movePolicy == FREE_UPDATED_MOVE) {
|
||||||
|
UIWidgetPtr parent = getParent();
|
||||||
|
|
||||||
|
// restore position before move
|
||||||
|
parent->moveChildToIndex(asUIWidget(), m_oldIndex);
|
||||||
|
moveTo(m_oldPos);
|
||||||
|
|
||||||
|
// calculate new index
|
||||||
|
int newIndex;
|
||||||
|
for(newIndex=parent->getChildCount();newIndex>1;--newIndex) {
|
||||||
|
UIWidgetPtr child = parent->getChildByIndex(newIndex);
|
||||||
|
if(mousePos.y >= child->getRect().top())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the new index
|
||||||
|
parent->moveChildToIndex(asUIWidget(), newIndex);
|
||||||
|
updateParentLayout();
|
||||||
|
}
|
||||||
m_moving = false;
|
m_moving = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -138,8 +152,6 @@ bool UIWindow::onMouseMove(const Point& mousePos, const Point& mouseMoved)
|
||||||
{
|
{
|
||||||
if(m_moving) {
|
if(m_moving) {
|
||||||
moveTo(mousePos - m_movingReference);
|
moveTo(mousePos - m_movingReference);
|
||||||
if(m_movePolicy == FREE_UPDATED_MOVE)
|
|
||||||
updateParentLayout();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return UIWidget::onMouseMove(mousePos, mouseMoved);
|
return UIWidget::onMouseMove(mousePos, mouseMoved);
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||||
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
|
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
|
||||||
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
|
|
||||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||||
|
@ -54,6 +53,8 @@ private:
|
||||||
bool m_moving;
|
bool m_moving;
|
||||||
MovePolicy m_movePolicy;
|
MovePolicy m_movePolicy;
|
||||||
Point m_movingReference;
|
Point m_movingReference;
|
||||||
|
Point m_oldPos;
|
||||||
|
int m_oldIndex;
|
||||||
|
|
||||||
// styling
|
// styling
|
||||||
BorderImagePtr m_headImage;
|
BorderImagePtr m_headImage;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
namespace Otc
|
namespace Otc
|
||||||
{
|
{
|
||||||
static const char* AppName = "OTClient";
|
static const char* AppName = "OTClient";
|
||||||
|
static const char* AppPathName = "otclient";
|
||||||
static const char* AppVersion = "0.4.0";
|
static const char* AppVersion = "0.4.0";
|
||||||
|
|
||||||
static const char* CipsoftPublicRSA = "1321277432058722840622950990822933849527763264961655079678763618"
|
static const char* CipsoftPublicRSA = "1321277432058722840622950990822933849527763264961655079678763618"
|
||||||
|
|
|
@ -105,9 +105,7 @@ void Game::processTextMessage(int type, const std::string& message)
|
||||||
|
|
||||||
void Game::processInventoryChange(int slot, const ItemPtr& item)
|
void Game::processInventoryChange(int slot, const ItemPtr& item)
|
||||||
{
|
{
|
||||||
g_dispatcher.addEvent([slot, item] {
|
|
||||||
g_lua.callGlobalField("Game","onInventoryChange", slot, item);
|
g_lua.callGlobalField("Game","onInventoryChange", slot, item);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::walk(Otc::Direction direction)
|
void Game::walk(Otc::Direction direction)
|
||||||
|
|
|
@ -67,7 +67,7 @@ private:
|
||||||
|
|
||||||
void parsePlayerLogin(InputMessage& msg);
|
void parsePlayerLogin(InputMessage& msg);
|
||||||
void parseGMActions(InputMessage& msg);
|
void parseGMActions(InputMessage& msg);
|
||||||
void parseErrorMessage(InputMessage& msg);
|
void parseLoginError(InputMessage& msg);
|
||||||
void parseFYIMessage(InputMessage& msg);
|
void parseFYIMessage(InputMessage& msg);
|
||||||
void parseWaitList(InputMessage& msg);
|
void parseWaitList(InputMessage& msg);
|
||||||
void parsePing(InputMessage&);
|
void parsePing(InputMessage&);
|
||||||
|
|
|
@ -46,7 +46,7 @@ void ProtocolGame::parseMessage(InputMessage& msg)
|
||||||
parseGMActions(msg);
|
parseGMActions(msg);
|
||||||
break;
|
break;
|
||||||
case Otc::GameServerLoginError:
|
case Otc::GameServerLoginError:
|
||||||
parseErrorMessage(msg);
|
parseLoginError(msg);
|
||||||
break;
|
break;
|
||||||
case Otc::GameServerLoginAdvice:
|
case Otc::GameServerLoginAdvice:
|
||||||
parseFYIMessage(msg);
|
parseFYIMessage(msg);
|
||||||
|
@ -274,10 +274,10 @@ void ProtocolGame::parseGMActions(InputMessage& msg)
|
||||||
msg.getU8();
|
msg.getU8();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseErrorMessage(InputMessage& msg)
|
void ProtocolGame::parseLoginError(InputMessage& msg)
|
||||||
{
|
{
|
||||||
std::string error = msg.getString();
|
std::string error = msg.getString();
|
||||||
g_game.processLoginError(error);
|
g_dispatcher.addEvent(std::bind(&Game::processLoginError, &g_game, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseFYIMessage(InputMessage& msg)
|
void ProtocolGame::parseFYIMessage(InputMessage& msg)
|
||||||
|
@ -454,13 +454,13 @@ void ProtocolGame::parseAddInventoryItem(InputMessage& msg)
|
||||||
{
|
{
|
||||||
uint8 slot = msg.getU8();
|
uint8 slot = msg.getU8();
|
||||||
ItemPtr item = internalGetItem(msg, 0xFFFF);
|
ItemPtr item = internalGetItem(msg, 0xFFFF);
|
||||||
g_game.processInventoryChange(slot, item);
|
g_dispatcher.addEvent(std::bind(&Game::processInventoryChange, &g_game, slot, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseRemoveInventoryItem(InputMessage& msg)
|
void ProtocolGame::parseRemoveInventoryItem(InputMessage& msg)
|
||||||
{
|
{
|
||||||
uint8 slot = msg.getU8();
|
uint8 slot = msg.getU8();
|
||||||
g_game.processInventoryChange(slot, ItemPtr(nullptr));
|
g_dispatcher.addEvent(std::bind(&Game::processInventoryChange, &g_game, slot, ItemPtr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseOpenShopWindow(InputMessage& msg)
|
void ProtocolGame::parseOpenShopWindow(InputMessage& msg)
|
||||||
|
@ -771,7 +771,6 @@ void ProtocolGame::parseTextMessage(InputMessage& msg)
|
||||||
uint8 type = msg.getU8();
|
uint8 type = msg.getU8();
|
||||||
std::string message = msg.getString();
|
std::string message = msg.getString();
|
||||||
|
|
||||||
// must be scheduled because the map may not exist yet
|
|
||||||
g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, type, message));
|
g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, type, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void OTClient::init(std::vector<std::string> args)
|
||||||
registerLuaFunctions();
|
registerLuaFunctions();
|
||||||
|
|
||||||
// initialize resources
|
// initialize resources
|
||||||
g_resources.init(args[0].c_str());
|
g_resources.init(args[0].c_str(), Otc::AppPathName);
|
||||||
|
|
||||||
// load configurations
|
// load configurations
|
||||||
loadConfigurations();
|
loadConfigurations();
|
||||||
|
@ -90,6 +90,7 @@ void OTClient::init(std::vector<std::string> args)
|
||||||
|
|
||||||
// discover and load modules
|
// discover and load modules
|
||||||
g_modules.discoverAndLoadModules();
|
g_modules.discoverAndLoadModules();
|
||||||
|
g_modules.getModule("otclient")->load();
|
||||||
|
|
||||||
// now that everything is initialized, setup configurations
|
// now that everything is initialized, setup configurations
|
||||||
setupConfigurations();
|
setupConfigurations();
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
void setOnClose(const SimpleCallback& onCloseCallback) { m_onCloseCallback = onCloseCallback; }
|
void setOnClose(const SimpleCallback& onCloseCallback) { m_onCloseCallback = onCloseCallback; }
|
||||||
SimpleCallback getOnClose() const { return m_onCloseCallback; }
|
SimpleCallback getOnClose() const { return m_onCloseCallback; }
|
||||||
|
|
||||||
|
static void registerLuaFunctions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Set default configurations and load the user configurations
|
/// Set default configurations and load the user configurations
|
||||||
void loadConfigurations();
|
void loadConfigurations();
|
||||||
|
@ -66,8 +68,6 @@ private:
|
||||||
void setupConfigurations();
|
void setupConfigurations();
|
||||||
void saveConfigurations();
|
void saveConfigurations();
|
||||||
|
|
||||||
void registerLuaFunctions();
|
|
||||||
|
|
||||||
bool m_running;
|
bool m_running;
|
||||||
bool m_stopping;
|
bool m_stopping;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue