ALL: removed unused code
parent
7b035de1fe
commit
541540eda3
|
@ -9,7 +9,7 @@
|
|||
#include "Shared_generated.h"
|
||||
|
||||
/**
|
||||
* @defgroup Animation
|
||||
* @defgroup Animation Animation
|
||||
* @{
|
||||
* @brief Skeletal animation with lua configuration support.
|
||||
*
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace io {
|
|||
/**
|
||||
* @see SeekableReadStream
|
||||
* @see SeekableWriteStream
|
||||
* @see MemoryReadStream
|
||||
* @ingroup IO
|
||||
*/
|
||||
class BufferedReadWriteStream : public SeekableReadStream, public SeekableWriteStream {
|
||||
private:
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace io {
|
|||
/**
|
||||
* @brief Read from a zip input stream and save in a local buffer
|
||||
*
|
||||
* @ingroup IO
|
||||
* @see ZipReadStream
|
||||
* @see ZipWriteStream
|
||||
* @see MemoryReadStream
|
||||
|
|
|
@ -22,6 +22,7 @@ typedef core::SharedPtr<File> FilePtr;
|
|||
/**
|
||||
* @brief File read and write capable stream
|
||||
*
|
||||
* @ingroup IO
|
||||
* @see SeekableReadStream
|
||||
* @see SeekableWriteStream
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
namespace io {
|
||||
|
||||
/**
|
||||
* @ingroup IO
|
||||
* @see SeekableReadStream
|
||||
* @see BufferedReadWriteStream
|
||||
*/
|
||||
class MemoryReadStream : public SeekableReadStream {
|
||||
protected:
|
||||
|
|
|
@ -11,8 +11,16 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup IO IO
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace io {
|
||||
|
||||
/**
|
||||
* @ingroup IO
|
||||
*/
|
||||
class ReadStream : public core::NonCopyable {
|
||||
public:
|
||||
virtual ~ReadStream() {}
|
||||
|
@ -55,6 +63,7 @@ public:
|
|||
|
||||
/**
|
||||
* @brief ReadStream with the option to jump back and forth in while reading
|
||||
* @ingroup IO
|
||||
*/
|
||||
class SeekableReadStream : public ReadStream {
|
||||
public:
|
||||
|
@ -98,6 +107,9 @@ inline bool SeekableReadStream::empty() const {
|
|||
return size() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup IO
|
||||
*/
|
||||
class WriteStream : public core::NonCopyable {
|
||||
public:
|
||||
virtual ~WriteStream() {}
|
||||
|
@ -137,6 +149,7 @@ public:
|
|||
|
||||
/**
|
||||
* @brief WriteStream with the option to jump back and forth in while writing
|
||||
* @ingroup IO
|
||||
*/
|
||||
class SeekableWriteStream : public WriteStream {
|
||||
public:
|
||||
|
@ -150,3 +163,8 @@ public:
|
|||
};
|
||||
|
||||
} // namespace io
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace io {
|
|||
/**
|
||||
* @see BufferedZipReadStream
|
||||
* @see ZipWriteStream
|
||||
* @ingroup IO
|
||||
*/
|
||||
class ZipReadStream : public io::ReadStream {
|
||||
private:
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace io {
|
|||
* @see BufferedZipReadStream
|
||||
* @see ZipReadStream
|
||||
* @see WriteStream
|
||||
* @ingroup IO
|
||||
*/
|
||||
class ZipWriteStream : public io::WriteStream {
|
||||
private:
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
set(SRCS
|
||||
IProgressMonitor.h
|
||||
EMailValidator.h EMailValidator.cpp
|
||||
BufferUtil.cpp BufferUtil.h
|
||||
Console.h Console.cpp
|
||||
KeybindingParser.h KeybindingParser.cpp
|
||||
KeybindingHandler.h KeybindingHandler.cpp
|
||||
IncludeUtil.h IncludeUtil.cpp
|
||||
MessageQueue.h MessageQueue.cpp
|
||||
VarUtil.h
|
||||
)
|
||||
set(LIB util)
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace util {
|
||||
|
||||
class IProgressMonitor {
|
||||
protected:
|
||||
long _max;
|
||||
long _steps;
|
||||
public:
|
||||
IProgressMonitor(long max = 100l):
|
||||
_max(max), _steps(0l) {
|
||||
}
|
||||
|
||||
virtual ~IProgressMonitor() {
|
||||
}
|
||||
|
||||
void init(long max) {
|
||||
_max = max;
|
||||
}
|
||||
|
||||
virtual void step(long steps = 1l) {
|
||||
_steps += steps;
|
||||
}
|
||||
|
||||
virtual void done() {
|
||||
}
|
||||
|
||||
double progress() const {
|
||||
return _steps * 100.0 / static_cast<double>(_max);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "MessageQueue.h"
|
||||
#include "command/Command.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
const double MessageDelay = 2.0;
|
||||
}
|
||||
|
||||
void MessageQueue::message(const char *msg, ...) {
|
||||
va_list ap;
|
||||
const size_t bufSize = 4096;
|
||||
char buf[bufSize];
|
||||
|
||||
va_start(ap, msg);
|
||||
SDL_vsnprintf(buf, bufSize, msg, ap);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
va_end(ap);
|
||||
|
||||
_messageEventQueue.emplace_back(_timeSeconds + MessageDelay, buf);
|
||||
std::push_heap(_messageEventQueue.begin(), _messageEventQueue.end(), _messageEventQueueComp);
|
||||
}
|
||||
|
||||
void MessageQueue::construct() {
|
||||
command::Command::registerCommand("addmessage", [&] (const command::CmdArgs& args) {
|
||||
if (args.empty()) {
|
||||
return;
|
||||
}
|
||||
message("%s", args.front().c_str());
|
||||
});
|
||||
}
|
||||
|
||||
bool MessageQueue::init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MessageQueue::shutdown() {
|
||||
_messageEventQueue.clear();
|
||||
command::Command::unregisterCommand("addmessage");
|
||||
}
|
||||
|
||||
void MessageQueue::update(double deltaFrameSeconds) {
|
||||
_timeSeconds += deltaFrameSeconds;
|
||||
if (_messageEventQueue.empty()) {
|
||||
return;
|
||||
}
|
||||
// update queue and remove outdated messages
|
||||
for (;;) {
|
||||
const auto& msg = _messageEventQueue.front();
|
||||
const double remainingMillis = msg.ttlSeconds - _timeSeconds;
|
||||
if (remainingMillis > 0.0) {
|
||||
break;
|
||||
}
|
||||
std::pop_heap(_messageEventQueue.begin(), _messageEventQueue.end(), _messageEventQueueComp);
|
||||
_messageEventQueue.pop_back();
|
||||
if (_messageEventQueue.empty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/IComponent.h"
|
||||
#include "core/String.h"
|
||||
#include "core/Common.h"
|
||||
#include "core/StandardLib.h"
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* @brief Class that implements messages with lifetime. The messages are removed once they got old enough.
|
||||
*
|
||||
* This can e.g. be used to display hud messages
|
||||
*/
|
||||
class MessageQueue : public core::IComponent {
|
||||
private:
|
||||
struct MessageEvent {
|
||||
MessageEvent(double _ttlSeconds, const core::String& _msg) :
|
||||
ttlSeconds(_ttlSeconds), msg(_msg) {
|
||||
}
|
||||
double ttlSeconds;
|
||||
core::String msg;
|
||||
};
|
||||
|
||||
struct MessageEventComparator {
|
||||
inline bool operator()(const MessageEvent& x, const MessageEvent& y) const {
|
||||
return x.ttlSeconds > y.ttlSeconds;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<MessageEvent> MessageEventQueue;
|
||||
MessageEventQueue _messageEventQueue;
|
||||
MessageEventComparator _messageEventQueueComp;
|
||||
double _timeSeconds = 0.0;
|
||||
public:
|
||||
/**
|
||||
* @brief Registers a console command to add messages from scripts or console
|
||||
*/
|
||||
void construct() override;
|
||||
/**
|
||||
* @brief Initializes this component
|
||||
* @sa @c shutdown()
|
||||
*/
|
||||
bool init() override;
|
||||
/**
|
||||
* @brief The update method will remove outdated messages.
|
||||
*/
|
||||
void update(double deltaFrameSeconds);
|
||||
/**
|
||||
* @brief Perform a cleanup of the component.
|
||||
* @sa @c init()
|
||||
*/
|
||||
void shutdown() override;
|
||||
|
||||
/**
|
||||
* @brief Adds a message to the message queue
|
||||
*/
|
||||
void message(CORE_FORMAT_STRING const char *msg, ...) CORE_PRINTF_VARARG_FUNC(2);
|
||||
|
||||
/**
|
||||
* @brief Iterates over all active messages and call the given functor with the remaining millis and the string of the message
|
||||
* @note The oldest messages are coming first
|
||||
* @note Call @c update() to get rid of outdated messages
|
||||
*/
|
||||
template<class FUNC>
|
||||
inline void visitMessages(FUNC&& func) const {
|
||||
for (const auto& m : _messageEventQueue) {
|
||||
func(m.ttlSeconds - _timeSeconds, m.msg);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue