summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-27 14:52:10 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-27 14:52:10 +0300
commit45949cf0fbade4f211520926c5e839c68cd01fbb (patch)
treedf264bef9f6876c65d3e1905e374b15739c8f655 /src
parentd003da4b7bbf1b37f95c2e8e761fbe3e54b25c7a (diff)
downloadmanaverse-45949cf0fbade4f211520926c5e839c68cd01fbb.tar.gz
manaverse-45949cf0fbade4f211520926c5e839c68cd01fbb.tar.bz2
manaverse-45949cf0fbade4f211520926c5e839c68cd01fbb.tar.xz
manaverse-45949cf0fbade4f211520926c5e839c68cd01fbb.zip
Move chat command /testsdlfont into actions.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp44
-rw-r--r--src/actions/actions.h5
-rw-r--r--src/commands.cpp44
-rw-r--r--src/commands.h5
-rw-r--r--src/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h19
-rw-r--r--src/input/pages/other.cpp8
7 files changed, 77 insertions, 49 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 22dd4834b..9198b474b 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -993,4 +993,48 @@ impHandler(dumpMods)
return true;
}
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+impHandler0(testSdlFont)
+{
+ Font *font = new Font("fonts/dejavusans.ttf", 18);
+ timespec time1;
+ timespec time2;
+ NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
+ std::vector<std::string> data;
+ volatile int width = 0;
+
+ for (int f = 0; f < 300; f ++)
+ data.push_back("test " + toString(f) + "string");
+ nullGraphics->beginDraw();
+
+ clock_gettime(CLOCK_MONOTONIC, &time1);
+ for (int f = 0; f < 500; f ++)
+ {
+ FOR_EACH (std::vector<std::string>::const_iterator, it, data)
+ {
+ width += font->getWidth(*it);
+ font->drawString(nullGraphics, *it, 10, 10);
+ }
+ FOR_EACH (std::vector<std::string>::const_iterator, it, data)
+ font->drawString(nullGraphics, *it, 10, 10);
+
+ font->doClean();
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &time2);
+
+ delete nullGraphics;
+ delete font;
+
+ int64_t diff = (static_cast<long long int>(
+ time2.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time2.tv_nsec)) / 100000 - (static_cast<long long int>(
+ time1.tv_sec) * 1000000000LL + static_cast<long long int>(
+ time1.tv_nsec)) / 100000;
+ if (debugChatTab)
+ debugChatTab->chatLog("sdlfont time: " + toString(diff));
+ return true;
+}
+#endif
+
} // namespace Actions
diff --git a/src/actions/actions.h b/src/actions/actions.h
index 7a8217570..f3c58da54 100644
--- a/src/actions/actions.h
+++ b/src/actions/actions.h
@@ -21,6 +21,8 @@
#ifndef ACTIONS_ACTIONS_H
#define ACTIONS_ACTIONS_H
+#include "localconsts.h"
+
#define decHandler(name) bool name(InputEvent &event)
struct InputEvent;
@@ -78,6 +80,9 @@ namespace Actions
decHandler(dumpOGL);
decHandler(dumpGL);
decHandler(dumpMods);
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+ decHandler(testSdlFont);
+#endif
} // namespace Actions
#undef decHandler
diff --git a/src/commands.cpp b/src/commands.cpp
index 18747f24e..1f474bd3f 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -328,50 +328,6 @@ impHandler(uploadLog)
return true;
}
-impHandler0(testsdlfont)
-{
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
- Font *font = new Font("fonts/dejavusans.ttf", 18);
- timespec time1;
- timespec time2;
- NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
- std::vector<std::string> data;
- volatile int width = 0;
-
- for (int f = 0; f < 300; f ++)
- data.push_back("test " + toString(f) + "string");
- nullGraphics->beginDraw();
-
- clock_gettime(CLOCK_MONOTONIC, &time1);
- for (int f = 0; f < 500; f ++)
- {
- FOR_EACH (std::vector<std::string>::const_iterator, it, data)
- {
- width += font->getWidth(*it);
- font->drawString(nullGraphics, *it, 10, 10);
- }
- FOR_EACH (std::vector<std::string>::const_iterator, it, data)
- font->drawString(nullGraphics, *it, 10, 10);
-
- font->doClean();
- }
-
- clock_gettime(CLOCK_MONOTONIC, &time2);
-
- delete nullGraphics;
- delete font;
-
- int64_t diff = (static_cast<long long int>(
- time2.tv_sec) * 1000000000LL + static_cast<long long int>(
- time2.tv_nsec)) / 100000 - (static_cast<long long int>(
- time1.tv_sec) * 1000000000LL + static_cast<long long int>(
- time1.tv_nsec)) / 100000;
- if (debugChatTab)
- debugChatTab->chatLog("sdlfont time: " + toString(diff));
-#endif
- return true;
-}
-
impHandler0(debugSpawn)
{
int cnt = atoi(event.args.c_str());
diff --git a/src/commands.h b/src/commands.h
index 44afba028..3875d4523 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -52,7 +52,6 @@ struct CommandInfo final
namespace Commands
{
decHandler(hack);
- decHandler(testsdlfont);
decHandler(enableHighlight);
decHandler(disableHighlight);
decHandler(dontRemoveName);
@@ -74,8 +73,7 @@ namespace Commands
enum
{
- COMMAND_TESTSDLFONT = 0,
- COMMAND_ENABLEHIGHLIGHT,
+ COMMAND_ENABLEHIGHLIGHT = 0,
COMMAND_DISABLEHIGHLIGHT,
COMMAND_DONTREMOVENAME,
COMMAND_REMOVENAME,
@@ -96,7 +94,6 @@ enum
static const CommandInfo commands[] =
{
- {"testsdlfont", &Commands::testsdlfont, -1, false},
{"enablehighlight", &Commands::enableHighlight, -1, false},
{"disablehighlight", &Commands::disableHighlight, -1, false},
{"", &Commands::dontRemoveName, -1, false},
diff --git a/src/input/inputaction.h b/src/input/inputaction.h
index c0c91d7f8..48508b0fb 100644
--- a/src/input/inputaction.h
+++ b/src/input/inputaction.h
@@ -407,6 +407,7 @@ namespace InputAction
URL,
OPEN_URL,
EXECUTE,
+ TEST_SDL_FONT,
TOTAL
};
} // namespace InputAction
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 0e16c866c..e2d123b73 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -3432,7 +3432,24 @@ static const InputActionData inputActionData[InputAction::TOTAL] = {
InputAction::NO_VALUE, 50,
InputCondition::INGAME,
"execute",
- true}
+ true},
+ {"keyTestSdlFont",
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ InputType::UNKNOWN, InputAction::NO_VALUE,
+ Input::GRP_DEFAULT,
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+ &Actions::testSdlFont,
+#else
+ nullptr,
+#endif
+ InputAction::NO_VALUE, 50,
+ InputCondition::INGAME,
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+ "testsdlfont",
+#else
+ "",
+#endif
+ false}
};
#endif // INPUT_INPUTACTIONMAP_H
diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp
index 06ce2c348..61c6a5a9f 100644
--- a/src/input/pages/other.cpp
+++ b/src/input/pages/other.cpp
@@ -327,6 +327,14 @@ SetupActionData setupActionDataOther[] =
InputAction::DUMP_OGL,
"",
},
+#if defined USE_OPENGL && defined DEBUG_SDLFONT
+ {
+ // TRANSLATORS: input action name
+ N_("Test SDL font speed"),
+ InputAction::TEST_SDL_FONT,
+ "",
+ },
+#endif
{
"",
InputAction::NO_VALUE,