mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
fix outfit glitches, init combobox, move shaders, remove unused particles files, create timer utility
This commit is contained in:
@@ -128,6 +128,7 @@ SET(framework_SOURCES ${framework_SOURCES}
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/modulemanager.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/module.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/clock.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/core/timer.cpp
|
||||
|
||||
# framework net
|
||||
${CMAKE_CURRENT_LIST_DIR}/net/connection.cpp
|
||||
|
@@ -103,11 +103,10 @@ void Application::init(const std::vector<std::string>& args, int appFlags)
|
||||
|
||||
// fire first resize
|
||||
resize(g_window.getSize());
|
||||
}
|
||||
|
||||
// finally show the window
|
||||
if(m_appFlags & Fw::AppEnableGraphics)
|
||||
g_window.show();
|
||||
// display window when the application starts running
|
||||
g_dispatcher.addEvent([]{ g_window.show(); });
|
||||
}
|
||||
|
||||
if(m_appFlags & Fw::AppEnableModules)
|
||||
g_modules.discoverModulesPath();
|
||||
|
@@ -48,20 +48,5 @@ private:
|
||||
|
||||
extern Clock g_clock;
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
Timer() { restart(); }
|
||||
|
||||
void restart() { m_startTicks = g_clock.ticks(); }
|
||||
|
||||
ticks_t startTicks() { return m_startTicks; }
|
||||
ticks_t ticksElapsed() { return g_clock.ticks() - m_startTicks; }
|
||||
double timeElapsed() { return ticksElapsed()/1000.0; }
|
||||
|
||||
private:
|
||||
ticks_t m_startTicks;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -30,7 +30,6 @@ void EventDispatcher::flush()
|
||||
{
|
||||
poll();
|
||||
|
||||
m_eventList.clear();
|
||||
while(!m_scheduledEventList.empty())
|
||||
m_scheduledEventList.pop();
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
Logger g_logger;
|
||||
|
||||
Logger::Logger() : m_terminated(false)
|
||||
Logger::Logger()
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -48,7 +48,6 @@ public:
|
||||
private:
|
||||
std::list<LogMessage> m_logMessages;
|
||||
OnLogCallback m_onLog;
|
||||
bool m_terminated;
|
||||
};
|
||||
|
||||
extern Logger g_logger;
|
||||
|
@@ -48,14 +48,14 @@ void Module::discover(const OTMLNodePtr& moduleNode)
|
||||
|
||||
// set onLoad callback
|
||||
if(OTMLNodePtr node = moduleNode->get("onLoad")) {
|
||||
g_lua.loadFunction(node->value<std::string>(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.useValue();
|
||||
m_loadCallback = g_lua.polymorphicPop<BooleanCallback>();
|
||||
}
|
||||
|
||||
// set onUnload callback
|
||||
if(OTMLNodePtr node = moduleNode->get("onUnload")) {
|
||||
g_lua.loadFunction(node->value<std::string>(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
|
||||
g_lua.useValue();
|
||||
m_unloadCallback = g_lua.polymorphicPop<SimpleCallback>();
|
||||
}
|
||||
|
35
src/framework/core/timer.cpp
Normal file
35
src/framework/core/timer.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "timer.h"
|
||||
#include "clock.h"
|
||||
|
||||
void Timer::restart()
|
||||
{
|
||||
m_startTicks = g_clock.ticks();
|
||||
}
|
||||
|
||||
ticks_t Timer::ticksElapsed()
|
||||
{
|
||||
return g_clock.ticks() - m_startTicks;
|
||||
}
|
43
src/framework/core/timer.h
Normal file
43
src/framework/core/timer.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#include <framework/util/types.h>
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
Timer() { restart(); }
|
||||
|
||||
void restart();
|
||||
|
||||
ticks_t startTicks() { return m_startTicks; }
|
||||
ticks_t ticksElapsed();
|
||||
double timeElapsed() { return ticksElapsed()/1000.0; }
|
||||
|
||||
private:
|
||||
ticks_t m_startTicks;
|
||||
};
|
||||
|
||||
#endif
|
25
src/framework/graphics/hardwarebuffer.cpp
Normal file
25
src/framework/graphics/hardwarebuffer.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "hardwarebuffer.h"
|
||||
|
31
src/framework/graphics/hardwarebuffer.h
Normal file
31
src/framework/graphics/hardwarebuffer.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HARDWAREBUFFER_H
|
||||
#define HARDWAREBUFFER_H
|
||||
|
||||
class HardwareBuffer
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
@@ -36,9 +36,10 @@ bool PainterShaderProgram::link()
|
||||
bindUniformLocation(COLOR_UNIFORM, "color");
|
||||
bindUniformLocation(OPACITY_UNIFORM, "opacity");
|
||||
bindUniformLocation(TEXTURE_UNIFORM, "texture");
|
||||
bindUniformLocation(TICKS_UNIFORM, "ticks");
|
||||
bindUniformLocation(TIME_UNIFORM, "ticks");
|
||||
return true;
|
||||
}
|
||||
m_startTimer.restart();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,10 +63,11 @@ void PainterShaderProgram::setOpacity(float opacity)
|
||||
|
||||
void PainterShaderProgram::setUniformTexture(int location, const TexturePtr& texture, int index)
|
||||
{
|
||||
if(!texture)
|
||||
return;
|
||||
glActiveTexture(GL_TEXTURE0 + index);
|
||||
glBindTexture(GL_TEXTURE_2D, texture->getId());
|
||||
if(index > 0)
|
||||
glActiveTexture(GL_TEXTURE0 + index);
|
||||
glBindTexture(GL_TEXTURE_2D, texture ? texture->getId() : 0);
|
||||
if(index > 0)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
setUniformValue(location, index);
|
||||
}
|
||||
|
||||
@@ -90,7 +92,7 @@ void PainterShaderProgram::draw(const CoordsBuffer& coordsBuffer, DrawMode drawM
|
||||
{
|
||||
assert(bind());
|
||||
|
||||
setUniformValue(TICKS_UNIFORM, (float)g_clock.ticks());
|
||||
setUniformValue(TIME_UNIFORM, (float)m_startTimer.timeElapsed());
|
||||
|
||||
int numVertices = coordsBuffer.getVertexCount();
|
||||
if(numVertices == 0)
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "shaderprogram.h"
|
||||
#include "coordsbuffer.h"
|
||||
#include <framework/core/timer.h>
|
||||
|
||||
class PainterShaderProgram : public ShaderProgram
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class PainterShaderProgram : public ShaderProgram
|
||||
COLOR_UNIFORM = 2,
|
||||
OPACITY_UNIFORM = 3,
|
||||
TEXTURE_UNIFORM = 4,
|
||||
TICKS_UNIFORM = 5
|
||||
TIME_UNIFORM = 5
|
||||
};
|
||||
public:
|
||||
enum DrawMode {
|
||||
@@ -55,6 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
DrawMode m_drawMode;
|
||||
Timer m_startTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -427,7 +427,12 @@ bool X11Window::isExtensionSupported(const char *ext)
|
||||
|
||||
void X11Window::move(const Point& pos)
|
||||
{
|
||||
bool wasVisible = isVisible();
|
||||
if(!wasVisible)
|
||||
show();
|
||||
XMoveWindow(m_display, m_window, pos.x, pos.y);
|
||||
if(!wasVisible)
|
||||
hide();
|
||||
}
|
||||
|
||||
void X11Window::resize(const Size& size)
|
||||
|
@@ -299,4 +299,6 @@ inline float randomRange<float>(float min, float max) {
|
||||
// shortcut for Fw::dump
|
||||
const static Fw::dumper dump;
|
||||
|
||||
#define forever for(;;)
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user