Commit bae742c6 authored by Jeb's avatar Jeb

Changed CMake project parameters (included VERSION, DESCRPTION & URL) and...

Changed CMake project parameters (included VERSION, DESCRPTION & URL) and added more functionality to Console-Class
parent 0340677d
......@@ -19,12 +19,11 @@
# todo: c++11 okay this way with variables?
cmake_minimum_required (VERSION 3.3 FATAL_ERROR)
project(modest-engine) # "m"odest-"e"ngine => ME
# The version number
set (ME_VERSION_MAJOR 0)
set (ME_VERSION_MINOR 1)
set (ME_VERSION_PATCH 2)
project(modest-engine
VERSION 0.1.2
DESCRIPTION "CMake root for modest-engine"
HOMEPAGE_URL "https://gitlab.kitware.com/Natschu/modest-engine"
)
# c++11
set(CMAKE_CXX_STANDARD 11)
......
//Console.h
#pragma once
#include <string>
#include "common/Locator.h"
#include "common/typedef.h"
#include "common/console/IConsolePrinter.h"
#include "common/console/NullPrinter.h"
// #include "common/console/NullPrinter.h" // use cmake to automaticly add the right console (maybe all should be included for runTimeSwitches?)
#include "common/console/WinConsolePrinter.h"
#include "../builds/meConfig.h"
class Console {
public:
explicit Console();
......@@ -15,11 +19,18 @@ public:
void startUp();
void shutDown();
void print(const C8* message);
void assignPrinter(IConsolePrinter* printer);
void print(const C8* message, const C8* sender = "");
void print(const std::string message, const std::string sender = "");
void engineStartMessage(int argc, char* argv[]);
void engineEndMessage();
private:
IConsolePrinter* printer;
std::string versionNumber;
const C8* buildSenderMessage(const C8* message, const C8* sender);
std::string buildSenderMessage(const std::string message, const std::string sender);
IConsolePrinter* printer;
};
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "common/typedef.h"
#include <typeinfo>
#include <string>
#define QUOTE(x) #x
......@@ -10,6 +11,7 @@ class IConsolePrinter {
public:
virtual ~IConsolePrinter();
virtual void print(const C8* message) = 0;
virtual void print(const std::string message) = 0;
protected:
explicit IConsolePrinter();
......
......@@ -9,7 +9,8 @@ public:
explicit NullPrinter();
virtual ~NullPrinter();
virtual void print(const C8* message) override;
void print(const C8* message) override;
void print(const std::string message) override;
private:
......
......@@ -12,6 +12,8 @@ public:
virtual ~WinConsolePrinter();
void print(const C8* message) override;
void print(const std::string message) override;
private:
};
\ No newline at end of file
......@@ -7,13 +7,13 @@
* - by using _least for every type we can assure that all types are usable by every OS
* - the first character describe what data it uses (B -> boolean, I -> Integer, U -> Unsigner Integer, F -> Floating-Point, ...)
* - capizalizing the first letter also helps with distinction of the hungarian notation
* - the following number shows the bit-size, this is useful for the object layout in Memory (*lit[0])
* - the following number shows the bit-size, this is useful for the object layout in Memory (lit[0])
*
* Note:
* - For default use take B8, I32, U32, F32
* - Keep in mind that I8 & U8 are converted into char when displaying on the console
*
* *lit[0] -> Game Engineering Architecture by Jason Gregory, Section 3.2.5
* lit[0] -> Game Engineering Architecture by Jason Gregory, Section 3.2.5
*/
// Standard Data types
......@@ -35,4 +35,5 @@ typedef std::uint_least64_t U64; //8Byte [0, 18.446.744.073.709.551.615] (UINT_
typedef float F32; //4Byte | Precision: 6 [-3,4E+38, +3,4E+38]
typedef double F64; //8Byte | Precision: 15 [-1,7E+308, +1,7E+308]
// Differnt Data types
// Different Data types
// ...
\ No newline at end of file
......@@ -14,48 +14,8 @@
#define MS_PER_UPDATE 60
//TODO: add (console) logger (avoiding)
void engineStartMessage(int argc, char* argv[]){
if(argc > 0){
std::cout
<< "[Modest-Engine] "
<< "Version "
<< ME_VERSION_MAJOR << "."
<< ME_VERSION_MINOR << "."
<< ME_VERSION_PATCH
<< std::endl
<< "Path: "
<< argv[0]
<< std::endl;
}
}
namespace test{
template<class T>
//print(Printable)
void print(T sender, std::string message){
std::cout << "[" << typeid(sender).name() << ": " << QUOTE(sender) << "] " << message << std::endl;
// locator.provide(string);
}
}
class one{
public:
void printName(){
test::print(this, "hello");
}
};
int main(int argc, char* argv[]){
engineStartMessage(argc, argv);
Console console;
console.startUp();
// WinConsolePrinter console;
// one hi;
// float lul = 5;
......@@ -63,28 +23,24 @@ int main(int argc, char* argv[]){
// test::print(hi, "hewwo");
// std::cout << "[" << typeid(lul).name() << ": " << QUOTE(lul) << "] " << "meow" << std::endl;
Console* test = Locator::getConsole();
test->print("hello");
// List of the modules
ME::GameWorldModule modGameWorld;
Console console;
// Start up engine in the CORRECT order
// ...
console.startUp();
console.engineStartMessage(argc, argv);
modGameWorld.startUp();
// ...
// Run game
//modGameWorld.run();
// Shut down engine in REVERSE order
modGameWorld.shutDown();
console.shutDown();
// ...
std::cout << std::endl << "[END] Press any key to close program..." << std::endl;
getchar();
return 0;
}
......
//Console.cpp
#include "common/console/Console.h"
Console::Console() {}
Console::Console()
: versionNumber(ME::getVersionNumber())
{}
Console::~Console() {}
void Console::startUp(){
// printer = new NullPrinter(); // use cmake to specify start-console
printer = new WinConsolePrinter();
Locator::provide(this);
versionNumber = ME::getVersionNumber();
}
void Console::shutDown(){
delete printer;
}
void Console::print(const C8* message){
void Console::assignPrinter(IConsolePrinter* printer){
this->printer = printer;
}
void Console::print(const C8* message, const C8* sender){
if(sender[0] != '\0' && sender != nullptr){
printer->print(buildSenderMessage(message, sender));
return;
}
printer->print(message);
}
void Console::assignPrinter(IConsolePrinter* printer){
this->printer = printer;
void Console::print(const std::string message, const std::string sender){
std::string newMessage = message;
if(sender != ""){
newMessage = buildSenderMessage(message, sender);
}
printer->print(newMessage);
}
void Console::engineStartMessage(int argc, char* argv[]){
std::string message = "";
message += "[Modest-Engine] Version " + ME::getVersionNumber() + "\n";
message += "Execution Path: " + std::string(argv[0]) + "\n";
printer->print(message);
}
void Console::engineEndMessage(){
printer->print("[END] Press any key to close program...");
getchar(); // IConsolePrinter Command?
}
const C8* Console::buildSenderMessage(const C8* message, const C8* sender){
return std::string("[" + std::string(sender) + "] " + std::string(message)).c_str();
}
std::string Console::buildSenderMessage(const std::string message, const std::string sender){
return "[" + sender + "] " + message;
}
// std::cout << "[" << typeid(sender) << ": " << QUOTE(sender) << "] " << message << std::endl;
// std::cout<<typeid(A).name()<<"\t"<< quote(A) <<"\n";
\ No newline at end of file
......@@ -5,4 +5,5 @@ NullPrinter::NullPrinter() {}
NullPrinter::~NullPrinter() {}
void NullPrinter::print(const C8* message){}
void NullPrinter::print(const std::string message){}
......@@ -5,9 +5,12 @@ WinConsolePrinter::WinConsolePrinter() {}
WinConsolePrinter::~WinConsolePrinter() {}
void WinConsolePrinter::print(const C8* message){
// std::cout << "[" << typeid(sender) << ": " << QUOTE(sender) << "] " << message << std::endl;
// std::cout<<typeid(A).name()<<"\t"<< quote(A) <<"\n";
void WinConsolePrinter::print(const C8* message){
std::cout << message << std::endl;
}
}
void WinConsolePrinter::print(const std::string message){
std::cout << message << std::endl;
}
\ No newline at end of file
// the configured options and settings for Tutorial
#define ME_VERSION_MAJOR @ME_VERSION_MAJOR@
#define ME_VERSION_MINOR @ME_VERSION_MINOR@
#define ME_VERSION_PATCH @ME_VERSION_PATCH@
\ No newline at end of file
#pragma once
// the configured options and settings for modest-engine
// Bug? cmakedefine doesnt detect CMAKE_PROJECT_VERSION (but does detect the other ones?)
// define does the trick, but it still confuses me
#define ME_VERSION @CMAKE_PROJECT_VERSION@
#define ME_VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@
#define ME_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
#define ME_VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
#include <string>
namespace ME {
static std::string getVersionNumber(){
return std::to_string(ME_VERSION_MAJOR) + "." + std::to_string(ME_VERSION_MINOR) + "." + std::to_string(ME_VERSION_PATCH);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment