Browse Source

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
Eduardo Bart 9 years ago
parent
commit
a24212d4de

+ 6
- 1
README.rdoc View File

@@ -29,6 +29,11 @@ http://otclient.info/tracker
29 29
 We encourage you to contribute to OTClient! Please check out
30 30
 {our website}[http://otclient.info/] for guidelines about how to proceed. Join us!
31 31
 
32
+== Contact
33
+
34
+You have 3 options, post at http://otclient.info/ , talk directly with us at #otclient irc.freenode.net or send
35
+an email directly to the project leader edub4rt@gmail.com
36
+
32 37
 == Authors
33 38
 
34 39
 * edubart (project creator and leader developer) <edub4rt@gmail.com>
@@ -37,5 +42,5 @@ We encourage you to contribute to OTClient! Please check out
37 42
 
38 43
 == License
39 44
 
40
-OTClient is made available under the MIT License
45
+OTClient is made available under the MIT License, thus this means that you can do whatever you want, commercial, non-commercial, closed or open.
41 46
 

+ 1
- 1
modules/client/client.otmod View File

@@ -9,7 +9,7 @@ Module
9 9
   load-later:
10 10
     - client_topmenu
11 11
     - client_background
12
-    - client_about
12
+    //- client_about
13 13
     - client_options
14 14
     - client_terminal
15 15
     - client_modulemanager

+ 5
- 0
modules/client_background/background.lua View File

@@ -8,6 +8,11 @@ function Background.init()
8 8
   background = displayUI('background.otui')
9 9
   background:lower()
10 10
 
11
+  local clientVersionLabel = background:getChildById('clientVersionLabel')
12
+  clientVersionLabel:setText('OTClient ' .. g_app.getVersion() .. '\n' ..
13
+                             'Built on ' .. g_app.getBuildDate())
14
+  Effects.fadeIn(clientVersionLabel, 1500)
15
+
11 16
   connect(g_game, { onGameStart = Background.hide })
12 17
   connect(g_game, { onGameEnd = Background.show })
13 18
 end

+ 12
- 1
modules/client_background/background.otui View File

@@ -1,6 +1,6 @@
1 1
 Panel
2 2
   id: background
3
-  image-source: /client_background/background.png
3
+  image-source: /client_background/bg.png
4 4
   image-smooth: true
5 5
   image-fixed-ratio: true
6 6
   anchors.top: topMenu.bottom
@@ -9,3 +9,14 @@ Panel
9 9
   anchors.bottom: parent.bottom
10 10
   margin-top: 1
11 11
   focusable: false
12
+
13
+  UILabel
14
+    background-color: #00000099
15
+    id: clientVersionLabel
16
+    anchors.right: parent.right
17
+    anchors.bottom: parent.bottom
18
+    text-offset: 4 2
19
+    height: 32
20
+    width: 120
21
+    color: #ffffff
22
+    font: verdana-11px-monochrome

BIN
modules/client_background/background.png View File


+ 1
- 0
modules/client_entergame/entergame.lua View File

@@ -80,6 +80,7 @@ function EnterGame.init()
80 80
   enterGame:getChildById('accountNameLineEdit'):focus()
81 81
 
82 82
   -- only open entergame when app starts
83
+  enterGame:hide()
83 84
   if not g_app.isRunning() then
84 85
     if #account > 0 and autologin then
85 86
       addEvent(EnterGame.doLogin)

+ 3
- 3
modules/core_styles/styles/labels.otui View File

@@ -1,13 +1,13 @@
1 1
 Label < UILabel
2 2
   font: verdana-11px-antialised
3
-  color: #aaaaaa
3
+  color: #bbbbbb
4 4
 
5 5
   $disabled:
6
-    color: #aaaaaa88
6
+    color: #bbbbbb88
7 7
 
8 8
 GameLabel < UILabel
9 9
   font: verdana-11px-antialised
10
-  color: #aaaaaa
10
+  color: #bbbbbb
11 11
 
12 12
 FrameCounter < UIFrameCounter
13 13
   size: 68 16

+ 1
- 1
src/framework/application.cpp View File

@@ -67,7 +67,7 @@ Application::~Application()
67 67
 void Application::init(const std::vector<std::string>& args, int appFlags)
68 68
 {
69 69
     m_appFlags = appFlags;
70
-    logInfo("Starting application...");
70
+    logInfo("Starting ", m_appName, " ", m_appVersion);
71 71
 
72 72
     // capture exit signals
73 73
     signal(SIGTERM, exitSignalHandler);

+ 5
- 1
src/framework/application.h View File

@@ -47,7 +47,9 @@ public:
47 47
 
48 48
     bool isRunning() { return m_running; }
49 49
     bool isStopping() { return m_stopping; }
50
-    const std::string& getAppName() { return m_appName; }
50
+    const std::string& getName() { return m_appName; }
51
+    const std::string& getVersion() { return m_appVersion; }
52
+    const std::string& getBuildDate() { return m_appBuildDate; }
51 53
 
52 54
 protected:
53 55
     virtual void render();
@@ -55,6 +57,8 @@ protected:
55 57
     virtual void inputEvent(const InputEvent& event);
56 58
 
57 59
     std::string m_appName;
60
+    std::string m_appVersion;
61
+    std::string m_appBuildDate;
58 62
     int m_appFlags;
59 63
     int m_pollCycleDelay;
60 64
     Boolean<false> m_running;

+ 2
- 2
src/framework/core/modulemanager.cpp View File

@@ -64,7 +64,7 @@ void ModuleManager::discoverModulesPath()
64 64
     std::string possibleModulesDirs[] = { "modules",
65 65
                                           g_resources.getBaseDir() + "modules",
66 66
                                           g_resources.getBaseDir() + "../modules",
67
-                                          g_resources.getBaseDir() + "../share/" + g_app->getAppName() + "/modules",
67
+                                          g_resources.getBaseDir() + "../share/" + g_app->getName() + "/modules",
68 68
                                            "" };
69 69
     bool found = false;
70 70
     for(const std::string& dir : possibleModulesDirs) {
@@ -83,7 +83,7 @@ void ModuleManager::discoverModulesPath()
83 83
     std::string possibleAddonsDirs[] = { "addons",
84 84
                                          g_resources.getBaseDir() + "addons",
85 85
                                          g_resources.getBaseDir() + "../addons",
86
-                                         g_resources.getBaseDir() + "../addons/" + g_app->getAppName() + "/modules",
86
+                                         g_resources.getBaseDir() + "../addons/" + g_app->getName() + "/modules",
87 87
                                          "" };
88 88
     for(const std::string& dir : possibleAddonsDirs) {
89 89
         // try to add module directory

+ 3
- 0
src/framework/luafunctions.cpp View File

@@ -418,6 +418,9 @@ void Application::registerLuaFunctions()
418 418
     g_lua.bindClassStaticFunction("g_app", "exit", std::bind(&Application::exit, g_app));
419 419
     g_lua.bindClassStaticFunction("g_app", "isRunning", std::bind(&Application::isRunning, g_app));
420 420
     g_lua.bindClassStaticFunction("g_app", "isStopping", std::bind(&Application::isStopping, g_app));
421
+    g_lua.bindClassStaticFunction("g_app", "getName", std::bind(&Application::getName, g_app));
422
+    g_lua.bindClassStaticFunction("g_app", "getVersion", std::bind(&Application::getVersion, g_app));
423
+    g_lua.bindClassStaticFunction("g_app", "getBuildDate", std::bind(&Application::getBuildDate, g_app));
421 424
 
422 425
     // ConfigManager
423 426
     g_lua.registerStaticClass("g_configs");

+ 1
- 1
src/framework/platform/unixcrashhandler.cpp View File

@@ -41,7 +41,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
41 41
     char fileName[128];
42 42
     time(&tnow);
43 43
     tm *ts = localtime(&tnow);
44
-    strftime(fileName, 128, (g_app->getAppName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts);
44
+    strftime(fileName, 128, (g_app->getName() + "-crash_-%d-%m-%Y_%H:%M:%S.txt").c_str(), ts);
45 45
 
46 46
     std::stringstream ss;
47 47
     ss.flags(std::ios::hex | std::ios::showbase);

+ 1
- 1
src/framework/platform/win32crashhandler.cpp View File

@@ -46,7 +46,7 @@ LONG WINAPI crashHandler(EXCEPTION_POINTERS* exceptionPointers)
46 46
 
47 47
         SYSTEMTIME systemTime;
48 48
         GetSystemTime(&systemTime);
49
-        snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getAppName().c_str(),
49
+        snprintf(fileName, 128, "%s_%02u-%02u-%04u_%02u-%02u-%02u.mdmp", g_app->getName().c_str(),
50 50
                 systemTime.wDay, systemTime.wMonth, systemTime.wYear,
51 51
                 systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
52 52
 

+ 3
- 3
src/framework/platform/win32window.cpp View File

@@ -226,7 +226,7 @@ void WIN32Window::terminate()
226 226
     }
227 227
 
228 228
     if(m_instance) {
229
-        if(!UnregisterClassA(g_app->getAppName().c_str(), m_instance))
229
+        if(!UnregisterClassA(g_app->getName().c_str(), m_instance))
230 230
             logError("UnregisterClassA failed");
231 231
         m_instance = NULL;
232 232
     }
@@ -252,7 +252,7 @@ void WIN32Window::internalRegisterWindowClass()
252 252
     wc.hCursor          = m_defaultCursor;
253 253
     wc.hbrBackground    = NULL;
254 254
     wc.lpszMenuName     = NULL;
255
-    wc.lpszClassName    = g_app->getAppName().c_str();
255
+    wc.lpszClassName    = g_app->getName().c_str();
256 256
 
257 257
     if(!RegisterClassA(&wc))
258 258
         logFatal("Failed to register the window class.");
@@ -272,7 +272,7 @@ void WIN32Window::internalCreateWindow()
272 272
 
273 273
     updateUnmaximizedCoords();
274 274
     m_window = CreateWindowExA(dwExStyle,
275
-                               g_app->getAppName().c_str(),
275
+                               g_app->getName().c_str(),
276 276
                                NULL,
277 277
                                dwStyle,
278 278
                                windowRect.left,

+ 1
- 1
src/framework/ui/uiframecounter.cpp View File

@@ -41,7 +41,7 @@ void UIFrameCounter::draw()
41 41
     UIWidget::draw();
42 42
 
43 43
     if(g_clock.ticksElapsed(m_lastFrameTicks) >= 1000) {
44
-        m_fpsText = Fw::mkstr("FPS: ", m_frameCount);
44
+        m_fpsText = Fw::formatString("FPS: %d", m_frameCount);
45 45
         m_lastFrameTicks = g_clock.ticks();
46 46
         m_frameCount = 0;
47 47
     }

+ 2
- 1
src/framework/ui/uiwidgettext.cpp View File

@@ -61,9 +61,10 @@ void UIWidget::drawText(const Rect& screenCoords)
61 61
         m_textFramebuffer->bind();
62 62
         Rect virtualTextRect(0, 0, boxSize);
63 63
         virtualTextRect.translate(m_textOffset);
64
+        g_painter.saveAndResetState();
64 65
         g_painter.setCompositionMode(Painter::CompositionMode_DestBlending);
65 66
         m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white);
66
-        g_painter.resetCompositionMode();
67
+        g_painter.restoreSavedState();
67 68
         m_textFramebuffer->release();
68 69
 
69 70
         m_textMustRecache = false;

+ 17
- 0
src/framework/util/tools.h View File

@@ -113,6 +113,23 @@ void println(const T&... args) {
113 113
     std::cout << std::endl;
114 114
 }
115 115
 
116
+// useful std::string version of sprintf :)
117
+template<typename... Args>
118
+std::string formatString(const std::string& format, Args... args) {
119
+    int n, size = 1024;
120
+    std::string str;
121
+    while(true) {
122
+        str.resize(size);
123
+        n = snprintf(&str[0], size, format.c_str(), args...);
124
+        assert(n != -1);
125
+        if(n < size) {
126
+            str.resize(n);
127
+            return str;
128
+        }
129
+        size *= 2;
130
+    }
131
+}
132
+
116 133
 // demangle names for GNU g++ compiler
117 134
 inline std::string demangleName(const char* name) {
118 135
     size_t len;

+ 1
- 0
src/otclient/const.h View File

@@ -30,6 +30,7 @@ namespace Otc
30 30
     constexpr const char* AppName = "OTClient";
31 31
     constexpr const char* AppCompactName = "otclient";
32 32
     constexpr const char* AppVersion = "0.4.0";
33
+    constexpr const char* AppBuild = "_dev";
33 34
 
34 35
     enum {
35 36
         TILE_PIXELS = 32,

+ 3
- 3
src/otclient/otclient.cpp View File

@@ -26,14 +26,14 @@
26 26
 #include <framework/core/resourcemanager.h>
27 27
 #include "core/map.h"
28 28
 
29
-OTClient::OTClient(const std::string& appName) : Application(appName)
29
+OTClient::OTClient() : Application(Otc::AppCompactName)
30 30
 {
31
-
31
+    m_appVersion = Fw::formatString("%s%s", Otc::AppVersion, Otc::AppBuild);
32
+    m_appBuildDate = __DATE__;
32 33
 }
33 34
 
34 35
 void OTClient::init(const std::vector<std::string>& args)
35 36
 {
36
-    logInfo(Otc::AppName, " ", Otc::AppVersion);
37 37
     Application::init(args, Fw::AppEnableAll);
38 38
 
39 39
     g_modules.discoverModules();

+ 1
- 1
src/otclient/otclient.h View File

@@ -29,7 +29,7 @@
29 29
 class OTClient : public Application
30 30
 {
31 31
 public:
32
-    OTClient(const std::string &appName = Otc::AppCompactName);
32
+    OTClient();
33 33
     void init(const std::vector<std::string>& args);
34 34
     void registerLuaFunctions();
35 35
 };

Loading…
Cancel
Save