mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
back to otclient dev, with new background!
* show otclient version in background * disable about module (don't really need it) * new function for formating strings like sprintf, Fw::formatString * new nice background (taken from RPG maker XV) * update contact information in README * fix text rendering issues with opacity
This commit is contained in:
@@ -67,7 +67,7 @@ Application::~Application()
|
||||
void Application::init(const std::vector<std::string>& args, int appFlags)
|
||||
{
|
||||
m_appFlags = appFlags;
|
||||
logInfo("Starting application...");
|
||||
logInfo("Starting ", m_appName, " ", m_appVersion);
|
||||
|
||||
// capture exit signals
|
||||
signal(SIGTERM, exitSignalHandler);
|
||||
|
@@ -47,7 +47,9 @@ public:
|
||||
|
||||
bool isRunning() { return m_running; }
|
||||
bool isStopping() { return m_stopping; }
|
||||
const std::string& getAppName() { return m_appName; }
|
||||
const std::string& getName() { return m_appName; }
|
||||
const std::string& getVersion() { return m_appVersion; }
|
||||
const std::string& getBuildDate() { return m_appBuildDate; }
|
||||
|
||||
protected:
|
||||
virtual void render();
|
||||
@@ -55,6 +57,8 @@ protected:
|
||||
virtual void inputEvent(const InputEvent& event);
|
||||
|
||||
std::string m_appName;
|
||||
std::string m_appVersion;
|
||||
std::string m_appBuildDate;
|
||||
int m_appFlags;
|
||||
int m_pollCycleDelay;
|
||||
Boolean<false> m_running;
|
||||
|
@@ -64,7 +64,7 @@ void ModuleManager::discoverModulesPath()
|
||||
std::string possibleModulesDirs[] = { "modules",
|
||||
g_resources.getBaseDir() + "modules",
|
||||
g_resources.getBaseDir() + "../modules",
|
||||
g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules",
|
||||
g_resources.getBaseDir() + "../share/" + g_app->getName() + "/modules",
|
||||
"" };
|
||||
bool found = false;
|
||||
for(const std::string& dir : possibleModulesDirs) {
|
||||
@@ -83,7 +83,7 @@ void ModuleManager::discoverModulesPath()
|
||||
std::string possibleAddonsDirs[] = { "addons",
|
||||
g_resources.getBaseDir() + "addons",
|
||||
g_resources.getBaseDir() + "../addons",
|
||||
g_resources.getBaseDir() + "../addons/" + g_app->getAppName() + "/modules",
|
||||
g_resources.getBaseDir() + "../addons/" + g_app->getName() + "/modules",
|
||||
"" };
|
||||
for(const std::string& dir : possibleAddonsDirs) {
|
||||
// try to add module directory
|
||||
|
@@ -418,6 +418,9 @@ void Application::registerLuaFunctions()
|
||||
g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app));
|
||||
g_lua.bindClassStaticFunction("g_app", "isRunning", std::bind(&Application::isRunning, g_app));
|
||||
g_lua.bindClassStaticFunction("g_app", "isStopping", std::bind(&Application::isStopping, g_app));
|
||||
g_lua.bindClassStaticFunction("g_app", "getName", std::bind(&Application::getName, g_app));
|
||||
g_lua.bindClassStaticFunction("g_app", "getVersion", std::bind(&Application::getVersion, g_app));
|
||||
g_lua.bindClassStaticFunction("g_app", "getBuildDate", std::bind(&Application::getBuildDate, g_app));
|
||||
|
||||
// ConfigManager
|
||||
g_lua.registerStaticClass("g_configs");
|
||||
|
@@ -41,7 +41,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||
char fileName[128];
|
||||
time(&tnow);
|
||||
tm *ts = localtime(&tnow);
|
||||
strftime(fileName, 128, (g_app->getAppName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts);
|
||||
strftime(fileName, 128, (g_app->getName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts);
|
||||
|
||||
std::stringstream ss;
|
||||
ss.flags(std::ios::hex | std::ios::showbase);
|
||||
|
@@ -46,7 +46,7 @@ LONG WINAPI crashHandler(EXCEPTION_POINTERS* exceptionPointers)
|
||||
|
||||
SYSTEMTIME systemTime;
|
||||
GetSystemTime(&systemTime);
|
||||
snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getAppName().c_str(),
|
||||
snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getName().c_str(),
|
||||
systemTime.wDay, systemTime.wMonth, systemTime.wYear,
|
||||
systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
|
||||
|
||||
|
@@ -226,7 +226,7 @@ void WIN32Window::terminate()
|
||||
}
|
||||
|
||||
if(m_instance) {
|
||||
if(!UnregisterClassA(g_app->getAppName().c_str(), m_instance))
|
||||
if(!UnregisterClassA(g_app->getName().c_str(), m_instance))
|
||||
logError("UnregisterClassA failed");
|
||||
m_instance = NULL;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void WIN32Window::internalRegisterWindowClass()
|
||||
wc.hCursor = m_defaultCursor;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = g_app->getAppName().c_str();
|
||||
wc.lpszClassName = g_app->getName().c_str();
|
||||
|
||||
if(!RegisterClassA(&wc))
|
||||
logFatal("Failed to register the window class.");
|
||||
@@ -272,7 +272,7 @@ void WIN32Window::internalCreateWindow()
|
||||
|
||||
updateUnmaximizedCoords();
|
||||
m_window = CreateWindowExA(dwExStyle,
|
||||
g_app->getAppName().c_str(),
|
||||
g_app->getName().c_str(),
|
||||
NULL,
|
||||
dwStyle,
|
||||
windowRect.left,
|
||||
|
@@ -41,7 +41,7 @@ void UIFrameCounter::draw()
|
||||
UIWidget::draw();
|
||||
|
||||
if(g_clock.ticksElapsed(m_lastFrameTicks) >= 1000) {
|
||||
m_fpsText = Fw::mkstr("FPS: ", m_frameCount);
|
||||
m_fpsText = Fw::formatString("FPS: %d", m_frameCount);
|
||||
m_lastFrameTicks = g_clock.ticks();
|
||||
m_frameCount = 0;
|
||||
}
|
||||
|
@@ -61,9 +61,10 @@ void UIWidget::drawText(const Rect& screenCoords)
|
||||
m_textFramebuffer->bind();
|
||||
Rect virtualTextRect(0, 0, boxSize);
|
||||
virtualTextRect.translate(m_textOffset);
|
||||
g_painter.saveAndResetState();
|
||||
g_painter.setCompositionMode(Painter::CompositionMode_DestBlending);
|
||||
m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white);
|
||||
g_painter.resetCompositionMode();
|
||||
g_painter.restoreSavedState();
|
||||
m_textFramebuffer->release();
|
||||
|
||||
m_textMustRecache = false;
|
||||
|
@@ -113,6 +113,23 @@ void println(const T&... args) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
// useful std::string version of sprintf :)
|
||||
template<typename... Args>
|
||||
std::string formatString(const std::string& format, Args... args) {
|
||||
int n, size = 1024;
|
||||
std::string str;
|
||||
while(true) {
|
||||
str.resize(size);
|
||||
n = snprintf(&str[0], size, format.c_str(), args...);
|
||||
assert(n != -1);
|
||||
if(n < size) {
|
||||
str.resize(n);
|
||||
return str;
|
||||
}
|
||||
size *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
// demangle names for GNU g++ compiler
|
||||
inline std::string demangleName(const char* name) {
|
||||
size_t len;
|
||||
|
@@ -30,6 +30,7 @@ namespace Otc
|
||||
constexpr const char* AppName = "OTClient";
|
||||
constexpr const char* AppCompactName = "otclient";
|
||||
constexpr const char* AppVersion = "0.4.0";
|
||||
constexpr const char* AppBuild = "_dev";
|
||||
|
||||
enum {
|
||||
TILE_PIXELS = 32,
|
||||
|
@@ -26,14 +26,14 @@
|
||||
#include <framework/core/resourcemanager.h>
|
||||
#include "core/map.h"
|
||||
|
||||
OTClient::OTClient(const std::string& appName) : Application(appName)
|
||||
OTClient::OTClient() : Application(Otc::AppCompactName)
|
||||
{
|
||||
|
||||
m_appVersion = Fw::formatString("%s%s", Otc::AppVersion, Otc::AppBuild);
|
||||
m_appBuildDate = __DATE__;
|
||||
}
|
||||
|
||||
void OTClient::init(const std::vector<std::string>& args)
|
||||
{
|
||||
logInfo(Otc::AppName, " ", Otc::AppVersion);
|
||||
Application::init(args, Fw::AppEnableAll);
|
||||
|
||||
g_modules.discoverModules();
|
||||
|
@@ -29,7 +29,7 @@
|
||||
class OTClient : public Application
|
||||
{
|
||||
public:
|
||||
OTClient(const std::string &appName = Otc::AppCompactName);
|
||||
OTClient();
|
||||
void init(const std::vector<std::string>& args);
|
||||
void registerLuaFunctions();
|
||||
};
|
||||
|
Reference in New Issue
Block a user