-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c578fb0
Showing
73 changed files
with
13,054 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CMake build directoris | ||
build | ||
build-* | ||
cmake-build-* | ||
|
||
# CLion | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
project(TBM) | ||
set(EXECUTABLE_NAME Among_Us_Taskbar_Mask) | ||
|
||
# Options | ||
|
||
## Build target | ||
option(TBM_WIN32 "Build for windows" OFF) | ||
option(TBM_X11 "Build for linux (X11)" OFF) | ||
|
||
if (NOT TBM_WIN32 AND NOT TBM_X11) | ||
if (WIN32) | ||
set(TBM_WIN32 ON) | ||
else () | ||
set(TBM_X11 ON) | ||
endif () | ||
endif () | ||
|
||
if (TBM_WIN32) | ||
message(STATUS "Build target: WIN32") | ||
add_definitions("-DTBM_WIN32") | ||
endif () | ||
if (TBM_X11) | ||
message(STATUS "Build target: X11") | ||
add_definitions("-DTBM_X11") | ||
endif () | ||
|
||
# Compiler configuration | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
if (MSVC) | ||
## Use unicode character set | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /UMBCS /D_UNICODE /DUNICODE") | ||
|
||
## Set optimization level | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od") | ||
else () | ||
message(FATAL_ERROR "Unsupported compiler!") | ||
endif () | ||
|
||
# Dependencies | ||
|
||
## Plog | ||
include_directories(lib/plog_v1.1.5/include/) | ||
|
||
## WinSDK | ||
if (TBM_WIN32) | ||
find_library(WINDOWSSDK REQUIRED) | ||
endif () | ||
|
||
## Nowide | ||
if (TBM_WIN32) | ||
include_directories(lib/nowide_standalone_v11.0.0/include/) | ||
set(NOWIDE_SOURCES) | ||
endif () | ||
|
||
# Sources | ||
include_directories(src/) | ||
set(GLOB_RECURSE HEADER_FILES "src/*.h") | ||
set(SOURCE_FILES | ||
"src/tbm/among_us_geometry.cpp" | ||
"src/tbm/among_us_geometry.h" | ||
"src/tbm/app.cpp" | ||
"src/tbm/app.h" | ||
"src/tbm/constants.h" | ||
"src/tbm/log.h" | ||
"src/tbm/main.cpp" | ||
"src/tbm/platform/main_window.h" | ||
"src/tbm/platform/system.h" | ||
"src/tbm/platform/window_painter.h" | ||
"src/tbm/utils/geometry_types.h" | ||
"src/tbm/utils/math_utils.h" | ||
) | ||
|
||
if (TBM_WIN32) | ||
list(APPEND SOURCE_FILES | ||
"src/tbm/platform/win32/hdc_buffer.cpp" | ||
"src/tbm/platform/win32/hdc_buffer.h" | ||
"src/tbm/platform/win32/main_window.cpp" | ||
"src/tbm/platform/win32/main_window_p.h" | ||
"src/tbm/platform/win32/system.cpp" | ||
"src/tbm/platform/win32/win32.cpp" | ||
"src/tbm/platform/win32/win32.h" | ||
"src/tbm/platform/win32/window_painter_hdc.cpp" | ||
"src/tbm/platform/win32/window_painter_hdc.h" | ||
) | ||
endif () | ||
|
||
list(APPEND SOURCE_FILES ${NOWIDE_SOURCES}) | ||
|
||
# Executable | ||
if (TBM_WIN32) | ||
add_executable(${EXECUTABLE_NAME} WIN32 ${SOURCE_FILES} resources/win32rc/resource.rc) | ||
set_property(TARGET ${EXECUTABLE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
else () | ||
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Boost Software License - Version 1.0 - August 17th, 2003 | ||
|
||
Permission is hereby granted, free of charge, to any person or organization | ||
obtaining a copy of the software and accompanying documentation covered by | ||
this license (the "Software") to use, reproduce, display, distribute, | ||
execute, and transmit the Software, and to prepare derivative works of the | ||
Software, and to permit third-parties to whom the Software is furnished to | ||
do so, all subject to the following: | ||
|
||
The copyright notices in the Software and this entire statement, including | ||
the above license grant, this restriction and the following disclaimer, | ||
must be included in all copies of the Software, in whole or in part, and | ||
all derivative works of the Software, unless such copies or derivative | ||
works are solely in the form of machine-executable object code generated by | ||
a source language processor. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
// | ||
// Copyright (c) 2012 Artyom Beilis (Tonkikh) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See | ||
// accompanying file LICENSE or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
#ifndef NOWIDE_ARGS_HPP_INCLUDED | ||
#define NOWIDE_ARGS_HPP_INCLUDED | ||
|
||
#include <nowide/config.hpp> | ||
#ifdef NOWIDE_WINDOWS | ||
#include <nowide/stackstring.hpp> | ||
#include <nowide/windows.hpp> | ||
#include <stdexcept> | ||
#include <vector> | ||
#endif | ||
|
||
namespace nowide { | ||
#if !defined(NOWIDE_WINDOWS) && !defined(NOWIDE_DOXYGEN) | ||
class args | ||
{ | ||
public: | ||
args(int&, char**&) | ||
{} | ||
args(int&, char**&, char**&) | ||
{} | ||
}; | ||
|
||
#else | ||
|
||
/// | ||
/// \brief \c args is a class that temporarily replaces standard main() function arguments with their | ||
/// equal, but UTF-8 encoded values under Microsoft Windows for the lifetime of the instance. | ||
/// | ||
/// The class uses \c GetCommandLineW(), \c CommandLineToArgvW() and \c GetEnvironmentStringsW() | ||
/// in order to obtain Unicode-encoded values. | ||
/// It does not relate to actual values of argc, argv and env under Windows. | ||
/// | ||
/// It restores the original values in its destructor (usually at the end of the \c main function). | ||
/// | ||
/// If any of the system calls fails, an exception of type std::runtime_error will be thrown | ||
/// and argc, argv, env remain unchanged. | ||
/// | ||
/// \note The class owns the memory of the newly allocated strings. | ||
/// So you need to keep it alive as long as you use the values. | ||
/// | ||
/// Usage: | ||
/// \code | ||
/// int main(int argc, char** argv, char** env) { | ||
/// nowide::args _(argc, argv, env); // Note the _ as a "don't care" name for the instance | ||
/// // Use argv and env as usual, they are now UTF-8 encoded on Windows | ||
/// return 0; // Memory held by args is released | ||
/// } | ||
/// \endcode | ||
class args | ||
{ | ||
public: | ||
/// | ||
/// Fix command line arguments | ||
/// | ||
args(int& argc, char**& argv) : | ||
old_argc_(argc), old_argv_(argv), old_env_(0), old_argc_ptr_(&argc), old_argv_ptr_(&argv), old_env_ptr_(0) | ||
{ | ||
fix_args(argc, argv); | ||
} | ||
/// | ||
/// Fix command line arguments and environment | ||
/// | ||
args(int& argc, char**& argv, char**& env) : | ||
old_argc_(argc), old_argv_(argv), old_env_(env), old_argc_ptr_(&argc), old_argv_ptr_(&argv), | ||
old_env_ptr_(&env) | ||
{ | ||
fix_args(argc, argv); | ||
fix_env(env); | ||
} | ||
/// | ||
/// Restore original argc, argv, env values, if changed | ||
/// | ||
~args() | ||
{ | ||
if(old_argc_ptr_) | ||
*old_argc_ptr_ = old_argc_; | ||
if(old_argv_ptr_) | ||
*old_argv_ptr_ = old_argv_; | ||
if(old_env_ptr_) | ||
*old_env_ptr_ = old_env_; | ||
} | ||
|
||
private: | ||
class wargv_ptr | ||
{ | ||
wchar_t** p; | ||
int argc; | ||
|
||
public: | ||
wargv_ptr() | ||
{ | ||
p = CommandLineToArgvW(GetCommandLineW(), &argc); | ||
} | ||
~wargv_ptr() | ||
{ | ||
if(p) | ||
LocalFree(p); | ||
} | ||
wargv_ptr(const wargv_ptr&) = delete; | ||
wargv_ptr& operator=(const wargv_ptr&) = delete; | ||
|
||
int size() const | ||
{ | ||
return argc; | ||
} | ||
operator bool() const | ||
{ | ||
return p != NULL; | ||
} | ||
const wchar_t* operator[](size_t i) const | ||
{ | ||
return p[i]; | ||
} | ||
}; | ||
class wenv_ptr | ||
{ | ||
wchar_t* p; | ||
|
||
public: | ||
wenv_ptr() : p(GetEnvironmentStringsW()) | ||
{} | ||
~wenv_ptr() | ||
{ | ||
if(p) | ||
FreeEnvironmentStringsW(p); | ||
} | ||
wenv_ptr(const wenv_ptr&) = delete; | ||
wenv_ptr& operator=(const wenv_ptr&) = delete; | ||
|
||
operator const wchar_t*() const | ||
{ | ||
return p; | ||
} | ||
}; | ||
|
||
void fix_args(int& argc, char**& argv) | ||
{ | ||
const wargv_ptr wargv; | ||
if(!wargv) | ||
throw std::runtime_error("Could not get command line!"); | ||
args_.resize(wargv.size() + 1, 0); | ||
arg_values_.resize(wargv.size()); | ||
for(int i = 0; i < wargv.size(); i++) | ||
args_[i] = arg_values_[i].convert(wargv[i]); | ||
argc = wargv.size(); | ||
argv = &args_[0]; | ||
} | ||
void fix_env(char**& env) | ||
{ | ||
const wenv_ptr wstrings; | ||
if(!wstrings) | ||
throw std::runtime_error("Could not get environment strings!"); | ||
const wchar_t* wstrings_end = 0; | ||
int count = 0; | ||
for(wstrings_end = wstrings; *wstrings_end; wstrings_end += wcslen(wstrings_end) + 1) | ||
count++; | ||
env_.convert(wstrings, wstrings_end); | ||
envp_.resize(count + 1, 0); | ||
char* p = env_.get(); | ||
int pos = 0; | ||
for(int i = 0; i < count; i++) | ||
{ | ||
if(*p != '=') | ||
envp_[pos++] = p; | ||
p += strlen(p) + 1; | ||
} | ||
env = &envp_[0]; | ||
} | ||
|
||
std::vector<char*> args_; | ||
std::vector<short_stackstring> arg_values_; | ||
stackstring env_; | ||
std::vector<char*> envp_; | ||
|
||
int old_argc_; | ||
char** old_argv_; | ||
char** old_env_; | ||
|
||
int* old_argc_ptr_; | ||
char*** old_argv_ptr_; | ||
char*** old_env_ptr_; | ||
}; | ||
|
||
#endif | ||
|
||
} // namespace nowide | ||
#endif |
Oops, something went wrong.