reorganize all constants and place them into namespaces
This commit is contained in:
parent
dab483caab
commit
e87297c1b5
5
AUTHORS
5
AUTHORS
|
@ -1,3 +1,2 @@
|
|||
Developers
|
||||
edubart - leader developer <edub4rt@gmail.com>
|
||||
baxnie - developer <henrique_santiago93@hotmail.com>
|
||||
edubart - leader developer <edub4rt@gmail.com>
|
||||
baxnie - developer <henrique_santiago93@hotmail.com>
|
|
@ -25,7 +25,7 @@ MESSAGE(STATUS "BUILD TYPE: " ${CMAKE_BUILD_TYPE})
|
|||
|
||||
# setup compiler options
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-result")
|
||||
SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable")
|
||||
SET(CMAKE_CXX_FLAGS "-std=c++0x -pipe ${CXX_WARNS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
|
@ -84,7 +84,6 @@ SET(SOURCES
|
|||
src/framework/net/rsa.cpp
|
||||
|
||||
# framework util
|
||||
src/framework/util/color.cpp
|
||||
src/framework/util/translator.cpp
|
||||
|
||||
# framework core
|
||||
|
|
|
@ -23,17 +23,39 @@
|
|||
#ifndef FRAMEWORK_CONST_H
|
||||
#define FRAMEWORK_CONST_H
|
||||
|
||||
//namespace fw {
|
||||
#include "util/color.h"
|
||||
|
||||
enum LogLevel {
|
||||
namespace Fw
|
||||
{
|
||||
const Color white (0xFF, 0xFF, 0xFF, 0xFF);
|
||||
const Color black (0x00, 0x00, 0x00, 0xFF);
|
||||
const Color alpha (0x00, 0x00, 0x00, 0x00);
|
||||
const Color red (0xFF, 0x00, 0x00, 0xFF);
|
||||
const Color green (0x00, 0xFF, 0x00, 0xFF);
|
||||
const Color blue (0x00, 0x00, 0xFF, 0xFF);
|
||||
const Color pink (0xFF, 0x00, 0xFF, 0xFF);
|
||||
const Color yellow(0xFF, 0xFF, 0x00, 0xFF);
|
||||
|
||||
enum LogLevel {
|
||||
LogDebug = 0,
|
||||
LogInfo,
|
||||
LogWarning,
|
||||
LogError,
|
||||
LogFatal
|
||||
};
|
||||
};
|
||||
|
||||
enum AlignmentFlag {
|
||||
enum BlendFunc {
|
||||
BlendNormal,
|
||||
BlendColorzing
|
||||
};
|
||||
|
||||
enum AspectRatioMode {
|
||||
IgnoreAspectRatio,
|
||||
KeepAspectRatio,
|
||||
KeepAspectRatioByExpanding
|
||||
};
|
||||
|
||||
enum AlignmentFlag {
|
||||
AlignNone = 0,
|
||||
AlignLeft = 1,
|
||||
AlignRight = 2,
|
||||
|
@ -50,9 +72,9 @@ enum AlignmentFlag {
|
|||
AlignTopCenter = AlignTop | AlignHorizontalCenter,
|
||||
AlignBottomCenter = AlignBottom | AlignHorizontalCenter,
|
||||
AlignCenter = AlignVerticalCenter | AlignHorizontalCenter
|
||||
};
|
||||
};
|
||||
|
||||
enum AnchorEdge {
|
||||
enum AnchorEdge {
|
||||
AnchorNone = 0,
|
||||
AnchorTop,
|
||||
AnchorBottom,
|
||||
|
@ -60,36 +82,36 @@ enum AnchorEdge {
|
|||
AnchorRight,
|
||||
AnchorVerticalCenter,
|
||||
AnchorHorizontalCenter,
|
||||
};
|
||||
};
|
||||
|
||||
enum FocusReason {
|
||||
enum FocusReason {
|
||||
MouseFocusReason = 0,
|
||||
TabFocusReason,
|
||||
ActiveFocusReason,
|
||||
OtherFocusReason
|
||||
};
|
||||
};
|
||||
|
||||
enum MouseButton {
|
||||
enum MouseButton {
|
||||
MouseNoButton = 0,
|
||||
MouseLeftButton,
|
||||
MouseRightButton,
|
||||
MouseMidButton
|
||||
};
|
||||
};
|
||||
|
||||
enum MouseWheelDirection {
|
||||
enum MouseWheelDirection {
|
||||
MouseNoWheel = 0,
|
||||
MouseWheelUp,
|
||||
MouseWheelDown
|
||||
};
|
||||
};
|
||||
|
||||
enum KeyboardModifier {
|
||||
enum KeyboardModifier {
|
||||
KeyboardNoModifier = 0,
|
||||
KeyboardCtrlModifier = 1,
|
||||
KeyboardAltModifier = 2,
|
||||
KeyboardShiftModifier = 4
|
||||
};
|
||||
};
|
||||
|
||||
enum WidgetState {
|
||||
enum WidgetState {
|
||||
DefaultState = 0,
|
||||
ActiveState = 1,
|
||||
FocusState = 2,
|
||||
|
@ -100,8 +122,7 @@ enum WidgetState {
|
|||
//MiddleState,
|
||||
//LastState,
|
||||
//AlternateState
|
||||
};
|
||||
|
||||
//}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@ Logger::Logger() : m_terminated(false)
|
|||
|
||||
}
|
||||
|
||||
void Logger::log(LogLevel level, std::string message)
|
||||
void Logger::log(Fw::LogLevel level, std::string message)
|
||||
{
|
||||
const static std::string logPrefixes[] = { "", "", "WARNING: ", "ERROR: ", "FATAL ERROR: " };
|
||||
|
||||
|
@ -45,13 +45,13 @@ void Logger::log(LogLevel level, std::string message)
|
|||
m_onLog(level, message, now);
|
||||
}
|
||||
|
||||
if(level == LogFatal) {
|
||||
if(level == Fw::LogFatal) {
|
||||
m_terminated = true;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::logFunc(LogLevel level, const std::string& message, std::string prettyFunction)
|
||||
void Logger::logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction)
|
||||
{
|
||||
std::stringstream ss;
|
||||
prettyFunction = prettyFunction.substr(0, prettyFunction.find_first_of('('));
|
||||
|
|
|
@ -29,21 +29,21 @@
|
|||
#include <functional>
|
||||
|
||||
struct LogMessage {
|
||||
LogMessage(LogLevel level, const std::string& message, std::size_t when) : level(level), message(message), when(when) { }
|
||||
LogLevel level;
|
||||
LogMessage(Fw::LogLevel level, const std::string& message, std::size_t when) : level(level), message(message), when(when) { }
|
||||
Fw::LogLevel level;
|
||||
std::string message;
|
||||
std::size_t when;
|
||||
};
|
||||
|
||||
class Logger
|
||||
{
|
||||
typedef std::function<void(LogLevel, std::string, std::size_t)> OnLogCallback;
|
||||
typedef std::function<void(Fw::LogLevel, std::string, std::size_t)> OnLogCallback;
|
||||
|
||||
public:
|
||||
Logger();
|
||||
|
||||
void log(LogLevel level, std::string message);
|
||||
void logFunc(LogLevel level, const std::string& message, std::string prettyFunction);
|
||||
void log(Fw::LogLevel level, std::string message);
|
||||
void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction);
|
||||
|
||||
void fireOldMessages();
|
||||
void setOnLog(const OnLogCallback& onLog) { m_onLog = onLog; }
|
||||
|
@ -57,16 +57,16 @@ private:
|
|||
extern Logger g_logger;
|
||||
|
||||
// specialized logging
|
||||
#define logDebug(...) g_logger.log(LogDebug, fw::mkstr(__VA_ARGS__))
|
||||
#define logInfo(...) g_logger.log(LogInfo, fw::mkstr(__VA_ARGS__))
|
||||
#define logWarning(...) g_logger.log(LogWarning, fw::mkstr(__VA_ARGS__))
|
||||
#define logError(...) g_logger.log(LogError, fw::mkstr(__VA_ARGS__))
|
||||
#define logFatal(...) g_logger.log(LogFatal, fw::mkstr(__VA_ARGS__))
|
||||
#define logDebug(...) g_logger.log(Fw::LogDebug, Fw::mkstr(__VA_ARGS__))
|
||||
#define logInfo(...) g_logger.log(Fw::LogInfo, Fw::mkstr(__VA_ARGS__))
|
||||
#define logWarning(...) g_logger.log(Fw::LogWarning, Fw::mkstr(__VA_ARGS__))
|
||||
#define logError(...) g_logger.log(Fw::LogError, Fw::mkstr(__VA_ARGS__))
|
||||
#define logFatal(...) g_logger.log(Fw::LogFatal, Fw::mkstr(__VA_ARGS__))
|
||||
|
||||
#define logTrace() g_logger.logFunc(LogDebug, "", __PRETTY_FUNCTION__)
|
||||
#define logTraceDebug(...) g_logger.logFunc(LogDebug, fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceInfo(...) g_logger.logFunc(LogInfo, fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceWarning(...) g_logger.logFunc(LogWarning, fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceError(...) g_logger.logFunc(LogError, fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTrace() g_logger.logFunc(Fw::LogDebug, "", __PRETTY_FUNCTION__)
|
||||
#define logTraceDebug(...) g_logger.logFunc(Fw::LogDebug, Fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceInfo(...) g_logger.logFunc(Fw::LogInfo, Fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceWarning(...) g_logger.logFunc(Fw::LogWarning, Fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceError(...) g_logger.logFunc(Fw::LogError, Fw::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
|
||||
#endif
|
|
@ -61,10 +61,10 @@ bool Module::load()
|
|||
for(const std::string& depName : m_dependencies) {
|
||||
ModulePtr dep = g_modules.getModule(depName);
|
||||
if(!dep)
|
||||
throw std::runtime_error(fw::mkstr("could not find module dependency '", depName ,"'"));
|
||||
throw std::runtime_error(Fw::mkstr("could not find module dependency '", depName ,"'"));
|
||||
|
||||
if(!dep->isLoaded() && !dep->load())
|
||||
throw std::runtime_error(fw::mkstr("dependency '", depName, "' has failed to load"));
|
||||
throw std::runtime_error(Fw::mkstr("dependency '", depName, "' has failed to load"));
|
||||
}
|
||||
|
||||
if(m_loadCallback) {
|
||||
|
|
|
@ -107,7 +107,7 @@ void ResourceManager::loadFile(const std::string& fileName, std::iostream& out)
|
|||
PHYSFS_file* file = PHYSFS_openRead(fullPath.c_str());
|
||||
if(!file) {
|
||||
out.clear(std::ios::failbit);
|
||||
throw std::runtime_error(fw::mkstr("failed to load file '", fullPath.c_str(), "': ", PHYSFS_getLastError()));
|
||||
throw std::runtime_error(Fw::mkstr("failed to load file '", fullPath.c_str(), "': ", PHYSFS_getLastError()));
|
||||
} else {
|
||||
int fileSize = PHYSFS_fileLength(file);
|
||||
if(fileSize > 0) {
|
||||
|
|
|
@ -49,7 +49,7 @@ void Font::load(const OTMLNodePtr& fontNode)
|
|||
// read custom widths
|
||||
if(OTMLNodePtr node = fontNode->get("glyph widths")) {
|
||||
for(const OTMLNodePtr& child : node->children())
|
||||
m_glyphsSize[fw::safe_cast<int>(child->tag())].setWidth(child->value<int>());
|
||||
m_glyphsSize[Fw::safeCast<int>(child->tag())].setWidth(child->value<int>());
|
||||
}
|
||||
|
||||
// calculate glyphs texture coords
|
||||
|
@ -68,13 +68,13 @@ void Font::renderText(const std::string& text,
|
|||
{
|
||||
Size boxSize = g_graphics.getScreenSize() - startPos.toSize();
|
||||
Rect screenCoords(startPos, boxSize);
|
||||
renderText(text, screenCoords, AlignTopLeft, color);
|
||||
renderText(text, screenCoords, Fw::AlignTopLeft, color);
|
||||
}
|
||||
|
||||
|
||||
void Font::renderText(const std::string& text,
|
||||
const Rect& screenCoords,
|
||||
AlignmentFlag align,
|
||||
Fw::AlignmentFlag align,
|
||||
const Color& color)
|
||||
{
|
||||
// prevent glitches from invalid rects
|
||||
|
@ -103,17 +103,17 @@ void Font::renderText(const std::string& text,
|
|||
Rect glyphTextureCoords = m_glyphsTextureCoords[glyph];
|
||||
|
||||
// first translate to align position
|
||||
if(align & AlignBottom) {
|
||||
if(align & Fw::AlignBottom) {
|
||||
glyphScreenCoords.translate(0, screenCoords.height() - textBoxSize.height());
|
||||
} else if(align & AlignVerticalCenter) {
|
||||
} else if(align & Fw::AlignVerticalCenter) {
|
||||
glyphScreenCoords.translate(0, (screenCoords.height() - textBoxSize.height()) / 2);
|
||||
} else { // AlignTop
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
if(align & AlignRight) {
|
||||
if(align & Fw::AlignRight) {
|
||||
glyphScreenCoords.translate(screenCoords.width() - textBoxSize.width(), 0);
|
||||
} else if(align & AlignHorizontalCenter) {
|
||||
} else if(align & Fw::AlignHorizontalCenter) {
|
||||
glyphScreenCoords.translate((screenCoords.width() - textBoxSize.width()) / 2, 0);
|
||||
} else { // AlignLeft
|
||||
// nothing to do
|
||||
|
@ -158,7 +158,7 @@ void Font::renderText(const std::string& text,
|
|||
}
|
||||
|
||||
const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text,
|
||||
AlignmentFlag align,
|
||||
Fw::AlignmentFlag align,
|
||||
Size *textBoxSize) const
|
||||
{
|
||||
// for performance reasons we use statics vectors that are allocated on demand
|
||||
|
@ -183,7 +183,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
|||
glyphsPositions.resize(textLength);
|
||||
|
||||
// calculate lines width
|
||||
if((align & AlignRight || align & AlignHorizontalCenter) || textBoxSize) {
|
||||
if((align & Fw::AlignRight || align & Fw::AlignHorizontalCenter) || textBoxSize) {
|
||||
lineWidths[0] = 0;
|
||||
for(i = 0; i< textLength; ++i) {
|
||||
glyph = (uchar)text[i];
|
||||
|
@ -213,9 +213,9 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
|||
}
|
||||
|
||||
// calculate start x pos
|
||||
if(align & AlignRight) {
|
||||
if(align & Fw::AlignRight) {
|
||||
virtualPos.x = (maxLineWidth - lineWidths[lines]);
|
||||
} else if(align & AlignHorizontalCenter) {
|
||||
} else if(align & Fw::AlignHorizontalCenter) {
|
||||
virtualPos.x = (maxLineWidth - lineWidths[lines]) / 2;
|
||||
} else { // AlignLeft
|
||||
virtualPos.x = 0;
|
||||
|
@ -242,7 +242,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
|||
Size Font::calculateTextRectSize(const std::string& text)
|
||||
{
|
||||
Size size;
|
||||
calculateGlyphsPositions(text, AlignTopLeft, &size);
|
||||
calculateGlyphsPositions(text, Fw::AlignTopLeft, &size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,17 +38,17 @@ public:
|
|||
/// Simple text render starting at startPos
|
||||
void renderText(const std::string& text,
|
||||
const Point& startPos,
|
||||
const Color& color = Color::white);
|
||||
const Color& color = Fw::white);
|
||||
|
||||
/// Advanced text render delimited by a screen region and alignment
|
||||
void renderText(const std::string& text,
|
||||
const Rect& screenCoords,
|
||||
AlignmentFlag align = AlignTopLeft,
|
||||
const Color& color = Color::white);
|
||||
Fw::AlignmentFlag align = Fw::AlignTopLeft,
|
||||
const Color& color = Fw::white);
|
||||
|
||||
/// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted
|
||||
const std::vector<Point>& calculateGlyphsPositions(const std::string& text,
|
||||
AlignmentFlag align = AlignTopLeft,
|
||||
Fw::AlignmentFlag align = Fw::AlignTopLeft,
|
||||
Size* textBoxSize = NULL) const;
|
||||
|
||||
/// Simulate render and calculate text size
|
||||
|
|
|
@ -50,8 +50,8 @@ void Graphics::init()
|
|||
m_opacity = 255;
|
||||
m_emptyTexture = TexturePtr(new Texture);
|
||||
|
||||
bindColor(Color::white);
|
||||
bindBlendFunc(BLEND_NORMAL);
|
||||
bindColor(Fw::white);
|
||||
bindBlendFunc(Fw::BlendNormal);
|
||||
}
|
||||
|
||||
void Graphics::terminate()
|
||||
|
@ -299,13 +299,13 @@ void Graphics::bindTexture(const TexturePtr& texture)
|
|||
glBindTexture(GL_TEXTURE_2D, texture->getId());
|
||||
}
|
||||
|
||||
void Graphics::bindBlendFunc(BlendFuncType blendType)
|
||||
void Graphics::bindBlendFunc(Fw::BlendFunc blendType)
|
||||
{
|
||||
switch(blendType) {
|
||||
case BLEND_NORMAL:
|
||||
case Fw::BlendNormal:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case BLEND_COLORIZING:
|
||||
case Fw::BlendColorzing:
|
||||
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
#include "declarations.h"
|
||||
|
||||
enum BlendFuncType {
|
||||
BLEND_NORMAL,
|
||||
BLEND_COLORIZING
|
||||
};
|
||||
|
||||
class Graphics
|
||||
{
|
||||
public:
|
||||
|
@ -56,7 +51,7 @@ public:
|
|||
|
||||
void bindColor(const Color& color);
|
||||
void bindTexture(const TexturePtr& texture);
|
||||
void bindBlendFunc(BlendFuncType blendType);
|
||||
void bindBlendFunc(Fw::BlendFunc blendType);
|
||||
|
||||
// drawing API
|
||||
void drawTexturedRect(const Rect& screenCoords,
|
||||
|
|
|
@ -33,21 +33,21 @@ void LuaException::generateLuaErrorMessage(const std::string& error, int traceLe
|
|||
{
|
||||
// append trace level to error message
|
||||
if(traceLevel >= 0)
|
||||
m_what = fw::mkstr("LUA ERROR: ", g_lua.traceback(error, traceLevel));
|
||||
m_what = Fw::mkstr("LUA ERROR: ", g_lua.traceback(error, traceLevel));
|
||||
else
|
||||
m_what = fw::mkstr("LUA ERROR: ", error);
|
||||
m_what = Fw::mkstr("LUA ERROR: ", error);
|
||||
}
|
||||
|
||||
LuaBadNumberOfArgumentsException::LuaBadNumberOfArgumentsException(int expected, int got)
|
||||
{
|
||||
std::string error = "attempt to call a function with wrong number of arguments";
|
||||
if(expected >= 0 && got >= 0)
|
||||
error = fw::mkstr(error, " (expected ", expected, ", but got ", got, ")");
|
||||
error = Fw::mkstr(error, " (expected ", expected, ", but got ", got, ")");
|
||||
generateLuaErrorMessage(error, 1);
|
||||
}
|
||||
|
||||
LuaBadValueCastException::LuaBadValueCastException(const std::string& luaTypeName, const std::string& cppTypeName)
|
||||
{
|
||||
std::string error = fw::mkstr("attempt to cast a '", luaTypeName, "' lua value to '", cppTypeName, "'");
|
||||
std::string error = Fw::mkstr("attempt to cast a '", luaTypeName, "' lua value to '", cppTypeName, "'");
|
||||
generateLuaErrorMessage(error, 0);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void LuaInterface::init()
|
|||
createLuaState();
|
||||
|
||||
// check if demangle_type is working as expected
|
||||
assert(fw::demangle_type<LuaObject>() == "LuaObject");
|
||||
assert(Fw::demangleType<LuaObject>() == "LuaObject");
|
||||
|
||||
// register LuaObject, the base of all other objects
|
||||
registerClass<LuaObject>();
|
||||
|
@ -147,12 +147,12 @@ void LuaInterface::registerClassMemberField(const std::string& className,
|
|||
|
||||
if(getFunction) {
|
||||
pushCppFunction(getFunction);
|
||||
setField(fw::mkstr("get_", field));
|
||||
setField(Fw::mkstr("get_", field));
|
||||
}
|
||||
|
||||
if(setFunction) {
|
||||
pushCppFunction(setFunction);
|
||||
setField(fw::mkstr("set_", field));
|
||||
setField(Fw::mkstr("set_", field));
|
||||
}
|
||||
|
||||
pop();
|
||||
|
@ -295,7 +295,7 @@ void LuaInterface::loadFunction(const std::string& buffer, const std::string& so
|
|||
// gets the function contained in that buffer
|
||||
if(boost::starts_with(buffer, "function")) {
|
||||
// evaluate the function
|
||||
std::string buf = fw::mkstr("__func = ", buffer);
|
||||
std::string buf = Fw::mkstr("__func = ", buffer);
|
||||
loadBuffer(buf, source);
|
||||
safeCall();
|
||||
|
||||
|
@ -317,7 +317,7 @@ void LuaInterface::evaluateExpression(const std::string& expression, const std::
|
|||
{
|
||||
// evaluates the expression
|
||||
if(!expression.empty()) {
|
||||
std::string buffer = fw::mkstr("__exp = (", expression, ")");
|
||||
std::string buffer = Fw::mkstr("__exp = (", expression, ")");
|
||||
loadBuffer(buffer, source);
|
||||
safeCall();
|
||||
|
||||
|
@ -917,7 +917,7 @@ void LuaInterface::pushObject(const LuaObjectPtr& obj)
|
|||
new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);
|
||||
|
||||
// set the userdata metatable
|
||||
getGlobal(fw::mkstr(obj->getLuaObjectName(), "_mt"));
|
||||
getGlobal(Fw::mkstr(obj->getLuaObjectName(), "_mt"));
|
||||
assert(!isNil());
|
||||
setMetatable();
|
||||
}
|
||||
|
|
|
@ -63,24 +63,24 @@ public:
|
|||
// register shortcuts using templates
|
||||
template<class C, class B = LuaObject>
|
||||
void registerClass() {
|
||||
registerClass(fw::demangle_type<C>(), fw::demangle_type<B>());
|
||||
registerClass(Fw::demangleType<C>(), Fw::demangleType<B>());
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassStaticFunction(const std::string& functionName, const LuaCppFunction& function) {
|
||||
registerClassStaticFunction(fw::demangle_type<C>(), functionName, function);
|
||||
registerClassStaticFunction(Fw::demangleType<C>(), functionName, function);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassMemberFunction(const std::string& functionName, const LuaCppFunction& function) {
|
||||
registerClassMemberFunction(fw::demangle_type<C>(), functionName, function);
|
||||
registerClassMemberFunction(Fw::demangleType<C>(), functionName, function);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void registerClassMemberField(const std::string& field,
|
||||
const LuaCppFunction& getFunction,
|
||||
const LuaCppFunction& setFunction) {
|
||||
registerClassMemberField(fw::demangle_type<C>(), field, getFunction, setFunction);
|
||||
registerClassMemberField(Fw::demangleType<C>(), field, getFunction, setFunction);
|
||||
}
|
||||
|
||||
// methods for binding functions
|
||||
|
@ -343,7 +343,7 @@ template<class T>
|
|||
T LuaInterface::castValue(int index) {
|
||||
T o;
|
||||
if(!luavalue_cast(index, o))
|
||||
throw LuaBadValueCastException(typeName(index), fw::demangle_type<T>());
|
||||
throw LuaBadValueCastException(typeName(index), Fw::demangleType<T>());
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
/// Returns the class name used in Lua
|
||||
virtual std::string getLuaObjectName() const {
|
||||
// this could later be cached for more performance
|
||||
return fw::demangle_name(typeid(*this).name());
|
||||
return Fw::demangleName(typeid(*this).name());
|
||||
}
|
||||
|
||||
LuaObjectPtr asLuaObject() { return shared_from_this(); }
|
||||
|
|
|
@ -130,9 +130,9 @@ bool luavalue_cast(int index, Color& color)
|
|||
color.setAlpha(g_lua.popInteger());
|
||||
return true;
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), color);
|
||||
return Fw::cast(g_lua.toString(index), color);
|
||||
} else if(g_lua.isNil()) {
|
||||
color = Color::white;
|
||||
color = Fw::white;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -164,7 +164,7 @@ bool luavalue_cast(int index, Rect& rect)
|
|||
g_lua.getField("height", index);
|
||||
rect.setHeight(g_lua.popInteger());
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), rect);
|
||||
return Fw::cast(g_lua.toString(index), rect);
|
||||
} else if(g_lua.isNil()) {
|
||||
rect = Rect();
|
||||
return true;
|
||||
|
@ -191,7 +191,7 @@ bool luavalue_cast(int index, Point& point)
|
|||
point.y = g_lua.popInteger();
|
||||
return true;
|
||||
} else if(g_lua.isString()) {
|
||||
return fw::cast(g_lua.toString(index), point);
|
||||
return Fw::cast(g_lua.toString(index), point);
|
||||
} else if(g_lua.isNil()) {
|
||||
point = Point();
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,7 @@ void Connection::connect(const std::string& host, uint16 port, const SimpleCallb
|
|||
m_connected = false;
|
||||
m_connectCallback = connectCallback;
|
||||
|
||||
asio::ip::tcp::resolver::query query(host, fw::unsafe_cast<std::string>(port));
|
||||
asio::ip::tcp::resolver::query query(host, Fw::unsafeCast<std::string>(port));
|
||||
m_resolver.async_resolve(query, std::bind(&Connection::onResolve, shared_from_this(), _1, _2));
|
||||
|
||||
m_readTimer.expires_from_now(boost::posix_time::seconds(READ_TIMEOUT));
|
||||
|
|
|
@ -77,14 +77,14 @@ OTMLNodePtr OTMLNode::at(const std::string& childTag)
|
|||
}
|
||||
}
|
||||
if(!res)
|
||||
throw OTMLException(shared_from_this(), fw::mkstr("child node with tag '", childTag, "' not found"));
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("child node with tag '", childTag, "' not found"));
|
||||
return res;
|
||||
}
|
||||
|
||||
OTMLNodePtr OTMLNode::atIndex(int childIndex)
|
||||
{
|
||||
if(childIndex >= size() || childIndex < 0)
|
||||
throw OTMLException(shared_from_this(), fw::mkstr("child node with index '", childIndex, "' not found"));
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("child node with index '", childIndex, "' not found"));
|
||||
return m_children[childIndex];
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class OTMLNode : public std::enable_shared_from_this<OTMLNode>
|
|||
public:
|
||||
virtual ~OTMLNode() { }
|
||||
|
||||
static OTMLNodePtr create(std::string tag = fw::empty_string, bool unique = false);
|
||||
static OTMLNodePtr create(std::string tag = Fw::empty_string, bool unique = false);
|
||||
static OTMLNodePtr create(std::string tag, std::string value);
|
||||
|
||||
std::string tag() const { return m_tag; }
|
||||
|
@ -106,8 +106,8 @@ protected:
|
|||
template<typename T>
|
||||
T OTMLNode::value() {
|
||||
T ret;
|
||||
if(!fw::cast(m_value, ret))
|
||||
throw OTMLException(shared_from_this(), fw::mkstr("failed to cast node value to type '", fw::demangle_type<T>(), "'"));
|
||||
if(!Fw::cast(m_value, ret))
|
||||
throw OTMLException(shared_from_this(), Fw::mkstr("failed to cast node value to type '", Fw::demangleType<T>(), "'"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ T OTMLNode::valueAtIndex(int childIndex, const T& def) {
|
|||
|
||||
template<typename T>
|
||||
void OTMLNode::write(const T& v) {
|
||||
m_value = fw::safe_cast<std::string>(v);
|
||||
m_value = Fw::safeCast<std::string>(v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -181,7 +181,7 @@ void OTMLParser::parseNode(const std::string& data)
|
|||
|
||||
node->setUnique(dotsPos != std::string::npos);
|
||||
node->setTag(tag);
|
||||
node->setSource(doc->source() + ":" + fw::unsafe_cast<std::string>(nodeLine));
|
||||
node->setSource(doc->source() + ":" + Fw::unsafeCast<std::string>(nodeLine));
|
||||
|
||||
// ~ is considered the null value
|
||||
if(value == "~")
|
||||
|
|
|
@ -35,8 +35,8 @@ void UIAnchorGroup::addAnchor(const UIAnchor& anchor)
|
|||
m_anchors.push_back(anchor);
|
||||
}
|
||||
|
||||
void UIAnchorLayout::addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, AnchorEdge hookedEdge)
|
||||
void UIAnchorLayout::addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge)
|
||||
{
|
||||
if(!anchoredWidget)
|
||||
return;
|
||||
|
@ -59,16 +59,16 @@ void UIAnchorLayout::removeAnchors(const UIWidgetPtr& anchoredWidget)
|
|||
|
||||
void UIAnchorLayout::centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||
{
|
||||
addAnchor(anchoredWidget, AnchorHorizontalCenter, hookedWidgetId, AnchorHorizontalCenter);
|
||||
addAnchor(anchoredWidget, AnchorVerticalCenter, hookedWidgetId, AnchorVerticalCenter);
|
||||
addAnchor(anchoredWidget, Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
||||
addAnchor(anchoredWidget, Fw::AnchorVerticalCenter, hookedWidgetId, Fw::AnchorVerticalCenter);
|
||||
}
|
||||
|
||||
void UIAnchorLayout::fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId)
|
||||
{
|
||||
addAnchor(anchoredWidget, AnchorLeft, hookedWidgetId, AnchorLeft);
|
||||
addAnchor(anchoredWidget, AnchorRight, hookedWidgetId, AnchorRight);
|
||||
addAnchor(anchoredWidget, AnchorTop, hookedWidgetId, AnchorTop);
|
||||
addAnchor(anchoredWidget, AnchorBottom, hookedWidgetId, AnchorBottom);
|
||||
addAnchor(anchoredWidget, Fw::AnchorLeft, hookedWidgetId, Fw::AnchorLeft);
|
||||
addAnchor(anchoredWidget, Fw::AnchorRight, hookedWidgetId, Fw::AnchorRight);
|
||||
addAnchor(anchoredWidget, Fw::AnchorTop, hookedWidgetId, Fw::AnchorTop);
|
||||
addAnchor(anchoredWidget, Fw::AnchorBottom, hookedWidgetId, Fw::AnchorBottom);
|
||||
}
|
||||
|
||||
void UIAnchorLayout::update()
|
||||
|
@ -108,7 +108,7 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
|||
// calculates new rect based on anchors
|
||||
for(const UIAnchor& anchor : anchorGroup.getAnchors()) {
|
||||
// skip invalid anchors
|
||||
if(anchor.getHookedEdge() == AnchorNone)
|
||||
if(anchor.getHookedEdge() == Fw::AnchorNone)
|
||||
continue;
|
||||
|
||||
// determine hooked widget
|
||||
|
@ -141,22 +141,22 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
|||
// determine hooked widget edge point
|
||||
int point = 0;
|
||||
switch(anchor.getHookedEdge()) {
|
||||
case AnchorLeft:
|
||||
case Fw::AnchorLeft:
|
||||
point = hookedWidget->getRect().left();
|
||||
break;
|
||||
case AnchorRight:
|
||||
case Fw::AnchorRight:
|
||||
point = hookedWidget->getRect().right();
|
||||
break;
|
||||
case AnchorTop:
|
||||
case Fw::AnchorTop:
|
||||
point = hookedWidget->getRect().top();
|
||||
break;
|
||||
case AnchorBottom:
|
||||
case Fw::AnchorBottom:
|
||||
point = hookedWidget->getRect().bottom();
|
||||
break;
|
||||
case AnchorHorizontalCenter:
|
||||
case Fw::AnchorHorizontalCenter:
|
||||
point = hookedWidget->getRect().horizontalCenter();
|
||||
break;
|
||||
case AnchorVerticalCenter:
|
||||
case Fw::AnchorVerticalCenter:
|
||||
point = hookedWidget->getRect().verticalCenter();
|
||||
break;
|
||||
default:
|
||||
|
@ -166,36 +166,36 @@ void UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
|||
}
|
||||
|
||||
switch(anchor.getAnchoredEdge()) {
|
||||
case AnchorHorizontalCenter:
|
||||
case Fw::AnchorHorizontalCenter:
|
||||
newRect.moveHorizontalCenter(point + widget->getMarginLeft() - widget->getMarginRight());
|
||||
horizontalMoved = true;
|
||||
break;
|
||||
case AnchorLeft:
|
||||
case Fw::AnchorLeft:
|
||||
if(!horizontalMoved) {
|
||||
newRect.moveLeft(point + widget->getMarginLeft());
|
||||
horizontalMoved = true;
|
||||
} else
|
||||
newRect.setLeft(point + widget->getMarginLeft());
|
||||
break;
|
||||
case AnchorRight:
|
||||
case Fw::AnchorRight:
|
||||
if(!horizontalMoved) {
|
||||
newRect.moveRight(point - widget->getMarginRight());
|
||||
horizontalMoved = true;
|
||||
} else
|
||||
newRect.setRight(point - widget->getMarginRight());
|
||||
break;
|
||||
case AnchorVerticalCenter:
|
||||
case Fw::AnchorVerticalCenter:
|
||||
newRect.moveVerticalCenter(point + widget->getMarginTop() - widget->getMarginBottom());
|
||||
verticalMoved = true;
|
||||
break;
|
||||
case AnchorTop:
|
||||
case Fw::AnchorTop:
|
||||
if(!verticalMoved) {
|
||||
newRect.moveTop(point + widget->getMarginTop());
|
||||
verticalMoved = true;
|
||||
} else
|
||||
newRect.setTop(point + widget->getMarginTop());
|
||||
break;
|
||||
case AnchorBottom:
|
||||
case Fw::AnchorBottom:
|
||||
if(!verticalMoved) {
|
||||
newRect.moveBottom(point - widget->getMarginBottom());
|
||||
verticalMoved = true;
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
class UIAnchor
|
||||
{
|
||||
public:
|
||||
UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge) :
|
||||
UIAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge) :
|
||||
m_anchoredEdge(anchoredEdge), m_hookedEdge(hookedEdge), m_hookedWidgetId(hookedWidgetId) { }
|
||||
|
||||
AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
|
||||
Fw::AnchorEdge getAnchoredEdge() const { return m_anchoredEdge; }
|
||||
std::string getHookedWidgetId() const { return m_hookedWidgetId; }
|
||||
AnchorEdge getHookedEdge() const { return m_hookedEdge; }
|
||||
Fw::AnchorEdge getHookedEdge() const { return m_hookedEdge; }
|
||||
|
||||
private:
|
||||
AnchorEdge m_anchoredEdge;
|
||||
AnchorEdge m_hookedEdge;
|
||||
Fw::AnchorEdge m_anchoredEdge;
|
||||
Fw::AnchorEdge m_hookedEdge;
|
||||
std::string m_hookedWidgetId;
|
||||
};
|
||||
|
||||
|
@ -61,8 +61,8 @@ class UIAnchorLayout : public UILayout
|
|||
public:
|
||||
UIAnchorLayout(UIWidgetPtr parentWidget) : UILayout(parentWidget) { }
|
||||
|
||||
void addAnchor(const UIWidgetPtr& anchoredWidget, AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, AnchorEdge hookedEdge);
|
||||
void addAnchor(const UIWidgetPtr& anchoredWidget, Fw::AnchorEdge anchoredEdge,
|
||||
const std::string& hookedWidgetId, Fw::AnchorEdge hookedEdge);
|
||||
void removeAnchors(const UIWidgetPtr& anchoredWidget);
|
||||
void centerIn(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
void fill(const UIWidgetPtr& anchoredWidget, const std::string& hookedWidgetId);
|
||||
|
|
|
@ -41,7 +41,7 @@ void UIButton::render()
|
|||
UIWidget::render();
|
||||
Rect textRect = m_rect;
|
||||
textRect.translate(m_textTranslate);
|
||||
m_font->renderText(m_text, textRect, AlignCenter, m_foregroundColor);
|
||||
m_font->renderText(m_text, textRect, Fw::AlignCenter, m_foregroundColor);
|
||||
}
|
||||
|
||||
void UIButton::onStyleApply(const OTMLNodePtr& styleNode)
|
||||
|
@ -60,7 +60,7 @@ void UIButton::onStyleApply(const OTMLNodePtr& styleNode)
|
|||
}
|
||||
}
|
||||
|
||||
bool UIButton::onMouseRelease(const Point& mousePos, MouseButton button)
|
||||
bool UIButton::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
if(isPressed()) {
|
||||
if(m_onClick && getRect().contains(mousePos))
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
|
||||
SimpleCallback m_onClick;
|
||||
Point m_textTranslate;
|
||||
|
|
|
@ -28,7 +28,7 @@ void UILabel::setup()
|
|||
{
|
||||
UIWidget::setup();
|
||||
setFocusable(false);
|
||||
setAlign(AlignLeft);
|
||||
setAlign(Fw::AlignLeft);
|
||||
}
|
||||
|
||||
void UILabel::render()
|
||||
|
@ -66,7 +66,7 @@ void UILabel::onStyleApply(const OTMLNodePtr& styleNode)
|
|||
if(node->tag() == "text")
|
||||
setText(node->value());
|
||||
else if(node->tag() == "align")
|
||||
setAlign(fw::translateAlignment(node->value()));
|
||||
setAlign(Fw::translateAlignment(node->value()));
|
||||
else if(node->tag() == "offset") {
|
||||
setOffset(node->value<Point>());
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ public:
|
|||
void resizeToText();
|
||||
|
||||
void setText(const std::string& text);
|
||||
void setAlign(AlignmentFlag align) { m_align = align; }
|
||||
void setAlign(Fw::AlignmentFlag align) { m_align = align; }
|
||||
void setOffset(const Point& offset) { m_offset = offset; }
|
||||
|
||||
std::string getText() const { return m_text; }
|
||||
AlignmentFlag getAlign() const { return m_align; }
|
||||
Fw::AlignmentFlag getAlign() const { return m_align; }
|
||||
Point getOffset() const { return m_offset; }
|
||||
|
||||
protected:
|
||||
|
@ -47,7 +47,7 @@ protected:
|
|||
private:
|
||||
std::string m_text;
|
||||
Point m_offset;
|
||||
AlignmentFlag m_align;
|
||||
Fw::AlignmentFlag m_align;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
UILineEdit::UILineEdit()
|
||||
{
|
||||
m_align = AlignLeftCenter;
|
||||
m_align = Fw::AlignLeftCenter;
|
||||
m_cursorPos = 0;
|
||||
m_startRenderPos = 0;
|
||||
m_textHorizontalMargin = 3;
|
||||
|
@ -139,16 +139,16 @@ void UILineEdit::update()
|
|||
textScreenCoords.addRight(-m_textHorizontalMargin);
|
||||
m_drawArea = textScreenCoords;
|
||||
|
||||
if(m_align & AlignBottom) {
|
||||
if(m_align & Fw::AlignBottom) {
|
||||
m_drawArea.translate(0, textScreenCoords.height() - textBoxSize.height());
|
||||
} else if(m_align & AlignVerticalCenter) {
|
||||
} else if(m_align & Fw::AlignVerticalCenter) {
|
||||
m_drawArea.translate(0, (textScreenCoords.height() - textBoxSize.height()) / 2);
|
||||
} else { // AlignTop
|
||||
}
|
||||
|
||||
if(m_align & AlignRight) {
|
||||
if(m_align & Fw::AlignRight) {
|
||||
m_drawArea.translate(textScreenCoords.width() - textBoxSize.width(), 0);
|
||||
} else if(m_align & AlignHorizontalCenter) {
|
||||
} else if(m_align & Fw::AlignHorizontalCenter) {
|
||||
m_drawArea.translate((textScreenCoords.width() - textBoxSize.width()) / 2, 0);
|
||||
} else { // AlignLeft
|
||||
|
||||
|
@ -167,17 +167,17 @@ void UILineEdit::update()
|
|||
Rect glyphTextureCoords = glyphsTextureCoords[glyph];
|
||||
|
||||
// first translate to align position
|
||||
if(m_align & AlignBottom) {
|
||||
if(m_align & Fw::AlignBottom) {
|
||||
glyphScreenCoords.translate(0, textScreenCoords.height() - textBoxSize.height());
|
||||
} else if(m_align & AlignVerticalCenter) {
|
||||
} else if(m_align & Fw::AlignVerticalCenter) {
|
||||
glyphScreenCoords.translate(0, (textScreenCoords.height() - textBoxSize.height()) / 2);
|
||||
} else { // AlignTop
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
if(m_align & AlignRight) {
|
||||
if(m_align & Fw::AlignRight) {
|
||||
glyphScreenCoords.translate(textScreenCoords.width() - textBoxSize.width(), 0);
|
||||
} else if(m_align & AlignHorizontalCenter) {
|
||||
} else if(m_align & Fw::AlignHorizontalCenter) {
|
||||
glyphScreenCoords.translate((textScreenCoords.width() - textBoxSize.width()) / 2, 0);
|
||||
} else { // AlignLeft
|
||||
// nothing to do
|
||||
|
@ -243,7 +243,7 @@ void UILineEdit::setText(const std::string& text)
|
|||
}
|
||||
}
|
||||
|
||||
void UILineEdit::setAlign(AlignmentFlag align)
|
||||
void UILineEdit::setAlign(Fw::AlignmentFlag align)
|
||||
{
|
||||
if(m_align != align) {
|
||||
m_align = align;
|
||||
|
@ -360,10 +360,10 @@ void UILineEdit::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
|
|||
update();
|
||||
}
|
||||
|
||||
void UILineEdit::onFocusChange(bool focused, FocusReason reason)
|
||||
void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason)
|
||||
{
|
||||
if(focused) {
|
||||
if(reason == TabFocusReason)
|
||||
if(reason == Fw::TabFocusReason)
|
||||
setCursorPos(m_text.length());
|
||||
else
|
||||
blinkCursor();
|
||||
|
@ -386,7 +386,7 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
|
|||
setCursorPos(m_text.length());
|
||||
else if(keyCode == KC_TAB) {
|
||||
if(UIWidgetPtr parent = getParent())
|
||||
parent->focusNextChild(TabFocusReason);
|
||||
parent->focusNextChild(Fw::TabFocusReason);
|
||||
} else if(keyCode == KC_RETURN) {
|
||||
if(m_onAction)
|
||||
m_onAction();
|
||||
|
@ -398,9 +398,9 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool UILineEdit::onMousePress(const Point& mousePos, MouseButton button)
|
||||
bool UILineEdit::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
if(button == MouseLeftButton) {
|
||||
if(button == Fw::MouseLeftButton) {
|
||||
int pos = getTextPos(mousePos);
|
||||
if(pos >= 0)
|
||||
setCursorPos(pos);
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
void update();
|
||||
|
||||
void setText(const std::string& text);
|
||||
void setAlign(AlignmentFlag align);
|
||||
void setAlign(Fw::AlignmentFlag align);
|
||||
void setCursorPos(int pos);
|
||||
void setCursorEnabled(bool enable = true);
|
||||
|
||||
|
@ -51,16 +51,16 @@ public:
|
|||
protected:
|
||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
|
||||
virtual void onFocusChange(bool focused, FocusReason reason);
|
||||
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
|
||||
virtual bool onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers);
|
||||
virtual bool onMousePress(const Point& mousePos, MouseButton button);
|
||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
|
||||
private:
|
||||
void blinkCursor();
|
||||
|
||||
std::string m_text;
|
||||
Rect m_drawArea;
|
||||
AlignmentFlag m_align;
|
||||
Fw::AlignmentFlag m_align;
|
||||
int m_cursorPos;
|
||||
Point m_startInternalPos;
|
||||
int m_startRenderPos;
|
||||
|
|
|
@ -60,13 +60,13 @@ void UIManager::inputEvent(const PlatformEvent& event)
|
|||
// translate input event to ui events
|
||||
if(m_rootWidget) {
|
||||
if(event.type & EventKeyboardAction) {
|
||||
int keyboardModifiers = KeyboardNoModifier;
|
||||
int keyboardModifiers = Fw::KeyboardNoModifier;
|
||||
if(event.ctrl)
|
||||
keyboardModifiers |= KeyboardCtrlModifier;
|
||||
keyboardModifiers |= Fw::KeyboardCtrlModifier;
|
||||
if(event.shift)
|
||||
keyboardModifiers |= KeyboardShiftModifier;
|
||||
keyboardModifiers |= Fw::KeyboardShiftModifier;
|
||||
if(event.alt)
|
||||
keyboardModifiers |= KeyboardAltModifier;
|
||||
keyboardModifiers |= Fw::KeyboardAltModifier;
|
||||
|
||||
if(event.type == EventKeyDown)
|
||||
m_rootWidget->onKeyPress(event.keycode, event.keychar, keyboardModifiers);
|
||||
|
@ -74,25 +74,25 @@ void UIManager::inputEvent(const PlatformEvent& event)
|
|||
m_rootWidget->onKeyRelease(event.keycode, event.keychar, keyboardModifiers);
|
||||
} else if(event.type & EventMouseAction) {
|
||||
if(event.type == EventMouseMove) {
|
||||
m_rootWidget->updateState(HoverState);
|
||||
m_rootWidget->updateState(Fw::HoverState);
|
||||
m_rootWidget->onMouseMove(event.mousePos, event.mouseMoved);
|
||||
}
|
||||
else if(event.type & EventMouseWheel) {
|
||||
MouseWheelDirection dir = MouseNoWheel;
|
||||
Fw::MouseWheelDirection dir = Fw::MouseNoWheel;
|
||||
if(event.type & EventDown)
|
||||
dir = MouseWheelDown;
|
||||
dir = Fw::MouseWheelDown;
|
||||
else if(event.type & EventUp)
|
||||
dir = MouseWheelUp;
|
||||
dir = Fw::MouseWheelUp;
|
||||
|
||||
m_rootWidget->onMouseWheel(event.mousePos, dir);
|
||||
} else {
|
||||
MouseButton button = MouseNoButton;
|
||||
Fw::MouseButton button = Fw::MouseNoButton;
|
||||
if(event.type & EventMouseLeftButton)
|
||||
button = MouseLeftButton;
|
||||
button = Fw::MouseLeftButton;
|
||||
else if(event.type & EventMouseMidButton)
|
||||
button = MouseMidButton;
|
||||
button = Fw::MouseMidButton;
|
||||
else if(event.type & EventMouseRightButton)
|
||||
button = MouseRightButton;
|
||||
button = Fw::MouseRightButton;
|
||||
|
||||
if(event.type & EventDown)
|
||||
m_rootWidget->onMousePress(event.mousePos, button);
|
||||
|
@ -151,7 +151,7 @@ OTMLNodePtr UIManager::getStyle(const std::string& styleName)
|
|||
|
||||
auto it = m_styles.find(styleName);
|
||||
if(it == m_styles.end())
|
||||
throw std::runtime_error(fw::mkstr("style '", styleName, "' is not a defined style"));
|
||||
throw std::runtime_error(Fw::mkstr("style '", styleName, "' is not a defined style"));
|
||||
return m_styles[styleName];
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
UIWidget::UIWidget()
|
||||
{
|
||||
m_updateEventScheduled = false;
|
||||
m_states = DefaultState;
|
||||
m_states = Fw::DefaultState;
|
||||
|
||||
// generate an unique id, this is need because anchored layouts find widgets by id
|
||||
static unsigned long id = 1;
|
||||
m_id = fw::mkstr("widget", id++);
|
||||
m_id = Fw::mkstr("widget", id++);
|
||||
}
|
||||
|
||||
UIWidget::~UIWidget()
|
||||
|
@ -62,8 +62,8 @@ void UIWidget::setup()
|
|||
setPressed(false);
|
||||
setSizeFixed(false);
|
||||
setFont(g_fonts.getDefaultFont());
|
||||
setBackgroundColor(Color::white);
|
||||
setForegroundColor(Color::white);
|
||||
setBackgroundColor(Fw::white);
|
||||
setForegroundColor(Fw::white);
|
||||
setOpacity(255);
|
||||
setMarginTop(0);
|
||||
setMarginRight(0);
|
||||
|
@ -272,7 +272,7 @@ UIWidgetPtr UIWidget::backwardsGetWidgetById(const std::string& id)
|
|||
return widget;
|
||||
}
|
||||
|
||||
void UIWidget::focusChild(const UIWidgetPtr& child, FocusReason reason)
|
||||
void UIWidget::focusChild(const UIWidgetPtr& child, Fw::FocusReason reason)
|
||||
{
|
||||
if(child && !hasChild(child)) {
|
||||
logError("attempt to focus an unknown child in a UIWidget");
|
||||
|
@ -285,14 +285,14 @@ void UIWidget::focusChild(const UIWidgetPtr& child, FocusReason reason)
|
|||
|
||||
if(child) {
|
||||
child->setLastFocusReason(reason);
|
||||
child->updateState(FocusState);
|
||||
child->updateState(ActiveState);
|
||||
child->updateState(Fw::FocusState);
|
||||
child->updateState(Fw::ActiveState);
|
||||
}
|
||||
|
||||
if(oldFocused) {
|
||||
oldFocused->setLastFocusReason(reason);
|
||||
oldFocused->updateState(FocusState);
|
||||
oldFocused->updateState(ActiveState);
|
||||
oldFocused->updateState(Fw::FocusState);
|
||||
oldFocused->updateState(Fw::ActiveState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ void UIWidget::addChild(const UIWidgetPtr& child)
|
|||
|
||||
// always focus new child
|
||||
if(child->isFocusable() && child->isExplicitlyVisible() && child->isExplicitlyEnabled())
|
||||
focusChild(child, ActiveFocusReason);
|
||||
focusChild(child, Fw::ActiveFocusReason);
|
||||
|
||||
// create default layout
|
||||
if(!m_layout)
|
||||
|
@ -366,7 +366,7 @@ void UIWidget::removeChild(const UIWidgetPtr& child)
|
|||
if(it != m_children.end()) {
|
||||
// defocus if needed
|
||||
if(m_focusedChild == child)
|
||||
focusChild(nullptr, ActiveFocusReason);
|
||||
focusChild(nullptr, Fw::ActiveFocusReason);
|
||||
|
||||
// unlock child if it was locked
|
||||
unlockChild(child);
|
||||
|
@ -385,7 +385,7 @@ void UIWidget::removeChild(const UIWidgetPtr& child)
|
|||
logError("attempt to remove an unknown child from a UIWidget");
|
||||
}
|
||||
|
||||
void UIWidget::focusNextChild(FocusReason reason)
|
||||
void UIWidget::focusNextChild(Fw::FocusReason reason)
|
||||
{
|
||||
UIWidgetPtr toFocus;
|
||||
UIWidgetList rotatedChildren(m_children);
|
||||
|
@ -444,7 +444,7 @@ void UIWidget::lockChild(const UIWidgetPtr& child)
|
|||
|
||||
// lock child focus
|
||||
if(child->isFocusable())
|
||||
focusChild(child, ActiveFocusReason);
|
||||
focusChild(child, Fw::ActiveFocusReason);
|
||||
|
||||
moveChildToTop(child);
|
||||
}
|
||||
|
@ -495,13 +495,13 @@ void UIWidget::updateLayout()
|
|||
m_layout->update();
|
||||
}
|
||||
|
||||
void UIWidget::updateState(WidgetState state)
|
||||
void UIWidget::updateState(Fw::WidgetState state)
|
||||
{
|
||||
bool newStatus = true;
|
||||
bool oldStatus = hasState(state);
|
||||
bool updateChildren = false;
|
||||
|
||||
if(state == ActiveState) {
|
||||
if(state == Fw::ActiveState) {
|
||||
UIWidgetPtr widget = asUIWidget();
|
||||
UIWidgetPtr parent;
|
||||
do {
|
||||
|
@ -515,10 +515,10 @@ void UIWidget::updateState(WidgetState state)
|
|||
|
||||
updateChildren = true;
|
||||
}
|
||||
else if(state == FocusState) {
|
||||
else if(state == Fw::FocusState) {
|
||||
newStatus = (getParent() && getParent()->getFocusedChild() == asUIWidget());
|
||||
}
|
||||
else if(state == HoverState) {
|
||||
else if(state == Fw::HoverState) {
|
||||
updateChildren = true;
|
||||
Point mousePos = g_platform.getMouseCursorPos();
|
||||
UIWidgetPtr widget = asUIWidget();
|
||||
|
@ -532,10 +532,10 @@ void UIWidget::updateState(WidgetState state)
|
|||
}
|
||||
} while(widget = parent);
|
||||
}
|
||||
else if(state == PressedState) {
|
||||
else if(state == Fw::PressedState) {
|
||||
newStatus = m_pressed;
|
||||
}
|
||||
else if(state == DisabledState) {
|
||||
else if(state == Fw::DisabledState) {
|
||||
bool enabled = true;
|
||||
updateChildren = true;
|
||||
UIWidgetPtr widget = asUIWidget();
|
||||
|
@ -564,19 +564,19 @@ void UIWidget::updateState(WidgetState state)
|
|||
|
||||
updateStyle();
|
||||
|
||||
if(state == FocusState)
|
||||
if(state == Fw::FocusState)
|
||||
onFocusChange(newStatus, m_lastFocusReason);
|
||||
else if(state == HoverState)
|
||||
else if(state == Fw::HoverState)
|
||||
onHoverChange(newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::updateStates()
|
||||
{
|
||||
updateState(ActiveState);
|
||||
updateState(FocusState);
|
||||
updateState(DisabledState);
|
||||
updateState(HoverState);
|
||||
updateState(Fw::ActiveState);
|
||||
updateState(Fw::FocusState);
|
||||
updateState(Fw::DisabledState);
|
||||
updateState(Fw::HoverState);
|
||||
}
|
||||
|
||||
void UIWidget::updateStyle()
|
||||
|
@ -596,23 +596,23 @@ void UIWidget::updateStyle()
|
|||
|
||||
// merge states styles, NOTE: order does matter
|
||||
OTMLNodePtr style = m_style->get("state.active");
|
||||
if(style && hasState(ActiveState))
|
||||
if(style && hasState(Fw::ActiveState))
|
||||
newStateStyle->merge(style);
|
||||
|
||||
style = m_style->get("state.focus");
|
||||
if(style && hasState(FocusState))
|
||||
if(style && hasState(Fw::FocusState))
|
||||
newStateStyle->merge(style);
|
||||
|
||||
style = m_style->get("state.hover");
|
||||
if(style && hasState(HoverState))
|
||||
if(style && hasState(Fw::HoverState))
|
||||
newStateStyle->merge(style);
|
||||
|
||||
style = m_style->get("state.pressed");
|
||||
if(style && hasState(PressedState))
|
||||
if(style && hasState(Fw::PressedState))
|
||||
newStateStyle->merge(style);
|
||||
|
||||
style = m_style->get("state.disabled");
|
||||
if(style && hasState(DisabledState))
|
||||
if(style && hasState(Fw::DisabledState))
|
||||
newStateStyle->merge(style);
|
||||
|
||||
applyStyle(newStateStyle);
|
||||
|
@ -725,7 +725,7 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
|
|||
} else if(what == "centerIn") {
|
||||
anchorLayout->centerIn(asUIWidget(), node->value());
|
||||
} else {
|
||||
AnchorEdge anchoredEdge = fw::translateAnchorEdge(what);
|
||||
Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what);
|
||||
|
||||
std::string anchorDescription = node->value();
|
||||
std::vector<std::string> split;
|
||||
|
@ -734,12 +734,12 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
|
|||
throw OTMLException(node, "invalid anchor description");
|
||||
|
||||
std::string hookedWidgetId = split[0];
|
||||
AnchorEdge hookedEdge = fw::translateAnchorEdge(split[1]);
|
||||
Fw::AnchorEdge hookedEdge = Fw::translateAnchorEdge(split[1]);
|
||||
|
||||
if(anchoredEdge == AnchorNone)
|
||||
if(anchoredEdge == Fw::AnchorNone)
|
||||
throw OTMLException(node, "invalid anchor edge");
|
||||
|
||||
if(hookedEdge == AnchorNone)
|
||||
if(hookedEdge == Fw::AnchorNone)
|
||||
throw OTMLException(node, "invalid anchor target edge");
|
||||
|
||||
anchorLayout->addAnchor(asUIWidget(), anchoredEdge, hookedWidgetId, hookedEdge);
|
||||
|
@ -753,7 +753,7 @@ void UIWidget::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
|
|||
|
||||
}
|
||||
|
||||
void UIWidget::onFocusChange(bool focused, FocusReason reason)
|
||||
void UIWidget::onFocusChange(bool focused, Fw::FocusReason reason)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -807,7 +807,7 @@ bool UIWidget::onKeyRelease(uchar keyCode, char keyChar, int keyboardModifiers)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
|
||||
bool UIWidget::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
// do a backup of children list, because it may change while looping it
|
||||
UIWidgetList children;
|
||||
|
@ -824,7 +824,7 @@ bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
|
|||
for(const UIWidgetPtr& child : children) {
|
||||
// when a focusable item is focused it must gain focus
|
||||
if(child->isFocusable())
|
||||
focusChild(child, MouseFocusReason);
|
||||
focusChild(child, Fw::MouseFocusReason);
|
||||
|
||||
bool mustEnd = child->onMousePress(mousePos, button);
|
||||
|
||||
|
@ -838,7 +838,7 @@ bool UIWidget::onMousePress(const Point& mousePos, MouseButton button)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::onMouseRelease(const Point& mousePos, MouseButton button)
|
||||
bool UIWidget::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
// do a backup of children list, because it may change while looping it
|
||||
UIWidgetList children;
|
||||
|
@ -885,7 +885,7 @@ bool UIWidget::onMouseMove(const Point& mousePos, const Point& mouseMoved)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool UIWidget::onMouseWheel(const Point& mousePos, MouseWheelDirection direction)
|
||||
bool UIWidget::onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction)
|
||||
{
|
||||
// do a backup of children list, because it may change while looping it
|
||||
UIWidgetList children;
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
virtual void setup();
|
||||
virtual void render();
|
||||
|
||||
void setEnabled(bool enabled) { m_enabled = enabled; updateState(DisabledState); }
|
||||
void setEnabled(bool enabled) { m_enabled = enabled; updateState(Fw::DisabledState); }
|
||||
void setVisible(bool visible) { m_visible = visible; }
|
||||
void setPressed(bool pressed) { m_pressed = pressed; updateState(PressedState); }
|
||||
void setPressed(bool pressed) { m_pressed = pressed; updateState(Fw::PressedState); }
|
||||
void setId(const std::string& id) { m_id = id; }
|
||||
void setFocusable(bool focusable) { m_focusable = focusable; }
|
||||
void setStyle(const std::string& styleName);
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); }
|
||||
void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); }
|
||||
void setSizeFixed(bool fixed) { m_fixedSize = fixed; updateParentLayout(); }
|
||||
void setLastFocusReason(FocusReason reason) { m_lastFocusReason = reason; }
|
||||
void setLastFocusReason(Fw::FocusReason reason) { m_lastFocusReason = reason; }
|
||||
|
||||
void resize(const Size& size) { setRect(Rect(getPosition(), size)); }
|
||||
void moveTo(const Point& pos) { setRect(Rect(pos, getSize())); }
|
||||
|
@ -74,12 +74,12 @@ public:
|
|||
void disable() { setEnabled(false); }
|
||||
void enable() { setEnabled(true); }
|
||||
|
||||
bool isActive() const { return hasState(ActiveState); }
|
||||
bool isEnabled() const { return !hasState(DisabledState); }
|
||||
bool isDisabled() const { return hasState(DisabledState); }
|
||||
bool isFocused() const { return hasState(FocusState); }
|
||||
bool isHovered() const { return hasState(HoverState); }
|
||||
bool isPressed() const { return hasState(PressedState); }
|
||||
bool isActive() const { return hasState(Fw::ActiveState); }
|
||||
bool isEnabled() const { return !hasState(Fw::DisabledState); }
|
||||
bool isDisabled() const { return hasState(Fw::DisabledState); }
|
||||
bool isFocused() const { return hasState(Fw::FocusState); }
|
||||
bool isHovered() const { return hasState(Fw::HoverState); }
|
||||
bool isPressed() const { return hasState(Fw::PressedState); }
|
||||
bool isVisible();
|
||||
bool isExplicitlyEnabled() const { return m_enabled; }
|
||||
bool isExplicitlyVisible() const { return m_visible; }
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
bool isSizeFixed() const { return m_fixedSize; }
|
||||
bool hasChildren() const { return m_children.size() > 0; }
|
||||
bool hasChild(const UIWidgetPtr& child);
|
||||
bool hasState(WidgetState state) const { return m_states & state; }
|
||||
bool hasState(Fw::WidgetState state) const { return m_states & state; }
|
||||
|
||||
std::string getId() const { return m_id; }
|
||||
int getChildCount() const { return m_children.size(); }
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
int getMarginRight() const { return m_marginRight; }
|
||||
int getMarginTop() const { return m_marginTop; }
|
||||
int getMarginBottom() const { return m_marginBottom; }
|
||||
FocusReason getLastFocusReason() const { return m_lastFocusReason; }
|
||||
Fw::FocusReason getLastFocusReason() const { return m_lastFocusReason; }
|
||||
|
||||
UIWidgetList getChildren() const { return m_children; }
|
||||
UIWidgetPtr getFocusedChild() const { return m_focusedChild; }
|
||||
|
@ -126,15 +126,15 @@ public:
|
|||
void addChild(const UIWidgetPtr& child);
|
||||
void insertChild(int index, const UIWidgetPtr& child);
|
||||
void removeChild(const UIWidgetPtr& child);
|
||||
void focusChild(const UIWidgetPtr& child, FocusReason reason);
|
||||
void focusNextChild(FocusReason reason);
|
||||
void focusChild(const UIWidgetPtr& child, Fw::FocusReason reason);
|
||||
void focusNextChild(Fw::FocusReason reason);
|
||||
void moveChildToTop(const UIWidgetPtr& child);
|
||||
void lockChild(const UIWidgetPtr& child);
|
||||
void unlockChild(const UIWidgetPtr& child);
|
||||
|
||||
void updateParentLayout();
|
||||
void updateLayout();
|
||||
virtual void updateState(WidgetState state);
|
||||
virtual void updateState(Fw::WidgetState state);
|
||||
void updateStates();
|
||||
virtual void updateStyle();
|
||||
void applyStyle(const OTMLNodePtr& styleNode);
|
||||
|
@ -153,7 +153,7 @@ protected:
|
|||
/// Triggered when widget is moved or resized
|
||||
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
|
||||
/// Triggered when widget gets or loses focus
|
||||
virtual void onFocusChange(bool focused, FocusReason reason);
|
||||
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
|
||||
/// Triggered when the mouse enters or leaves widget area
|
||||
virtual void onHoverChange(bool hovered);
|
||||
/// Triggered when user presses key while widget has focus
|
||||
|
@ -161,19 +161,19 @@ protected:
|
|||
/// Triggered when user releases key while widget has focus
|
||||
virtual bool onKeyRelease(uchar keyCode, char keyChar, int keyboardModifiers);
|
||||
/// Triggered when a mouse button is pressed down while mouse pointer is inside widget area
|
||||
virtual bool onMousePress(const Point& mousePos, MouseButton button);
|
||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
/// Triggered when a mouse button is released
|
||||
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
/// Triggered when mouse moves (even when the mouse is outside widget area)
|
||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||
/// Triggered when mouse middle button wheels inside widget area
|
||||
virtual bool onMouseWheel(const Point& mousePos, MouseWheelDirection direction);
|
||||
virtual bool onMouseWheel(const Point& mousePos, Fw::MouseWheelDirection direction);
|
||||
|
||||
friend class UIManager;
|
||||
|
||||
protected:
|
||||
std::string m_id;
|
||||
FocusReason m_lastFocusReason;
|
||||
Fw::FocusReason m_lastFocusReason;
|
||||
bool m_enabled;
|
||||
bool m_visible;
|
||||
bool m_focusable;
|
||||
|
|
|
@ -32,7 +32,7 @@ void UIWindow::setup()
|
|||
m_moving = false;
|
||||
m_headHeight = 0;
|
||||
m_headMargin = 0;
|
||||
m_titleAlign = AlignCenter;
|
||||
m_titleAlign = Fw::AlignCenter;
|
||||
}
|
||||
|
||||
void UIWindow::render()
|
||||
|
@ -47,9 +47,9 @@ void UIWindow::render()
|
|||
|
||||
// draw window head text
|
||||
Rect headTextRect = headRect;
|
||||
if(m_titleAlign & AlignLeft)
|
||||
if(m_titleAlign & Fw::AlignLeft)
|
||||
headTextRect.addLeft(-m_headMargin);
|
||||
else if(m_titleAlign & AlignRight)
|
||||
else if(m_titleAlign & Fw::AlignRight)
|
||||
headTextRect.addRight(-m_headMargin);
|
||||
m_font->renderText(m_title, headTextRect, m_titleAlign, m_foregroundColor);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ void UIWindow::onStyleApply(const OTMLNodePtr& styleNode)
|
|||
m_headImage = BorderImage::loadFromOTML(cnode);
|
||||
m_headHeight = node->valueAt("height", m_headImage->getDefaultSize().height());
|
||||
m_headMargin = node->valueAt("margin", 0);
|
||||
m_titleAlign = fw::translateAlignment(node->valueAt("text align", std::string("center")));
|
||||
m_titleAlign = Fw::translateAlignment(node->valueAt("text align", std::string("center")));
|
||||
}
|
||||
else if(node->tag() == "body") {
|
||||
if(OTMLNodePtr cnode = node->get("border-image"))
|
||||
|
@ -109,7 +109,7 @@ void UIWindow::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
|
|||
setRect(boundRect);
|
||||
}
|
||||
|
||||
void UIWindow::onFocusChange(bool focused, FocusReason reason)
|
||||
void UIWindow::onFocusChange(bool focused, Fw::FocusReason reason)
|
||||
{
|
||||
// when a window is focused it goes to the top
|
||||
if(focused) {
|
||||
|
@ -118,7 +118,7 @@ void UIWindow::onFocusChange(bool focused, FocusReason reason)
|
|||
}
|
||||
}
|
||||
|
||||
bool UIWindow::onMousePress(const Point& mousePos, MouseButton button)
|
||||
bool UIWindow::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
if(!getChildByPos(mousePos)) {
|
||||
m_moving = true;
|
||||
|
@ -128,7 +128,7 @@ bool UIWindow::onMousePress(const Point& mousePos, MouseButton button)
|
|||
return UIWidget::onMousePress(mousePos, button);
|
||||
}
|
||||
|
||||
bool UIWindow::onMouseRelease(const Point& mousePos, MouseButton button)
|
||||
bool UIWindow::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
|
||||
{
|
||||
if(m_moving) {
|
||||
m_moving = false;
|
||||
|
|
|
@ -37,9 +37,9 @@ public:
|
|||
protected:
|
||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||
virtual void onGeometryUpdate(const Rect& oldRect, const Rect& newRect);
|
||||
virtual void onFocusChange(bool focused, FocusReason reason);
|
||||
virtual bool onMousePress(const Point& mousePos, MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, MouseButton button);
|
||||
virtual void onFocusChange(bool focused, Fw::FocusReason reason);
|
||||
virtual bool onMousePress(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseRelease(const Point& mousePos, Fw::MouseButton button);
|
||||
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
|
||||
|
||||
private:
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
ImagePtr m_bodyImage;
|
||||
int m_headHeight;
|
||||
int m_headMargin;
|
||||
AlignmentFlag m_titleAlign;
|
||||
Fw::AlignmentFlag m_titleAlign;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* 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 "color.h"
|
||||
|
||||
Color Color::white (0xFF, 0xFF, 0xFF, 0xFF);
|
||||
Color Color::black (0x00, 0x00, 0x00, 0xFF);
|
||||
Color Color::alpha (0x00, 0x00, 0x00, 0x00);
|
||||
Color Color::red (0xFF, 0x00, 0x00, 0xFF);
|
||||
Color Color::green (0x00, 0xFF, 0x00, 0xFF);
|
||||
Color Color::blue (0x00, 0x00, 0xFF, 0xFF);
|
||||
Color Color::pink (0xFF, 0x00, 0xFF, 0xFF);
|
||||
Color Color::yellow(0xFF, 0xFF, 0x00, 0xFF);
|
|
@ -77,15 +77,6 @@ public:
|
|||
bool operator==(const Color& other) const { return other.color.rgba == color.rgba; }
|
||||
bool operator!=(const Color& other) const { return other.color.rgba != color.rgba; }
|
||||
|
||||
static Color white;
|
||||
static Color black;
|
||||
static Color alpha;
|
||||
static Color red;
|
||||
static Color green;
|
||||
static Color blue;
|
||||
static Color pink;
|
||||
static Color yellow;
|
||||
|
||||
private:
|
||||
RGBA color;
|
||||
};
|
||||
|
@ -111,11 +102,11 @@ inline std::istream& operator>>(std::istream& in, Color& color)
|
|||
in >> tmp;
|
||||
|
||||
if(tmp.length() == 6 || tmp.length() == 8) {
|
||||
color.setRed((uint8)fw::hex2dec(tmp.substr(0, 2)));
|
||||
color.setGreen((uint8)fw::hex2dec(tmp.substr(2, 2)));
|
||||
color.setBlue((uint8)fw::hex2dec(tmp.substr(4, 2)));
|
||||
color.setRed((uint8)Fw::hex2dec(tmp.substr(0, 2)));
|
||||
color.setGreen((uint8)Fw::hex2dec(tmp.substr(2, 2)));
|
||||
color.setBlue((uint8)Fw::hex2dec(tmp.substr(4, 2)));
|
||||
if(tmp.length() == 8)
|
||||
color.setAlpha((uint8)fw::hex2dec(tmp.substr(6, 2)));
|
||||
color.setAlpha((uint8)Fw::hex2dec(tmp.substr(6, 2)));
|
||||
else
|
||||
color.setAlpha(255);
|
||||
} else
|
||||
|
|
|
@ -24,12 +24,7 @@
|
|||
#define SIZE_H
|
||||
|
||||
#include "point.h"
|
||||
|
||||
enum ESizeScaleMode {
|
||||
IGNORE_ASPECT_RATIO,
|
||||
KEEP_ASPECT_RATIO,
|
||||
KEEP_ASPECT_RATIO_BY_EXPANDING
|
||||
};
|
||||
#include "../const.h"
|
||||
|
||||
template<class T>
|
||||
class TSize
|
||||
|
@ -74,17 +69,17 @@ public:
|
|||
TSize<T> expandedTo(const TSize<T>& other) const { return TSize<T>(std::max(wd,other.wd), std::max(ht,other.ht)); }
|
||||
TSize<T> boundedTo(const TSize<T>& other) const { return TSize<T>(std::min(wd,other.wd), std::min(ht,other.ht)); }
|
||||
|
||||
void scale(const TSize<T>& s, ESizeScaleMode mode) {
|
||||
if(mode == IGNORE_ASPECT_RATIO || wd == 0 || ht == 0) {
|
||||
void scale(const TSize<T>& s, Fw::AspectRatioMode mode) {
|
||||
if(mode == Fw::IgnoreAspectRatio || wd == 0 || ht == 0) {
|
||||
wd = s.wd;
|
||||
ht = s.ht;
|
||||
} else {
|
||||
bool useHeight;
|
||||
T rw = (s.ht * wd) / ht;
|
||||
|
||||
if(mode == KEEP_ASPECT_RATIO)
|
||||
if(mode == Fw::KeepAspectRatio)
|
||||
useHeight = (rw <= s.wd);
|
||||
else // mode == KEEP_ASPECT_RATIO_BY_EXPANDING
|
||||
else // mode == Fw::KeepAspectRatioByExpanding
|
||||
useHeight = (rw >= s.wd);
|
||||
|
||||
if(useHeight) {
|
||||
|
@ -96,7 +91,7 @@ public:
|
|||
}
|
||||
}
|
||||
}
|
||||
void scale(int w, int h, ESizeScaleMode mode) { scale(TSize<T>(w, h)); }
|
||||
void scale(int w, int h, Fw::AspectRatioMode mode) { scale(TSize<T>(w, h)); }
|
||||
|
||||
float ratio() const { return (float)wd/ht; }
|
||||
T area() const { return wd*ht; }
|
||||
|
|
|
@ -31,22 +31,22 @@
|
|||
#include <cxxabi.h>
|
||||
#include "types.h"
|
||||
|
||||
namespace fw {
|
||||
namespace Fw {
|
||||
|
||||
// read utilities for istream
|
||||
inline uint8 getu8(std::istream& in) {
|
||||
inline uint8 getU8(std::istream& in) {
|
||||
uint8 tmp;
|
||||
in.read((char*)&tmp, 1);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline uint16 getu16(std::istream& in) {
|
||||
inline uint16 getU16(std::istream& in) {
|
||||
uint16 tmp;
|
||||
in.read((char*)&tmp, 2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline uint32 getu32(std::istream& in) {
|
||||
inline uint32 getU32(std::istream& in) {
|
||||
uint32 tmp;
|
||||
in.read((char*)&tmp, 4);
|
||||
return tmp;
|
||||
|
@ -54,21 +54,21 @@ inline uint32 getu32(std::istream& in) {
|
|||
|
||||
/// Fill an ostream by concatenating args
|
||||
/// Usage:
|
||||
/// fw::fill_ostream(stream, a1, a2, ..., aN);
|
||||
inline void fill_ostream(std::ostringstream&) { }
|
||||
/// Fw::fill_ostream(stream, a1, a2, ..., aN);
|
||||
inline void fillOstream(std::ostringstream&) { }
|
||||
template<class T, class... Args>
|
||||
void fill_ostream(std::ostringstream& stream, const T& first, const Args&... rest) {
|
||||
void fillOstream(std::ostringstream& stream, const T& first, const Args&... rest) {
|
||||
stream << first;
|
||||
fill_ostream(stream, rest...);
|
||||
fillOstream(stream, rest...);
|
||||
}
|
||||
|
||||
/// Makes a std::string by concatenating args
|
||||
/// Usage:
|
||||
/// std::string str = fw::mkstr(a1, a2, ..., aN);
|
||||
/// std::string str = Fw::mkstr(a1, a2, ..., aN);
|
||||
template<class... T>
|
||||
std::string mkstr(const T&... args) {
|
||||
std::ostringstream buf;
|
||||
fill_ostream(buf, args...);
|
||||
fillOstream(buf, args...);
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ struct dump_util {
|
|||
|
||||
/// Utility for dumping variables
|
||||
/// Usage:
|
||||
/// fw::dump << v1, v2, ..., vN;
|
||||
/// Fw::dump << v1, v2, ..., vN;
|
||||
struct dumper {
|
||||
dumper() { }
|
||||
template<class T>
|
||||
|
@ -97,15 +97,15 @@ struct dumper {
|
|||
|
||||
/// Utility for printing messages into stdout
|
||||
/// Usage:
|
||||
/// fw::print(v1, v2, ..., vN);
|
||||
/// Fw::print(v1, v2, ..., vN);
|
||||
template<class... T>
|
||||
void print(const T&... args) {
|
||||
std::ostringstream buf;
|
||||
fill_ostream(buf, args...);
|
||||
fillOstream(buf, args...);
|
||||
std::cout << buf.str();
|
||||
}
|
||||
|
||||
/// Same as fw::print but adds a new line at the end
|
||||
/// Same as Fw::print but adds a new line at the end
|
||||
template<class... T>
|
||||
void println(const T&... args) {
|
||||
print(args...);
|
||||
|
@ -113,7 +113,7 @@ void println(const T&... args) {
|
|||
}
|
||||
|
||||
/// Demangle names for GNU g++ compiler
|
||||
inline std::string demangle_name(const char* name) {
|
||||
inline std::string demangleName(const char* name) {
|
||||
size_t len;
|
||||
int status;
|
||||
std::string ret;
|
||||
|
@ -126,10 +126,10 @@ inline std::string demangle_name(const char* name) {
|
|||
}
|
||||
|
||||
/// Returns the name of a type
|
||||
/// e.g. fw::demangle_type<Foo*>() returns a string containing 'Foo*'
|
||||
/// e.g. Fw::demangle_type<Foo*>() returns a string containing 'Foo*'
|
||||
template<typename T>
|
||||
std::string demangle_type() {
|
||||
return demangle_name(typeid(T).name());
|
||||
std::string demangleType() {
|
||||
return demangleName(typeid(T).name());
|
||||
}
|
||||
|
||||
/// Cast a type to another type
|
||||
|
@ -185,27 +185,27 @@ inline bool cast(const bool& in, std::string& out) {
|
|||
}
|
||||
|
||||
// used by safe_cast
|
||||
class bad_cast : public std::bad_cast {
|
||||
class BadCast : public std::bad_cast {
|
||||
public:
|
||||
virtual ~bad_cast() throw() { }
|
||||
virtual ~BadCast() throw() { }
|
||||
template<class T, class R>
|
||||
void setWhat() {
|
||||
m_what = mkstr("failed to cast value of type '", demangle_type<T>(),
|
||||
"' to type '", demangle_type<R>(), "'");
|
||||
m_what = mkstr("failed to cast value of type '", demangleType<T>(),
|
||||
"' to type '", demangleType<R>(), "'");
|
||||
}
|
||||
virtual const char* what() { return m_what.c_str(); }
|
||||
private:
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
/// Cast a type to another type, any error throws a fw::bad_cast_exception
|
||||
/// Cast a type to another type, any error throws a Fw::bad_cast_exception
|
||||
/// Usage:
|
||||
/// R r = fw::safe_cast<R>(t);
|
||||
/// R r = Fw::safe_cast<R>(t);
|
||||
template<typename R, typename T>
|
||||
R safe_cast(const T& t) {
|
||||
R safeCast(const T& t) {
|
||||
R r;
|
||||
if(!cast(t, r)) {
|
||||
bad_cast e;
|
||||
BadCast e;
|
||||
e.setWhat<T,R>();
|
||||
throw e;
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ R safe_cast(const T& t) {
|
|||
|
||||
/// Cast a type to another type, cast errors are ignored
|
||||
/// Usage:
|
||||
/// R r = fw::unsafe_cast<R>(t);
|
||||
/// R r = Fw::unsafe_cast<R>(t);
|
||||
template<typename R, typename T>
|
||||
R unsafe_cast(const T& t, R def = R()) {
|
||||
R unsafeCast(const T& t, R def = R()) {
|
||||
try {
|
||||
return safe_cast<R,T>(t);
|
||||
} catch(bad_cast& e) {
|
||||
return safeCast<R,T>(t);
|
||||
} catch(BadCast& e) {
|
||||
println("CAST ERROR: ", e.what());
|
||||
return def;
|
||||
}
|
||||
|
@ -227,12 +227,12 @@ R unsafe_cast(const T& t, R def = R()) {
|
|||
|
||||
template<typename T>
|
||||
std::string tostring(const T& t) {
|
||||
return unsafe_cast<std::string, T>(t);
|
||||
return unsafeCast<std::string, T>(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T fromstring(const std::string& str, T def = T()) {
|
||||
return unsafe_cast<T, std::string>(str, def);
|
||||
return unsafeCast<T, std::string>(str, def);
|
||||
}
|
||||
|
||||
inline std::string dec2hex(unsigned int num) {
|
||||
|
@ -261,7 +261,7 @@ const static std::string empty_string;
|
|||
|
||||
}
|
||||
|
||||
// shortcut for fw::dump
|
||||
const static fw::dumper dump;
|
||||
// shortcut for Fw::dump
|
||||
const static Fw::dumper dump;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,46 +23,46 @@
|
|||
#include "translator.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
AlignmentFlag fw::translateAlignment(std::string aligment)
|
||||
Fw::AlignmentFlag Fw::translateAlignment(std::string aligment)
|
||||
{
|
||||
boost::to_lower(aligment);
|
||||
boost::erase_all(aligment, " ");
|
||||
if(aligment == "topleft")
|
||||
return AlignTopLeft;
|
||||
return Fw::AlignTopLeft;
|
||||
else if(aligment == "topright")
|
||||
return AlignTopRight;
|
||||
return Fw::AlignTopRight;
|
||||
else if(aligment == "bottomleft")
|
||||
return AlignBottomLeft;
|
||||
return Fw::AlignBottomLeft;
|
||||
else if(aligment == "bottomright")
|
||||
return AlignBottomRight;
|
||||
return Fw::AlignBottomRight;
|
||||
else if(aligment == "left")
|
||||
return AlignLeftCenter;
|
||||
return Fw::AlignLeftCenter;
|
||||
else if(aligment == "right")
|
||||
return AlignRightCenter;
|
||||
return Fw::AlignRightCenter;
|
||||
else if(aligment == "top")
|
||||
return AlignTopCenter;
|
||||
return Fw::AlignTopCenter;
|
||||
else if(aligment == "bottom")
|
||||
return AlignBottomCenter;
|
||||
return Fw::AlignBottomCenter;
|
||||
else if(aligment == "center")
|
||||
return AlignCenter;
|
||||
return AlignNone;
|
||||
return Fw::AlignCenter;
|
||||
return Fw::AlignNone;
|
||||
}
|
||||
|
||||
AnchorEdge fw::translateAnchorEdge(std::string anchorEdge)
|
||||
Fw::AnchorEdge Fw::translateAnchorEdge(std::string anchorEdge)
|
||||
{
|
||||
boost::to_lower(anchorEdge);
|
||||
boost::erase_all(anchorEdge, " ");
|
||||
if(anchorEdge == "left")
|
||||
return AnchorLeft;
|
||||
return Fw::AnchorLeft;
|
||||
else if(anchorEdge == "right")
|
||||
return AnchorRight;
|
||||
return Fw::AnchorRight;
|
||||
else if(anchorEdge == "top")
|
||||
return AnchorTop;
|
||||
return Fw::AnchorTop;
|
||||
else if(anchorEdge == "bottom")
|
||||
return AnchorBottom;
|
||||
return Fw::AnchorBottom;
|
||||
else if(anchorEdge == "horizontalcenter")
|
||||
return AnchorHorizontalCenter;
|
||||
return Fw::AnchorHorizontalCenter;
|
||||
else if(anchorEdge == "verticalcenter")
|
||||
return AnchorVerticalCenter;
|
||||
return AnchorNone;
|
||||
return Fw::AnchorVerticalCenter;
|
||||
return Fw::AnchorNone;
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
#include "../const.h"
|
||||
#include <string>
|
||||
|
||||
namespace fw {
|
||||
namespace Fw {
|
||||
|
||||
AlignmentFlag translateAlignment(std::string aligment);
|
||||
AnchorEdge translateAnchorEdge(std::string anchorEdge);
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
/*
|
||||
* 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 OTCLIENT_CORE_CONST_H
|
||||
#define OTCLIENT_CORE_CONST_H
|
||||
|
||||
#include <framework/util/color.h>
|
||||
|
||||
enum ThingAttributesGroup {
|
||||
THING_GROUP_NONE = 0,
|
||||
THING_GROUP_GROUND,
|
||||
THING_GROUP_CONTAINER,
|
||||
THING_GROUP_WEAPON,
|
||||
THING_GROUP_AMMUNITION,
|
||||
THING_GROUP_ARMOR,
|
||||
THING_GROUP_RUNE,
|
||||
THING_GROUP_TELEPORT,
|
||||
THING_GROUP_MAGICFIELD,
|
||||
THING_GROUP_WRITEABLE,
|
||||
THING_GROUP_KEY,
|
||||
THING_GROUP_SPLASH,
|
||||
THING_GROUP_FLUID,
|
||||
THING_GROUP_DOOR,
|
||||
THING_GROUP_LAST
|
||||
};
|
||||
|
||||
enum ThingType {
|
||||
THING_ITEM,
|
||||
THING_CREATURE,
|
||||
THING_EFFECT,
|
||||
THING_SHOT
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
DIRECTION_NORTH,
|
||||
DIRECTION_EAST,
|
||||
DIRECTION_SOUTH,
|
||||
DIRECTION_WEST
|
||||
};
|
||||
|
||||
enum SpriteMask {
|
||||
SpriteMaskRed = 0,
|
||||
SpriteMaskGreen,
|
||||
SpriteMaskBlue,
|
||||
SpriteMaskYellow,
|
||||
SpriteMaskNone = 255
|
||||
};
|
||||
|
||||
static const Color OutfitColors[] = {
|
||||
Color(255,255,255),
|
||||
Color(255,212,191),
|
||||
Color(255,233,191),
|
||||
Color(255,255,191),
|
||||
Color(233,255,191),
|
||||
Color(212,255,191),
|
||||
Color(191,255,191),
|
||||
Color(191,255,212),
|
||||
Color(191,255,233),
|
||||
Color(191,255,255),
|
||||
Color(191,233,255),
|
||||
Color(191,212,255),
|
||||
Color(191,191,255),
|
||||
Color(212,191,255),
|
||||
Color(233,191,255),
|
||||
Color(255,191,255),
|
||||
Color(255,191,233),
|
||||
Color(255,191,212),
|
||||
Color(255,191,191),
|
||||
|
||||
Color(128,128,128),
|
||||
Color(191,159,143),
|
||||
Color(191,175,143),
|
||||
Color(191,191,143),
|
||||
Color(175,191,143),
|
||||
Color(159,191,143),
|
||||
Color(143,191,143),
|
||||
Color(143,191,159),
|
||||
Color(143,191,175),
|
||||
Color(143,191,191),
|
||||
Color(143,175,191),
|
||||
Color(143,159,191),
|
||||
Color(143,143,191),
|
||||
Color(159,143,191),
|
||||
Color(175,143,191),
|
||||
Color(191,143,191),
|
||||
Color(191,143,175),
|
||||
Color(191,143,159),
|
||||
Color(191,143,143),
|
||||
|
||||
Color(182,182,182),
|
||||
Color(191,127,95),
|
||||
Color(191,159,95),
|
||||
Color(191,191,95),
|
||||
Color(159,191,95),
|
||||
Color(127,191,95),
|
||||
Color(95,191,95),
|
||||
Color(95,191,127),
|
||||
Color(95,191,159),
|
||||
Color(95,191,191),
|
||||
Color(95,159,191),
|
||||
Color(95,127,191),
|
||||
Color(95,95,191),
|
||||
Color(127,95,191),
|
||||
Color(159,95,191),
|
||||
Color(191,95,191),
|
||||
Color(191,95,159),
|
||||
Color(191,95,127),
|
||||
Color(191,95,95),
|
||||
|
||||
Color(145,145,145),
|
||||
Color(191,106,63),
|
||||
Color(191,148,63),
|
||||
Color(191,191,63),
|
||||
Color(148,191,63),
|
||||
Color(107,191,63),
|
||||
Color(63,191,63),
|
||||
Color(63,191,106),
|
||||
Color(63,191,148),
|
||||
Color(63,191,191),
|
||||
Color(63,148,191),
|
||||
Color(63,106,191),
|
||||
Color(63,63,191),
|
||||
Color(106,63,191),
|
||||
Color(148,63,191),
|
||||
Color(191,63,191),
|
||||
Color(191,63,148),
|
||||
Color(191,63,106),
|
||||
Color(191,63,63),
|
||||
|
||||
Color(109,109,109),
|
||||
Color(255,85,0),
|
||||
Color(255,170,0),
|
||||
Color(255,255,0),
|
||||
Color(170,255,0),
|
||||
Color(84,255,0),
|
||||
Color(0,255,0),
|
||||
Color(0,255,84),
|
||||
Color(0,255,170),
|
||||
Color(0,255,255),
|
||||
Color(0,169,255),
|
||||
Color(0,85,255),
|
||||
Color(0,0,255),
|
||||
Color(85,0,255),
|
||||
Color(169,0,255),
|
||||
Color(254,0,255),
|
||||
Color(255,0,170),
|
||||
Color(255,0,85),
|
||||
Color(255,0,0),
|
||||
|
||||
Color(72,72,72),
|
||||
Color(191,63,0),
|
||||
Color(191,127,0),
|
||||
Color(191,191,0),
|
||||
Color(127,191,0),
|
||||
Color(63,191,0),
|
||||
Color(0,191,0),
|
||||
Color(0,191,63),
|
||||
Color(0,191,127),
|
||||
Color(0,191,191),
|
||||
Color(0,127,191),
|
||||
Color(0,63,191),
|
||||
Color(0,0,191),
|
||||
Color(63,0,191),
|
||||
Color(127,0,191),
|
||||
Color(191,0,191),
|
||||
Color(191,0,127),
|
||||
Color(191,0,63),
|
||||
Color(191,0,0),
|
||||
|
||||
Color(36,36,36),
|
||||
Color(127,42,0),
|
||||
Color(127,85,0),
|
||||
Color(127,127,0),
|
||||
Color(85,127,0),
|
||||
Color(42,127,0),
|
||||
Color(0,127,0),
|
||||
Color(0,127,42),
|
||||
Color(0,127,85),
|
||||
Color(0,127,127),
|
||||
Color(0,84,127),
|
||||
Color(0,42,127),
|
||||
Color(0,0,127),
|
||||
Color(42,0,127),
|
||||
Color(84,0,127),
|
||||
Color(127,0,127),
|
||||
Color(191,0,85),
|
||||
Color(127,0,42),
|
||||
Color(127,0,0)
|
||||
};
|
||||
|
||||
#endif
|
|
@ -28,10 +28,10 @@
|
|||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/graphics/fontmanager.h>
|
||||
|
||||
Creature::Creature() : Thing(THING_CREATURE)
|
||||
Creature::Creature() : Thing(Otc::Creature)
|
||||
{
|
||||
m_healthPercent = 0;
|
||||
m_direction = DIRECTION_SOUTH;
|
||||
m_direction = Otc::South;
|
||||
m_animation = 0;
|
||||
|
||||
m_walking = false;
|
||||
|
@ -72,13 +72,13 @@ void Creature::draw(int x, int y)
|
|||
if(m_walking && attributes.animcount > 1) {
|
||||
double offset = (32.0 / m_walkTime) * (g_platform.getTicks() - m_lastTicks);
|
||||
|
||||
if(m_direction == DIRECTION_NORTH)
|
||||
if(m_direction == Otc::North)
|
||||
m_walkOffsetY = std::max(m_walkOffsetY - offset, 0.0);
|
||||
else if(m_direction == DIRECTION_EAST)
|
||||
else if(m_direction == Otc::East)
|
||||
m_walkOffsetX = std::min(m_walkOffsetX + offset, 0.0);
|
||||
else if(m_direction == DIRECTION_SOUTH)
|
||||
else if(m_direction == Otc::South)
|
||||
m_walkOffsetY = std::min(m_walkOffsetY + offset, 0.0);
|
||||
else if(m_direction == DIRECTION_WEST)
|
||||
else if(m_direction == Otc::West)
|
||||
m_walkOffsetX = std::max(m_walkOffsetX - offset, 0.0);
|
||||
|
||||
/*if(g_platform.getTicks() - m_lastTicks > m_speed / 4) {
|
||||
|
@ -117,26 +117,26 @@ void Creature::draw(int x, int y)
|
|||
|
||||
// draw mask if exists
|
||||
if(attributes.blendframes > 1) {
|
||||
g_graphics.bindBlendFunc(BLEND_COLORIZING);
|
||||
g_graphics.bindBlendFunc(Fw::BlendColorzing);
|
||||
|
||||
for(int mask = 0; mask < 4; ++mask) {
|
||||
|
||||
int outfitColorId = 0;
|
||||
if(mask == SpriteMaskYellow)
|
||||
if(mask == Otc::SpriteYellowMask)
|
||||
outfitColorId = m_outfit.head;
|
||||
else if(mask == SpriteMaskRed)
|
||||
else if(mask == Otc::SpriteRedMask)
|
||||
outfitColorId = m_outfit.body;
|
||||
else if(mask == SpriteMaskGreen)
|
||||
else if(mask == Otc::SpriteGreenMask)
|
||||
outfitColorId = m_outfit.legs;
|
||||
else if(mask == SpriteMaskBlue)
|
||||
else if(mask == Otc::SpriteBlueMask)
|
||||
outfitColorId = m_outfit.feet;
|
||||
|
||||
g_graphics.bindColor(OutfitColors[outfitColorId]);
|
||||
internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, (SpriteMask)mask);
|
||||
g_graphics.bindColor(Otc::OutfitColors[outfitColorId]);
|
||||
internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, (Otc::SpriteMask)mask);
|
||||
}
|
||||
|
||||
g_graphics.bindBlendFunc(BLEND_NORMAL);
|
||||
g_graphics.bindColor(Color::white);
|
||||
g_graphics.bindBlendFunc(Fw::BlendNormal);
|
||||
g_graphics.bindColor(Fw::white);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ void Creature::drawInformation(int x, int y, bool useGray)
|
|||
|
||||
if(!useGray) {
|
||||
// health bar according to yatc
|
||||
fillColor = Color::black;
|
||||
fillColor = Fw::black;
|
||||
if(m_healthPercent > 92) {
|
||||
fillColor.setGreen(188);
|
||||
}
|
||||
|
@ -177,18 +177,18 @@ void Creature::drawInformation(int x, int y, bool useGray)
|
|||
Rect healthRect = backgroundRect.expanded(-1);
|
||||
healthRect.setWidth((m_healthPercent/100.0)*25);
|
||||
|
||||
g_graphics.bindColor(Color::black);
|
||||
g_graphics.bindColor(Fw::black);
|
||||
g_graphics.drawFilledRect(backgroundRect);
|
||||
|
||||
g_graphics.bindColor(fillColor);
|
||||
g_graphics.drawFilledRect(healthRect);
|
||||
|
||||
// restore white color
|
||||
g_graphics.bindColor(Color::white);
|
||||
g_graphics.bindColor(Fw::white);
|
||||
|
||||
// name
|
||||
FontPtr font = g_fonts.getFont("tibia-12px-rounded");
|
||||
font->renderText(m_name, Rect(x-100, y-15, 200, 15), AlignTopCenter, fillColor);
|
||||
font->renderText(m_name, Rect(x-100, y-15, 200, 15), Fw::AlignTopCenter, fillColor);
|
||||
}
|
||||
|
||||
void Creature::walk(const Position& position)
|
||||
|
@ -206,19 +206,19 @@ void Creature::walk(const Position& position)
|
|||
|
||||
// set new direction
|
||||
if(m_walkingFromPosition + Position(0, -1, 0) == m_position) {
|
||||
m_direction = DIRECTION_NORTH;
|
||||
m_direction = Otc::North;
|
||||
m_walkOffsetY = 32;
|
||||
}
|
||||
else if(m_walkingFromPosition + Position(1, 0, 0) == m_position) {
|
||||
m_direction = DIRECTION_EAST;
|
||||
m_direction = Otc::East;
|
||||
m_walkOffsetX = -32;
|
||||
}
|
||||
else if(m_walkingFromPosition + Position(0, 1, 0) == m_position) {
|
||||
m_direction = DIRECTION_SOUTH;
|
||||
m_direction = Otc::South;
|
||||
m_walkOffsetY = -32;
|
||||
}
|
||||
else if(m_walkingFromPosition + Position(-1, 0, 0) == m_position) {
|
||||
m_direction = DIRECTION_WEST;
|
||||
m_direction = Otc::West;
|
||||
m_walkOffsetX = 32;
|
||||
}
|
||||
else { // Teleport
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
void setName(const std::string& name) { m_name = name; }
|
||||
void setHealthPercent(uint8 healthPercent) { m_healthPercent = healthPercent; }
|
||||
void setDirection(Direction direction) { m_direction = direction; }
|
||||
void setDirection(Otc::Direction direction) { m_direction = direction; }
|
||||
void setOutfit(const Outfit& outfit) { m_outfit = outfit; }
|
||||
void setLight(const Light& light) { m_light = light; }
|
||||
void setSpeed(uint16 speed) { m_speed = speed; }
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
std::string getName() { return m_name; }
|
||||
uint8 getHealthPercent() { return m_healthPercent; }
|
||||
Direction getDirection() { return m_direction; }
|
||||
Otc::Direction getDirection() { return m_direction; }
|
||||
Outfit getOutfit() { return m_outfit; }
|
||||
Light getLight() { return m_light; }
|
||||
uint16 getSpeed() { return m_speed; }
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
private:
|
||||
std::string m_name;
|
||||
uint8 m_healthPercent;
|
||||
Direction m_direction;
|
||||
Otc::Direction m_direction;
|
||||
Outfit m_outfit;
|
||||
Light m_light;
|
||||
uint16 m_speed;
|
||||
|
|
|
@ -32,11 +32,11 @@ bool DatManager::load(const std::string& file)
|
|||
std::stringstream fin;
|
||||
g_resources.loadFile(file, fin);
|
||||
|
||||
m_signature = fw::getu32(fin);
|
||||
int numItems = fw::getu16(fin);
|
||||
int numCreatures = fw::getu16(fin);
|
||||
int numEffects = fw::getu16(fin);
|
||||
int numShots = fw::getu16(fin);
|
||||
m_signature = Fw::getU32(fin);
|
||||
int numItems = Fw::getU16(fin);
|
||||
int numCreatures = Fw::getU16(fin);
|
||||
int numEffects = Fw::getU16(fin);
|
||||
int numShots = Fw::getU16(fin);
|
||||
|
||||
m_itemsAttributes.resize(numItems);
|
||||
for(int id = 100; id < numItems; ++id)
|
||||
|
@ -83,16 +83,16 @@ void DatManager::parseThingAttributes(std::stringstream& fin, ThingAttributes& t
|
|||
parseThingAttributesOpt(fin, thingAttributes, opt);
|
||||
}
|
||||
|
||||
thingAttributes.width = fw::getu8(fin);
|
||||
thingAttributes.height = fw::getu8(fin);
|
||||
thingAttributes.width = Fw::getU8(fin);
|
||||
thingAttributes.height = Fw::getU8(fin);
|
||||
if(thingAttributes.width > 1 || thingAttributes.height > 1)
|
||||
fw::getu8(fin); // ??
|
||||
Fw::getU8(fin); // ??
|
||||
|
||||
thingAttributes.blendframes = fw::getu8(fin);
|
||||
thingAttributes.xdiv = fw::getu8(fin);
|
||||
thingAttributes.ydiv = fw::getu8(fin);
|
||||
thingAttributes.zdiv = fw::getu8(fin);
|
||||
thingAttributes.animcount = fw::getu8(fin);
|
||||
thingAttributes.blendframes = Fw::getU8(fin);
|
||||
thingAttributes.xdiv = Fw::getU8(fin);
|
||||
thingAttributes.ydiv = Fw::getU8(fin);
|
||||
thingAttributes.zdiv = Fw::getU8(fin);
|
||||
thingAttributes.animcount = Fw::getU8(fin);
|
||||
|
||||
int totalSprites = thingAttributes.width
|
||||
* thingAttributes.height
|
||||
|
@ -104,15 +104,15 @@ void DatManager::parseThingAttributes(std::stringstream& fin, ThingAttributes& t
|
|||
|
||||
thingAttributes.sprites.resize(totalSprites);
|
||||
for(uint16 i = 0; i < totalSprites; i++)
|
||||
thingAttributes.sprites[i] = fw::getu16(fin);
|
||||
thingAttributes.sprites[i] = Fw::getU16(fin);
|
||||
}
|
||||
|
||||
void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes& thingAttributes, uint8 opt)
|
||||
{
|
||||
switch(opt) {
|
||||
case 0x00: // Ground tile
|
||||
thingAttributes.speed = fw::getu16(fin);
|
||||
thingAttributes.group = THING_GROUP_GROUND;
|
||||
thingAttributes.speed = Fw::getU16(fin);
|
||||
thingAttributes.group = Otc::ThingGroundGroup;
|
||||
break;
|
||||
case 0x01: // All OnTop
|
||||
thingAttributes.alwaysOnTop = true;
|
||||
|
@ -127,7 +127,7 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
thingAttributes.alwaysOnTopOrder = 3;
|
||||
break;
|
||||
case 0x04: // Container
|
||||
thingAttributes.group = THING_GROUP_CONTAINER;
|
||||
thingAttributes.group = Otc::ThingContainerGroup;
|
||||
break;
|
||||
case 0x05: // Stackable
|
||||
thingAttributes.stackable = true;
|
||||
|
@ -138,21 +138,21 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
thingAttributes.useable = true;
|
||||
break;
|
||||
case 0x08: // Writtable
|
||||
thingAttributes.group = THING_GROUP_WRITEABLE;
|
||||
thingAttributes.group = Otc::ThingWriteableGroup;
|
||||
thingAttributes.readable = true;
|
||||
thingAttributes.subParam08 = fw::getu16(fin);
|
||||
thingAttributes.subParam08 = Fw::getU16(fin);
|
||||
break;
|
||||
case 0x09: // Writtable once
|
||||
// Writtable objects that can't be edited by players
|
||||
thingAttributes.readable = true;
|
||||
thingAttributes.subParam08 = fw::getu16(fin);
|
||||
thingAttributes.subParam08 = Fw::getU16(fin);
|
||||
break;
|
||||
case 0x0A: // Fluid containers
|
||||
thingAttributes.group = THING_GROUP_FLUID;
|
||||
fw::getu8(fin);
|
||||
thingAttributes.group = Otc::ThingFluidGroup;
|
||||
Fw::getU8(fin);
|
||||
break;
|
||||
case 0x0B: // Splashes
|
||||
thingAttributes.group = THING_GROUP_SPLASH;
|
||||
thingAttributes.group = Otc::ThingSplashGroup;
|
||||
break;
|
||||
case 0x0C: // Blocks solid objects (creatures, walls etc)
|
||||
thingAttributes.blockSolid = true;
|
||||
|
@ -182,8 +182,8 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
thingAttributes.rotable = true;
|
||||
break;
|
||||
case 0x15: // Light info
|
||||
thingAttributes.lightLevel = fw::getu16(fin);
|
||||
thingAttributes.lightColor = fw::getu16(fin);
|
||||
thingAttributes.lightLevel = Fw::getU16(fin);
|
||||
thingAttributes.lightColor = Fw::getU16(fin);
|
||||
break;
|
||||
case 0x16:
|
||||
break;
|
||||
|
@ -191,13 +191,13 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
break;
|
||||
case 0x18: // Thing must be drawed with offset
|
||||
thingAttributes.hasHeight = true;
|
||||
thingAttributes.drawOffset = fw::getu8(fin);
|
||||
fw::getu8(fin);
|
||||
fw::getu16(fin);
|
||||
thingAttributes.drawOffset = Fw::getU8(fin);
|
||||
Fw::getU8(fin);
|
||||
Fw::getU16(fin);
|
||||
break;
|
||||
case 0x19: // pixels characters height
|
||||
thingAttributes.drawNextOffset = fw::getu8(fin);
|
||||
fw::getu8(fin);
|
||||
thingAttributes.drawNextOffset = Fw::getU8(fin);
|
||||
Fw::getU8(fin);
|
||||
break;
|
||||
case 0x1A:
|
||||
//thingAttributes.hasHeight = true;
|
||||
|
@ -205,11 +205,11 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
case 0x1B:
|
||||
break;
|
||||
case 0x1C: // Minimap color
|
||||
thingAttributes.miniMapColor = fw::getu16(fin);
|
||||
thingAttributes.miniMapColor = Fw::getU16(fin);
|
||||
thingAttributes.hasMiniMapColor = true;
|
||||
break;
|
||||
case 0x1D: // Unknown
|
||||
if(fw::getu16(fin) == 1112)
|
||||
if(Fw::getU16(fin) == 1112)
|
||||
thingAttributes.readable = true;
|
||||
break;
|
||||
case 0x1E:
|
||||
|
@ -220,6 +220,6 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
|
|||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error(fw::mkstr("unknown .dat byte code: 0x", std::hex, (int)opt));
|
||||
throw std::runtime_error(Fw::mkstr("unknown .dat byte code: 0x", std::hex, (int)opt));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define OTCLIENT_CORE_DECLARATIONS_H
|
||||
|
||||
#include <otclient/global.h>
|
||||
#include "const.h"
|
||||
|
||||
class Tile;
|
||||
class Thing;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <framework/platform/platform.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
|
||||
Effect::Effect() : Thing(THING_EFFECT)
|
||||
Effect::Effect() : Thing(Otc::Effect)
|
||||
{
|
||||
m_lastTicks = g_platform.getTicks();
|
||||
m_animation = 0;
|
||||
|
|
|
@ -65,7 +65,7 @@ void Game::onLogout()
|
|||
m_online = false;
|
||||
}
|
||||
|
||||
void Game::walk(Direction direction)
|
||||
void Game::walk(Otc::Direction direction)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
@ -75,37 +75,37 @@ void Game::walk(Direction direction)
|
|||
m_localPlayer->setDirection(direction);
|
||||
|
||||
switch(direction) {
|
||||
case DIRECTION_NORTH:
|
||||
case Otc::North:
|
||||
m_protocolGame->sendWalkNorth();
|
||||
break;
|
||||
case DIRECTION_EAST:
|
||||
case Otc::East:
|
||||
m_protocolGame->sendWalkEast();
|
||||
break;
|
||||
case DIRECTION_SOUTH:
|
||||
case Otc::South:
|
||||
m_protocolGame->sendWalkSouth();
|
||||
break;
|
||||
case DIRECTION_WEST:
|
||||
case Otc::West:
|
||||
m_protocolGame->sendWalkWest();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Game::turn(Direction direction)
|
||||
void Game::turn(Otc::Direction direction)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
switch(direction) {
|
||||
case DIRECTION_NORTH:
|
||||
case Otc::North:
|
||||
m_protocolGame->sendTurnNorth();
|
||||
break;
|
||||
case DIRECTION_EAST:
|
||||
case Otc::East:
|
||||
m_protocolGame->sendTurnEast();
|
||||
break;
|
||||
case DIRECTION_SOUTH:
|
||||
case Otc::South:
|
||||
m_protocolGame->sendTurnSouth();
|
||||
break;
|
||||
case DIRECTION_WEST:
|
||||
case Otc::West:
|
||||
m_protocolGame->sendTurnWest();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
void onLogin();
|
||||
void onLogout();
|
||||
|
||||
void walk(Direction direction);
|
||||
void turn(Direction direction);
|
||||
void walk(Otc::Direction direction);
|
||||
void turn(Otc::Direction direction);
|
||||
|
||||
bool isOnline() { return m_online; }
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "thing.h"
|
||||
#include <framework/platform/platform.h>
|
||||
|
||||
Item::Item() : Thing(THING_ITEM)
|
||||
Item::Item() : Thing(Otc::Item)
|
||||
{
|
||||
m_count = 0;
|
||||
m_lastTicks = g_platform.getTicks();
|
||||
|
@ -50,7 +50,7 @@ void Item::draw(int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID) {
|
||||
if(attributes.group == Otc::ThingSplashGroup || attributes.group == Otc::ThingFluidGroup) {
|
||||
//xdiv = m_count % attributes.xdiv;
|
||||
//ydiv = m_count / attributes.ydiv;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void Map::draw(const Rect& rect)
|
|||
if(!m_framebuffer)
|
||||
m_framebuffer = FrameBufferPtr(new FrameBuffer(15*32, 11*32));
|
||||
|
||||
g_graphics.bindColor(Color::white);
|
||||
g_graphics.bindColor(Fw::white);
|
||||
m_framebuffer->bind();
|
||||
|
||||
LocalPlayerPtr player = g_game.getLocalPlayer();
|
||||
|
@ -91,12 +91,12 @@ void Map::draw(const Rect& rect)
|
|||
}
|
||||
|
||||
// debug draws
|
||||
g_graphics.bindColor(Color::red);
|
||||
g_graphics.bindColor(Fw::red);
|
||||
g_graphics.drawBoundingRect(Rect(7*32, 5*32, 32, 32));
|
||||
|
||||
m_framebuffer->unbind();
|
||||
|
||||
g_graphics.bindColor(Color::white);
|
||||
g_graphics.bindColor(Fw::white);
|
||||
m_framebuffer->draw(rect);
|
||||
|
||||
// calculate stretch factor
|
||||
|
|
|
@ -36,8 +36,8 @@ bool SpriteManager::load(const std::string& file)
|
|||
{
|
||||
try {
|
||||
g_resources.loadFile(file, m_fin);
|
||||
m_signature = fw::getu32(m_fin);
|
||||
m_spritesCount = fw::getu16(m_fin);
|
||||
m_signature = Fw::getU32(m_fin);
|
||||
m_spritesCount = Fw::getU16(m_fin);
|
||||
m_sprites.resize(m_spritesCount);
|
||||
return true;
|
||||
} catch(std::exception& e) {
|
||||
|
@ -57,7 +57,7 @@ TexturePtr SpriteManager::loadSpriteTexture(int id)
|
|||
{
|
||||
m_fin.seekg(((id-1) * 4) + 6, std::ios_base::beg);
|
||||
|
||||
uint32 spriteAddress = fw::getu32(m_fin);
|
||||
uint32 spriteAddress = Fw::getU32(m_fin);
|
||||
|
||||
// no sprite? return an empty texture
|
||||
if(spriteAddress == 0)
|
||||
|
@ -67,11 +67,11 @@ TexturePtr SpriteManager::loadSpriteTexture(int id)
|
|||
assert(m_fin.good());
|
||||
|
||||
// skip color key
|
||||
fw::getu8(m_fin);
|
||||
fw::getu8(m_fin);
|
||||
fw::getu8(m_fin);
|
||||
Fw::getU8(m_fin);
|
||||
Fw::getU8(m_fin);
|
||||
Fw::getU8(m_fin);
|
||||
|
||||
uint16 pixelDataSize = fw::getu16(m_fin);
|
||||
uint16 pixelDataSize = Fw::getU16(m_fin);
|
||||
|
||||
uchar pixels[4096];
|
||||
int writePos = 0;
|
||||
|
@ -92,9 +92,9 @@ TexturePtr SpriteManager::loadSpriteTexture(int id)
|
|||
}
|
||||
|
||||
for(int i = 0; i < coloredPixels; i++) {
|
||||
pixels[writePos + 0] = fw::getu8(m_fin);
|
||||
pixels[writePos + 1] = fw::getu8(m_fin);
|
||||
pixels[writePos + 2] = fw::getu8(m_fin);
|
||||
pixels[writePos + 0] = Fw::getU8(m_fin);
|
||||
pixels[writePos + 1] = Fw::getU8(m_fin);
|
||||
pixels[writePos + 2] = Fw::getU8(m_fin);
|
||||
pixels[writePos + 3] = 0xFF;
|
||||
|
||||
writePos += 4;
|
||||
|
@ -115,14 +115,14 @@ TexturePtr SpriteManager::loadSpriteTexture(int id)
|
|||
return TexturePtr(new Texture(32, 32, 4, pixels));
|
||||
}
|
||||
|
||||
TexturePtr SpriteManager::loadSpriteMask(TexturePtr spriteTex, SpriteMask mask)
|
||||
TexturePtr SpriteManager::loadSpriteMask(TexturePtr spriteTex, Otc::SpriteMask mask)
|
||||
{
|
||||
auto pixels = spriteTex->getPixels();
|
||||
|
||||
static RGBA maskColors[4] = { Color::red.rgba(), Color::green.rgba(), Color::blue.rgba(), Color::yellow.rgba() };
|
||||
static RGBA maskColors[4] = { Fw::red.rgba(), Fw::green.rgba(), Fw::blue.rgba(), Fw::yellow.rgba() };
|
||||
RGBA maskColor = maskColors[mask];
|
||||
RGBA whiteColor = Color::white.rgba();
|
||||
RGBA alphaColor = Color::alpha.rgba();
|
||||
RGBA whiteColor = Fw::white.rgba();
|
||||
RGBA alphaColor = Fw::alpha.rgba();
|
||||
|
||||
// convert pixels
|
||||
// masked color -> white color
|
||||
|
@ -138,7 +138,7 @@ TexturePtr SpriteManager::loadSpriteMask(TexturePtr spriteTex, SpriteMask mask)
|
|||
return TexturePtr(new Texture(32, 32, 4, &pixels[0]));
|
||||
}
|
||||
|
||||
TexturePtr SpriteManager::getSpriteTexture(int id, SpriteMask mask)
|
||||
TexturePtr SpriteManager::getSpriteTexture(int id, Otc::SpriteMask mask)
|
||||
{
|
||||
if(id == 0)
|
||||
return g_graphics.getEmptyTexture();
|
||||
|
@ -153,7 +153,7 @@ TexturePtr SpriteManager::getSpriteTexture(int id, SpriteMask mask)
|
|||
//TODO: release unused sprites textures after X seconds
|
||||
// to avoid massive texture allocations
|
||||
|
||||
if(mask != SpriteMaskNone) {
|
||||
if(mask != Otc::SpriteNoMask) {
|
||||
if(!sprite.masks[mask])
|
||||
sprite.masks[mask] = loadSpriteMask(sprite.texture, mask);
|
||||
return sprite.masks[mask];
|
||||
|
|
|
@ -42,11 +42,11 @@ public:
|
|||
uint32 getSignature() { return m_signature; }
|
||||
int getSpritesCount() { return m_spritesCount; }
|
||||
|
||||
TexturePtr getSpriteTexture(int id, SpriteMask mask = SpriteMaskNone);
|
||||
TexturePtr getSpriteTexture(int id, Otc::SpriteMask mask = Otc::SpriteNoMask);
|
||||
|
||||
private:
|
||||
TexturePtr loadSpriteTexture(int id);
|
||||
TexturePtr loadSpriteMask(TexturePtr spriteTex, SpriteMask mask);
|
||||
TexturePtr loadSpriteMask(TexturePtr spriteTex, Otc::SpriteMask mask);
|
||||
|
||||
uint32 m_signature;
|
||||
uint16 m_spritesCount;
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "spritemanager.h"
|
||||
#include <framework/graphics/graphics.h>
|
||||
|
||||
Thing::Thing(ThingType type) : m_id(0), m_type(type)
|
||||
Thing::Thing(Otc::ThingType type) : m_id(0), m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
void Thing::internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int zdiv, int anim, SpriteMask mask)
|
||||
void Thing::internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int zdiv, int anim, Otc::SpriteMask mask)
|
||||
{
|
||||
const ThingAttributes& attributes = getAttributes();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ struct Light
|
|||
class Thing : public LuaObject
|
||||
{
|
||||
public:
|
||||
Thing(ThingType type);
|
||||
Thing(Otc::ThingType type);
|
||||
virtual ~Thing() { }
|
||||
|
||||
virtual void draw(int x, int y) = 0;
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
void setPosition(const Position& position) { m_position = position; }
|
||||
|
||||
uint32 getId() const { return m_id; }
|
||||
ThingType getType() const { return m_type; }
|
||||
Otc::ThingType getType() const { return m_type; }
|
||||
Position getPosition() const { return m_position; }
|
||||
virtual const ThingAttributes& getAttributes() = 0;
|
||||
|
||||
|
@ -57,10 +57,10 @@ public:
|
|||
virtual LocalPlayerPtr asLocalPlayer() { return nullptr; }
|
||||
|
||||
protected:
|
||||
void internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int zdiv, int anim, SpriteMask mask = SpriteMaskNone);
|
||||
void internalDraw(int x, int y, int blendframes, int xdiv, int ydiv, int zdiv, int anim, Otc::SpriteMask mask = Otc::SpriteNoMask);
|
||||
|
||||
uint32 m_id;
|
||||
ThingType m_type;
|
||||
Otc::ThingType m_type;
|
||||
Position m_position;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
struct ThingAttributes
|
||||
{
|
||||
ThingAttributes() {
|
||||
group = THING_GROUP_NONE;
|
||||
group = Otc::ThingNoGroup;
|
||||
blockSolid = false;
|
||||
hasHeight = false;
|
||||
blockPathFind = false;
|
||||
|
@ -69,7 +69,7 @@ struct ThingAttributes
|
|||
uint16 speed, subParam07, subParam08, lightLevel, lightColor, miniMapColor;
|
||||
|
||||
std::vector<int> sprites;
|
||||
ThingAttributesGroup group;
|
||||
Otc::ThingAttributesGroup group;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,14 +99,14 @@ void Tile::addThing(ThingPtr thing, int stackpos)
|
|||
|
||||
const ThingAttributes& thingAttributes = thing->getAttributes();
|
||||
|
||||
if(thing->getPosition() == g_game.getLocalPlayer()->getPosition() + Position(-1, 0, 0) && thingAttributes.group == THING_GROUP_GROUND) {
|
||||
if(thing->getPosition() == g_game.getLocalPlayer()->getPosition() + Position(-1, 0, 0) && thingAttributes.group == Otc::ThingGroundGroup) {
|
||||
logDebug((int)thing->getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(thing->asItem()) {
|
||||
if(thingAttributes.group == THING_GROUP_GROUND)
|
||||
if(thingAttributes.group == Otc::ThingGroundGroup)
|
||||
m_ground = thing;
|
||||
else {
|
||||
if(thingAttributes.alwaysOnTop)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <framework/global.h>
|
||||
|
||||
// widely used headers
|
||||
#include <otclient/util/position.h>
|
||||
#include "const.h"
|
||||
#include "util/position.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,37 +32,4 @@ class ProtocolGame;
|
|||
typedef std::shared_ptr<ProtocolGame> ProtocolGamePtr;
|
||||
typedef std::shared_ptr<ProtocolLogin> ProtocolLoginPtr;
|
||||
|
||||
|
||||
|
||||
#define CIPSOFT_PUBLIC_RSA "1321277432058722840622950990822933849527763264961655079678763618" \
|
||||
"4334395343554449668205332383339435179772895415509701210392836078" \
|
||||
"6959821132214473291575712138800495033169914814069637740318278150" \
|
||||
"2907336840325241747827401343576296990629870233111328210165697754" \
|
||||
"88792221429527047321331896351555606801473202394175817"
|
||||
|
||||
|
||||
#define OTSERV_PUBLIC_RSA "1091201329673994292788609605089955415282375029027981291234687579" \
|
||||
"3726629149257644633073969600111060390723088861007265581882535850" \
|
||||
"3429057592827629436413108566029093628212635953836686562675849720" \
|
||||
"6207862794310902180176810615217550567108238764764442605581471797" \
|
||||
"07119674283982419152118103759076030616683978566631413"
|
||||
|
||||
// TODO: place it somewhere else
|
||||
enum SpeakClasses {
|
||||
SPEAK_SAY = 0x01, //normal talk
|
||||
SPEAK_WHISPER = 0x02, //whispering - #w text
|
||||
SPEAK_YELL = 0x03, //yelling - #y text
|
||||
SPEAK_PRIVATE_PN = 0x04, //Player-to-NPC speaking(NPCs channel)
|
||||
SPEAK_PRIVATE_NP = 0x05, //NPC-to-Player speaking
|
||||
SPEAK_PRIVATE = 0x06, //Players speaking privately to players
|
||||
SPEAK_CHANNEL_Y = 0x07, //Yellow message in chat
|
||||
SPEAK_CHANNEL_W = 0x08, //White message in chat
|
||||
SPEAK_BROADCAST = 0x09, //Broadcast a message - #b
|
||||
SPEAK_CHANNEL_R1 = 0x0A, //Talk red on chat - #c
|
||||
SPEAK_PRIVATE_RED = 0x0B, //Red private - @name@ text
|
||||
SPEAK_CHANNEL_O = 0x0C, //Talk orange on text
|
||||
SPEAK_MONSTER_SAY = 0x0D, //Talk orange
|
||||
SPEAK_MONSTER_YELL = 0x0E //Yell orange
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -598,7 +598,7 @@ void ProtocolGame::parseCreatureShields(InputMessage& msg)
|
|||
void ProtocolGame::parseCreatureTurn(InputMessage& msg)
|
||||
{
|
||||
uint32 id = msg.getU32();
|
||||
Direction direction = (Direction)msg.getU8();
|
||||
Otc::Direction direction = (Otc::Direction)msg.getU8();
|
||||
|
||||
CreaturePtr creature = g_map.getCreatureById(id);
|
||||
if(creature)
|
||||
|
@ -680,27 +680,27 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
|
|||
uint8 type = msg.getU8();
|
||||
|
||||
switch(type) {
|
||||
case SPEAK_SAY:
|
||||
case SPEAK_WHISPER:
|
||||
case SPEAK_YELL:
|
||||
case SPEAK_MONSTER_SAY:
|
||||
case SPEAK_MONSTER_YELL:
|
||||
case SPEAK_PRIVATE_NP:
|
||||
case Otc::SpeakSay:
|
||||
case Otc::SpeakWhisper:
|
||||
case Otc::SpeakYell:
|
||||
case Otc::SpeakMonsterSay:
|
||||
case Otc::SpeakMonsterYell:
|
||||
case Otc::SpeakPrivateNpcToPlayer:
|
||||
parsePosition(msg); // creaturePos
|
||||
break;
|
||||
case SPEAK_CHANNEL_R1:
|
||||
case SPEAK_CHANNEL_O:
|
||||
case SPEAK_CHANNEL_Y:
|
||||
case SPEAK_CHANNEL_W:
|
||||
case Otc::SpeakChannelRed:
|
||||
case Otc::SpeakChannelOrange:
|
||||
case Otc::SpeakChannelYellow:
|
||||
case Otc::SpeakChannelWhite:
|
||||
msg.getU16(); // channelId
|
||||
break;
|
||||
case SPEAK_PRIVATE:
|
||||
case SPEAK_PRIVATE_PN:
|
||||
case SPEAK_BROADCAST:
|
||||
case SPEAK_PRIVATE_RED:
|
||||
case Otc::SpeakPrivate:
|
||||
case Otc::SpeakPrivatePlayerToNpc:
|
||||
case Otc::SpeakBroadcast:
|
||||
case Otc::SpeakPrivateRed:
|
||||
break;
|
||||
default:
|
||||
logDebug("[ProtocolGame::parseCreatureSpeak]: Unknown speak type.", (int)type);
|
||||
logTraceDebug("Unknown speak type.", (int)type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -767,7 +767,7 @@ void ProtocolGame::parseTextMessage(InputMessage& msg)
|
|||
|
||||
void ProtocolGame::parseCancelWalk(InputMessage& msg)
|
||||
{
|
||||
Direction direction = (Direction)msg.getU8();
|
||||
Otc::Direction direction = (Otc::Direction)msg.getU8();
|
||||
g_game.getLocalPlayer()->setDirection(direction);
|
||||
}
|
||||
|
||||
|
@ -921,7 +921,7 @@ void ProtocolGame::setTileDescription(InputMessage& msg, Position position)
|
|||
return;
|
||||
else {
|
||||
if(stackpos >= 10) {
|
||||
logDebug("[ProtocolGame::setTileDescription] Too many things!.");
|
||||
logTraceDebug("Too many things!.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -984,7 +984,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
|||
}
|
||||
|
||||
uint8 healthPercent = msg.getU8();
|
||||
Direction direction = (Direction)msg.getU8();
|
||||
Otc::Direction direction = (Otc::Direction)msg.getU8();
|
||||
Outfit outfit = internalGetOutfit(msg);
|
||||
|
||||
Light light;
|
||||
|
@ -1032,7 +1032,7 @@ ItemPtr ProtocolGame::internalGetItem(InputMessage& msg, uint16 id)
|
|||
item->setId(id);
|
||||
|
||||
const ThingAttributes& itemAttributes = g_dat.getItemAttributes(id);
|
||||
if(itemAttributes.stackable || itemAttributes.group == THING_GROUP_FLUID || itemAttributes.group == THING_GROUP_SPLASH)
|
||||
if(itemAttributes.stackable || itemAttributes.group == Otc::ThingFluidGroup || itemAttributes.group == Otc::ThingSplashGroup)
|
||||
item->setCount(msg.getU8());
|
||||
|
||||
return item;
|
||||
|
|
|
@ -52,7 +52,7 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown)
|
|||
oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length()));
|
||||
|
||||
// encrypt with RSA
|
||||
if(!Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, OTSERV_PUBLIC_RSA))
|
||||
if(!Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Otc::OtservPublicRSA))
|
||||
return;
|
||||
|
||||
send(oMsg);
|
||||
|
|
|
@ -106,7 +106,7 @@ void ProtocolLogin::sendLoginPacket()
|
|||
// complete the 128 bytes for rsa encryption with zeros
|
||||
oMsg.addPaddingBytes(128 - (21 + m_accountName.length() + m_accountPassword.length()));
|
||||
|
||||
if(!Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, OTSERV_PUBLIC_RSA))
|
||||
if(!Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Otc::OtservPublicRSA))
|
||||
return;
|
||||
|
||||
send(oMsg);
|
||||
|
@ -140,7 +140,7 @@ void ProtocolLogin::parseCharacterList(InputMessage& inputMessage)
|
|||
std::string world = inputMessage.getString();
|
||||
uint32 ip = inputMessage.getU32();
|
||||
uint16 port = inputMessage.getU16();
|
||||
charList.push_back(CharacterInfo(name, world, fw::ip2str(ip), port));
|
||||
charList.push_back(CharacterInfo(name, world, Fw::ip2str(ip), port));
|
||||
}
|
||||
int premDays = inputMessage.getU16();
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#include <otclient/core/game.h>
|
||||
#include <otclient/core/map.h>
|
||||
|
||||
#define POLL_CYCLE_DELAY 10
|
||||
|
||||
OTClient g_client;
|
||||
|
||||
void OTClient::init(std::vector<std::string> args)
|
||||
|
@ -68,11 +66,11 @@ void OTClient::init(std::vector<std::string> args)
|
|||
// create the client window
|
||||
int minWidth = 550;
|
||||
int minHeight = 450;
|
||||
int windowX = fw::fromstring(g_configs.get("window x"), 0);
|
||||
int windowY = fw::fromstring(g_configs.get("window y"), 0);
|
||||
int windowWidth = fw::fromstring(g_configs.get("window width"), minWidth);
|
||||
int windowHeight = fw::fromstring(g_configs.get("window height"), minHeight);
|
||||
bool maximized = fw::fromstring(g_configs.get("window maximized"), false);
|
||||
int windowX = Fw::fromstring(g_configs.get("window x"), 0);
|
||||
int windowY = Fw::fromstring(g_configs.get("window y"), 0);
|
||||
int windowWidth = Fw::fromstring(g_configs.get("window width"), minWidth);
|
||||
int windowHeight = Fw::fromstring(g_configs.get("window height"), minHeight);
|
||||
bool maximized = Fw::fromstring(g_configs.get("window maximized"), false);
|
||||
g_platform.createWindow(windowX, windowY, windowWidth, windowHeight, minWidth, minHeight, maximized);
|
||||
g_platform.setWindowTitle("OTClient");
|
||||
|
||||
|
@ -128,7 +126,7 @@ void OTClient::run()
|
|||
// calculate fps
|
||||
frameCount++;
|
||||
if(frameTicks - lastFpsTicks >= 1000) {
|
||||
fpsText = fw::mkstr("FPS: ", frameCount);
|
||||
fpsText = Fw::mkstr("FPS: ", frameCount);
|
||||
fpsTextSize = defaultFont->calculateTextRectSize(fpsText);
|
||||
frameCount = 0;
|
||||
lastFpsTicks = frameTicks;
|
||||
|
@ -244,12 +242,12 @@ void OTClient::loadConfigurations()
|
|||
int defHeight = 450;
|
||||
|
||||
// sets default window configuration
|
||||
g_configs.set("window x", fw::tostring((g_platform.getDisplayWidth() - defWidth)/2));
|
||||
g_configs.set("window y", fw::tostring((g_platform.getDisplayHeight() - defHeight)/2));
|
||||
g_configs.set("window width", fw::tostring(defWidth));
|
||||
g_configs.set("window height", fw::tostring(defHeight));
|
||||
g_configs.set("window maximized", fw::tostring(false));
|
||||
g_configs.set("vsync", fw::tostring(true));
|
||||
g_configs.set("window x", Fw::tostring((g_platform.getDisplayWidth() - defWidth)/2));
|
||||
g_configs.set("window y", Fw::tostring((g_platform.getDisplayHeight() - defHeight)/2));
|
||||
g_configs.set("window width", Fw::tostring(defWidth));
|
||||
g_configs.set("window height", Fw::tostring(defHeight));
|
||||
g_configs.set("window maximized", Fw::tostring(false));
|
||||
g_configs.set("vsync", Fw::tostring(true));
|
||||
|
||||
// loads user configuration
|
||||
if(!g_configs.load("config.otml"))
|
||||
|
@ -259,17 +257,17 @@ void OTClient::loadConfigurations()
|
|||
void OTClient::setupConfigurations()
|
||||
{
|
||||
// activate vertical synchronization?
|
||||
bool vsync = fw::fromstring(g_configs.get("vsync"), true);
|
||||
bool vsync = Fw::fromstring(g_configs.get("vsync"), true);
|
||||
g_platform.setVerticalSync(vsync);
|
||||
}
|
||||
|
||||
void OTClient::saveConfigurations()
|
||||
{
|
||||
g_configs.set("window x", fw::tostring(g_platform.getWindowX()));
|
||||
g_configs.set("window y", fw::tostring(g_platform.getWindowY()));
|
||||
g_configs.set("window width", fw::tostring(g_platform.getWindowWidth()));
|
||||
g_configs.set("window height", fw::tostring(g_platform.getWindowHeight()));
|
||||
g_configs.set("window maximized", fw::tostring(g_platform.isWindowMaximized()));
|
||||
g_configs.set("window x", Fw::tostring(g_platform.getWindowX()));
|
||||
g_configs.set("window y", Fw::tostring(g_platform.getWindowY()));
|
||||
g_configs.set("window width", Fw::tostring(g_platform.getWindowWidth()));
|
||||
g_configs.set("window height", Fw::tostring(g_platform.getWindowHeight()));
|
||||
g_configs.set("window maximized", Fw::tostring(g_platform.isWindowMaximized()));
|
||||
|
||||
// saves user configuration
|
||||
if(!g_configs.save())
|
||||
|
@ -297,23 +295,23 @@ void OTClient::onPlatformEvent(const PlatformEvent& event)
|
|||
if(event.type == EventKeyDown) {
|
||||
if(!event.ctrl && !event.alt && !event.shift) {
|
||||
if(event.keycode == KC_UP)
|
||||
g_game.walk(DIRECTION_NORTH);
|
||||
g_game.walk(Otc::North);
|
||||
else if(event.keycode == KC_RIGHT)
|
||||
g_game.walk(DIRECTION_EAST);
|
||||
g_game.walk(Otc::East);
|
||||
else if(event.keycode == KC_DOWN)
|
||||
g_game.walk(DIRECTION_SOUTH);
|
||||
g_game.walk(Otc::South);
|
||||
else if(event.keycode == KC_LEFT)
|
||||
g_game.walk(DIRECTION_WEST);
|
||||
g_game.walk(Otc::West);
|
||||
}
|
||||
else if(event.ctrl && !event.alt && !event.shift) {
|
||||
if(event.keycode == KC_UP)
|
||||
g_game.turn(DIRECTION_NORTH);
|
||||
g_game.turn(Otc::North);
|
||||
else if(event.keycode == KC_RIGHT)
|
||||
g_game.turn(DIRECTION_EAST);
|
||||
g_game.turn(Otc::East);
|
||||
else if(event.keycode == KC_DOWN)
|
||||
g_game.turn(DIRECTION_SOUTH);
|
||||
g_game.turn(Otc::South);
|
||||
else if(event.keycode == KC_LEFT)
|
||||
g_game.turn(DIRECTION_WEST);
|
||||
g_game.turn(Otc::West);
|
||||
else if(event.keycode == KC_APOSTROPHE) {
|
||||
// TODO: move these events to lua
|
||||
UIWidgetPtr console = g_ui.getRootWidget()->getChildById("consolePanel");
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
|
||||
class OTClient : public PlatformListener
|
||||
{
|
||||
enum {
|
||||
POLL_CYCLE_DELAY = 10
|
||||
};
|
||||
|
||||
public:
|
||||
/// Where everything begins...
|
||||
void init(std::vector<std::string> args);
|
||||
|
|
Loading…
Reference in New Issue