mirror of
https://github.com/edubart/otclient.git
synced 2025-06-07 19:34:29 +02:00
Progress in SDL platform
This commit is contained in:
parent
e6ee88af43
commit
d60413f7d6
@ -63,8 +63,8 @@ function init()
|
|||||||
|
|
||||||
-- initialize in fullscreen mode on mobile devices
|
-- initialize in fullscreen mode on mobile devices
|
||||||
if g_app.getOs() == "android" then
|
if g_app.getOs() == "android" then
|
||||||
g_window.setFullscreen(true)
|
|
||||||
g_window.maximize()
|
g_window.maximize()
|
||||||
|
--g_window.setFullscreen(true)
|
||||||
else
|
else
|
||||||
-- window size
|
-- window size
|
||||||
local size = { width = 800, height = 600 }
|
local size = { width = 800, height = 600 }
|
||||||
|
@ -746,6 +746,7 @@ function setupViewMode(mode)
|
|||||||
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
|
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
|
||||||
elseif mode == 2 then
|
elseif mode == 2 then
|
||||||
local limit = limitZoom and not g_game.isGM()
|
local limit = limitZoom and not g_game.isGM()
|
||||||
|
gameMapPanel:setKeepAspectRatio(false)
|
||||||
gameMapPanel:setLimitVisibleRange(limit)
|
gameMapPanel:setLimitVisibleRange(limit)
|
||||||
gameMapPanel:setZoom(11)
|
gameMapPanel:setZoom(11)
|
||||||
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
|
gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
|
||||||
|
@ -48,9 +48,11 @@ bool SpriteManager::loadSpr(std::string file)
|
|||||||
file = g_resources.guessFilePath(file, "spr");
|
file = g_resources.guessFilePath(file, "spr");
|
||||||
|
|
||||||
m_spritesFile = g_resources.openFile(file);
|
m_spritesFile = g_resources.openFile(file);
|
||||||
// cache file buffer to avoid lags from hard drive
|
|
||||||
m_spritesFile->cache();
|
|
||||||
|
|
||||||
|
// cache file buffer to avoid lags from hard drive
|
||||||
|
#ifndef MOBILE
|
||||||
|
m_spritesFile->cache();
|
||||||
|
#endif
|
||||||
m_signature = m_spritesFile->getU32();
|
m_signature = m_spritesFile->getU32();
|
||||||
m_spritesCount = g_game.getFeature(Otc::GameSpritesU32) ? m_spritesFile->getU32() : m_spritesFile->getU16();
|
m_spritesCount = g_game.getFeature(Otc::GameSpritesU32) ? m_spritesFile->getU32() : m_spritesFile->getU16();
|
||||||
m_spritesOffset = m_spritesFile->tell();
|
m_spritesOffset = m_spritesFile->tell();
|
||||||
|
@ -42,11 +42,13 @@ void Logger::log(Fw::LogLevel level, const std::string& message)
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
>>>>>>> Progress in SDL platform
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
if(level == Fw::LogDebug)
|
if(level == Fw::LogDebug)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
static bool ignoreLogs = false;
|
static bool ignoreLogs = false;
|
||||||
if(ignoreLogs)
|
if(ignoreLogs)
|
||||||
return;
|
return;
|
||||||
|
@ -58,6 +58,9 @@ public:
|
|||||||
virtual void setMouseCursor(int cursorId) = 0;
|
virtual void setMouseCursor(int cursorId) = 0;
|
||||||
virtual void restoreMouseCursor() = 0;
|
virtual void restoreMouseCursor() = 0;
|
||||||
|
|
||||||
|
virtual void showInputKeyboard() { }
|
||||||
|
virtual void hideInputKeyboard() { }
|
||||||
|
|
||||||
virtual void setTitle(const std::string& title) = 0;
|
virtual void setTitle(const std::string& title) = 0;
|
||||||
virtual void setMinimumSize(const Size& minimumSize) = 0;
|
virtual void setMinimumSize(const Size& minimumSize) = 0;
|
||||||
virtual void setFullscreen(bool fullscreen) = 0;
|
virtual void setFullscreen(bool fullscreen) = 0;
|
||||||
|
@ -111,6 +111,21 @@ void SDLWindow::maximize()
|
|||||||
SDL_MaximizeWindow(m_window);
|
SDL_MaximizeWindow(m_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Fw::MouseButton translateMouseButton(uint8 sdlButton)
|
||||||
|
{
|
||||||
|
switch(sdlButton) {
|
||||||
|
case SDL_BUTTON_LEFT:
|
||||||
|
return Fw::MouseLeftButton;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_MIDDLE:
|
||||||
|
return Fw::MouseMidButton;
|
||||||
|
break;
|
||||||
|
case SDL_BUTTON_RIGHT:
|
||||||
|
return Fw::MouseRightButton;
|
||||||
|
}
|
||||||
|
return Fw::MouseNoButton;
|
||||||
|
}
|
||||||
|
|
||||||
void SDLWindow::poll()
|
void SDLWindow::poll()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@ -158,13 +173,93 @@ void SDLWindow::poll()
|
|||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseMoveInputEvent;
|
||||||
|
m_inputEvent.mouseMoved = Point(event.motion.xrel, event.motion.yrel);
|
||||||
|
m_inputEvent.mousePos = Point(event.motion.x, event.motion.y);
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN: {
|
||||||
|
Fw::MouseButton button = translateMouseButton(event.button.button);
|
||||||
|
if(button != Fw::MouseNoButton) {
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MousePressInputEvent;
|
||||||
|
m_inputEvent.mouseButton = button;
|
||||||
|
m_mouseButtonStates[button] = true;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
}
|
||||||
|
case SDL_MOUSEBUTTONUP: {
|
||||||
|
Fw::MouseButton button = translateMouseButton(event.button.button);
|
||||||
|
if(button == Fw::MouseNoButton)
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseReleaseInputEvent;
|
||||||
|
m_inputEvent.mouseButton = button;
|
||||||
|
m_mouseButtonStates[button] = false;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case SDL_MOUSEWHEEL: {
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseWheelInputEvent;
|
||||||
|
m_inputEvent.mouseButton = Fw::MouseMidButton;
|
||||||
|
if(event.wheel.y > 0)
|
||||||
|
m_inputEvent.wheelDirection = Fw::MouseWheelUp;
|
||||||
|
else if(event.wheel.y < 0)
|
||||||
|
m_inputEvent.wheelDirection = Fw::MouseWheelUp;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_FINGERDOWN: {
|
||||||
|
Fw::MouseButton button;
|
||||||
|
if(event.tfinger.fingerId == 0)
|
||||||
|
button = Fw::MouseLeftButton;
|
||||||
|
else if(event.tfinger.fingerId == 1)
|
||||||
|
button = Fw::MouseRightButton;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseReleaseInputEvent;
|
||||||
|
m_inputEvent.mouseButton = button;
|
||||||
|
m_mouseButtonStates[button] = true;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_FINGERUP: {
|
||||||
|
Fw::MouseButton button;
|
||||||
|
if(event.tfinger.fingerId == 0)
|
||||||
|
button = Fw::MouseLeftButton;
|
||||||
|
else if(event.tfinger.fingerId == 1)
|
||||||
|
button = Fw::MouseRightButton;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseReleaseInputEvent;
|
||||||
|
m_inputEvent.mouseButton = button;
|
||||||
|
m_mouseButtonStates[button] = false;
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_FINGERMOTION: {
|
||||||
|
m_inputEvent.reset();
|
||||||
|
m_inputEvent.type = Fw::MouseMoveInputEvent;
|
||||||
|
m_inputEvent.mouseMoved = Point(event.tfinger.dx, event.tfinger.dy);
|
||||||
|
m_inputEvent.mousePos = Point(event.tfinger.x, event.tfinger.y);
|
||||||
|
g_logger.info(stdext::format("motion %d %d", event.tfinger.x, event.tfinger.y));
|
||||||
|
if(m_onInputEvent)
|
||||||
|
m_onInputEvent(m_inputEvent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
if(m_onClose)
|
if(m_onClose)
|
||||||
m_onClose();
|
m_onClose();
|
||||||
@ -200,6 +295,16 @@ void SDLWindow::restoreMouseCursor()
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLWindow::showInputKeyboard()
|
||||||
|
{
|
||||||
|
SDL_StartTextInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDLWindow::hideInputKeyboard()
|
||||||
|
{
|
||||||
|
SDL_StopTextInput();
|
||||||
|
}
|
||||||
|
|
||||||
void SDLWindow::setTitle(const std::string& title)
|
void SDLWindow::setTitle(const std::string& title)
|
||||||
{
|
{
|
||||||
SDL_SetWindowTitle(m_window, title.c_str());
|
SDL_SetWindowTitle(m_window, title.c_str());
|
||||||
|
@ -48,6 +48,9 @@ public:
|
|||||||
void setMouseCursor(int cursorId);
|
void setMouseCursor(int cursorId);
|
||||||
void restoreMouseCursor();
|
void restoreMouseCursor();
|
||||||
|
|
||||||
|
void showInputKeyboard();
|
||||||
|
void hideInputKeyboard();
|
||||||
|
|
||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
void setMinimumSize(const Size& minimumSize);
|
void setMinimumSize(const Size& minimumSize);
|
||||||
void setFullscreen(bool fullscreen);
|
void setFullscreen(bool fullscreen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user