This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now it is possible to compile the project under OS X. However, additional work is required. Signed-off-by: Alexander Kurbatov <alkurbatov@virtuozzo.com>
- Loading branch information
Alexander Kurbatov
committed
Jan 12, 2020
1 parent
4455ab6
commit 07b4877
Showing
9 changed files
with
156 additions
and
121 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 @@ | ||
build/ |
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,18 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
project(Observer) | ||
|
||
# Specify output directories. | ||
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin") | ||
|
||
# Build with c++14 support, required by sc2api. | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
# Disable building of examples in the cpp-sc2 submodule. | ||
set(BUILD_API_EXAMPLES OFF CACHE INTERNAL "" FORCE) | ||
|
||
# Disable building of tests in the cpp-sc2 submodule. | ||
set(BUILD_API_TESTS OFF CACHE INTERNAL "" FORCE) | ||
|
||
add_subdirectory("cpp-sc2") | ||
add_subdirectory("src") |
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,41 @@ | ||
add_executable(Observer) | ||
|
||
target_sources(Observer | ||
PRIVATE | ||
CameraModule.h | ||
CameraModule.cpp | ||
Observer.cpp | ||
Timer.hpp | ||
Tools.h | ||
$<$<PLATFORM_ID:Windows>:ToolsWindows.cpp> | ||
$<$<PLATFORM_ID:Darwin>:ToolsUnix.cpp> | ||
) | ||
|
||
include_directories(SYSTEM | ||
${PROJECT_SOURCE_DIR}/cpp-sc2/include | ||
${PROJECT_SOURCE_DIR}/cpp-sc2/contrib/protobuf/src | ||
${PROJECT_BINARY_DIR}/cpp-sc2/generated | ||
"." | ||
) | ||
|
||
if (MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX-") | ||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything \ | ||
-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded \ | ||
-Wno-switch-enum -Wno-weak-vtables -Wno-exit-time-destructors \ | ||
-Wno-float-equal -Wno-global-constructors" | ||
) | ||
endif () | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") | ||
|
||
link_directories(${PROJECT_BINARY_DIR}/cpp-sc2/bin) | ||
|
||
target_link_libraries(Observer | ||
sc2api sc2utils | ||
) | ||
|
||
if (APPLE) | ||
target_link_libraries(Observer "-framework Carbon") | ||
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
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
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
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,9 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
|
||
bool loadReplayPaths(std::string & name, std::vector<std::string> & v); | ||
|
||
void pressDKey(); |
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,11 @@ | ||
#include "Tools.h" | ||
|
||
|
||
bool loadReplayPaths(std::string &, std::vector<std::string> &) | ||
{ | ||
return true; | ||
} | ||
|
||
void pressDKey() | ||
{ | ||
} |
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,60 @@ | ||
#include "Tools.h" | ||
|
||
#include <windows.h> | ||
|
||
|
||
bool loadReplayPaths(std::string & name, std::vector<std::string> & v) | ||
{ | ||
if (name.find("2Replay") != std::string::npos) | ||
{ | ||
v.push_back(name); | ||
return false; | ||
} | ||
|
||
std::string pattern(name); | ||
pattern.append("\\*"); | ||
WIN32_FIND_DATAA data; | ||
HANDLE hFind; | ||
if ((hFind = FindFirstFileA(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE) | ||
{ | ||
do | ||
{ | ||
if (data.dwFileAttributes != 16lu) | ||
{ | ||
const std::string fileName = name + "/" + data.cFileName; | ||
if (std::find(v.begin(), v.end(), fileName) == v.end()) | ||
{ | ||
v.push_back(fileName); | ||
} | ||
} | ||
} | ||
while (FindNextFileA(hFind, &data) != 0); | ||
FindClose(hFind); | ||
} | ||
return true; | ||
} | ||
|
||
void pressDKey() | ||
{ | ||
auto hwnd = FindWindow(NULL, TEXT("StarCraft II")); | ||
if (hwnd != 0) | ||
{ | ||
SetForegroundWindow(hwnd); | ||
SetFocus(hwnd); | ||
SetActiveWindow(hwnd); | ||
INPUT ip; | ||
ip.type = INPUT_KEYBOARD; | ||
ip.ki.wScan = 0; // hardware scan code for key | ||
ip.ki.time = 0; | ||
ip.ki.dwExtraInfo = 0; | ||
|
||
// Press the "D" key | ||
ip.ki.wVk = 0x44; // virtual-key code for the "D" key | ||
ip.ki.dwFlags = 0; // 0 for key press | ||
SendInput(1, &ip, sizeof(INPUT)); | ||
|
||
// Release the "D" key. | ||
ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release | ||
SendInput(1, &ip, sizeof(INPUT)); | ||
} | ||
} |