forked from NaiJi/project-kyoku
Compare commits
1 Commits
300be0983b
...
master
Author | SHA1 | Date |
---|---|---|
NaiJi ✨ | 5b22f627fa |
40
flake.lock
40
flake.lock
|
@ -1,40 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-utils",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1663491030,
|
||||
"narHash": "sha256-MVsfBhE9US5DvLtBAaTRjwYdv1tLO8xjahM8qLXTgTo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "767542707d394ff15ac1981e903e005ba69528b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
14
flake.nix
14
flake.nix
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
description = "Project Kyoku";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShell = import ./shell.nix { inherit pkgs; };
|
||||
}
|
||||
);
|
||||
}
|
10
shell.nix
10
shell.nix
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
unstable ? import <nixos-unstable> {},
|
||||
}:
|
||||
|
||||
with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [ sfml ];
|
||||
nativeBuildInputs = [ ccls cmake ];
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief Basic logging class
|
||||
*
|
||||
* Defines helper functions for logging facility. Configured in Application::init()
|
||||
*
|
||||
*/
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
enum LogLevel
|
||||
{
|
||||
FATAL,
|
||||
ERROR,
|
||||
WARN,
|
||||
INFO,
|
||||
DEBUG,
|
||||
};
|
||||
|
||||
LogLevel level = WARN; ///< Default logging level
|
||||
|
||||
/**
|
||||
* @brief Prints message to stdout
|
||||
*
|
||||
* TODO: write to configurable stream, be it stdout, stderr or even a file
|
||||
*
|
||||
* @param level the message level
|
||||
* @param fmt the message format
|
||||
* @param ... variable parameters
|
||||
*/
|
||||
void log(LogLevel level, const std::string &fmt, ...);
|
||||
|
||||
private:
|
||||
inline std::string _getLabel(LogLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case DEBUG: return "DEBUG";
|
||||
case INFO: return "INFO ";
|
||||
case WARN: return "WARN ";
|
||||
case ERROR: return "ERROR";
|
||||
case FATAL: return "FATAL";
|
||||
default: return "UNK ";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
extern Log LOG; /// Global variable :(
|
||||
|
||||
#define INFO(fmt, ...) LOG.log(Log::INFO, fmt, ##__VA_ARGS__)
|
||||
#define WARN(fmt, ...) LOG.log(Log::WARN, fmt, ##__VA_ARGS__)
|
||||
#define ERROR(fmt, ...) LOG.log(Log::ERROR, fmt, ##__VA_ARGS__)
|
||||
#define FATAL(fmt, ...) LOG.log(Log::FATAL, fmt, ##__VA_ARGS__)
|
||||
#define DEBUG(fmt, ...) LOG.log(Log::DEBUG, fmt, ##__VA_ARGS__)
|
|
@ -1,5 +1,4 @@
|
|||
#include "application/application.h"
|
||||
#include "application/log.h"
|
||||
#include "core/gameevent.h"
|
||||
#include "core/editor.h"
|
||||
|
||||
|
@ -10,13 +9,8 @@
|
|||
|
||||
#include "classicmode/classicfactory.h"
|
||||
|
||||
Log LOG;
|
||||
|
||||
bool Application::init()
|
||||
{
|
||||
LOG.level = Log::DEBUG;
|
||||
DEBUG("Initializing Application");
|
||||
|
||||
if (!_core_factory)
|
||||
return false;
|
||||
|
||||
|
@ -54,8 +48,6 @@ void Application::update(const kku::microsec& dt)
|
|||
|
||||
void Application::pushState(GUIState::Tag new_state)
|
||||
{
|
||||
DEBUG("Pushing state %d", new_state);
|
||||
|
||||
if (!_state_stack.empty())
|
||||
_state_stack.back()->leave();
|
||||
|
||||
|
@ -65,7 +57,6 @@ void Application::pushState(GUIState::Tag new_state)
|
|||
|
||||
void Application::popState()
|
||||
{
|
||||
DEBUG("Popping state");
|
||||
_state_stack.back()->leave();
|
||||
_state_stack.pop_back();
|
||||
_state_stack.back()->enter();
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include <cstdarg>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "application/log.h"
|
||||
|
||||
void Log::log(LogLevel level, const std::string &fmt, ...) {
|
||||
if (level > this->level)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
|
||||
// First va_start: count how many characters are needed for formatting
|
||||
va_start(args, fmt);
|
||||
size_t len = std::vsnprintf(NULL, 0, fmt.c_str(), args);
|
||||
va_end(args);
|
||||
|
||||
std::vector<char> buf(len + 1);
|
||||
|
||||
// Second va_start: actually write formatted message to buffer
|
||||
va_start(args, fmt);
|
||||
std::vsnprintf(&buf[0], len + 1, fmt.c_str(), args);
|
||||
va_end(args);
|
||||
|
||||
std::cout << this->_getLabel(level) << " " << &buf[0] << std::endl;
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
template <class T>
|
||||
class SelectionManager
|
||||
|
|
Loading…
Reference in New Issue