-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
98a047f
commit 578a7d1
Showing
8 changed files
with
184 additions
and
3 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
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,23 @@ | ||
#pragma once | ||
|
||
/* | ||
* This is a header designed to be included in C++ source code. | ||
* It should not be included in applications using any C wrapper libraries! | ||
*/ | ||
#ifndef __cplusplus | ||
#error "This header can only be used in C++!" | ||
#endif | ||
|
||
#include "gamepp.h" | ||
|
||
namespace gamepp { | ||
|
||
class GameInstance; | ||
|
||
} // namespace gamepp | ||
|
||
namespace Convert { | ||
|
||
gamepp::GameInstance* gameInstance(gamepp_game_instance_handle_t handle); | ||
|
||
} // namespace Convert |
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,45 @@ | ||
#pragma once | ||
|
||
#include <sourceppc/Buffer.h> | ||
#include <sourceppc/String.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef void* gamepp_game_instance_handle_t; | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
// REQUIRES MANUAL FREE: gamepp_game_instance_free | ||
SOURCEPP_API gamepp_game_instance_handle_t gamepp_find_game_instance(); | ||
|
||
// REQUIRES MANUAL FREE: gamepp_game_instance_free | ||
SOURCEPP_API gamepp_game_instance_handle_t gamepp_find_game_instance_with_name(const char* windowNameOverride); | ||
|
||
SOURCEPP_API void gamepp_game_instance_free(gamepp_game_instance_handle_t* handle); | ||
|
||
// REQUIRES MANUAL FREE: sourcepp_string_free | ||
SOURCEPP_API sourcepp_string_t gamepp_get_window_title(gamepp_game_instance_handle_t handle); | ||
|
||
SOURCEPP_API int gamepp_get_window_pos_x(gamepp_game_instance_handle_t handle); | ||
|
||
SOURCEPP_API int gamepp_get_window_pos_y(gamepp_game_instance_handle_t handle); | ||
|
||
SOURCEPP_API int gamepp_get_window_width(gamepp_game_instance_handle_t handle); | ||
|
||
SOURCEPP_API int gamepp_get_window_height(gamepp_game_instance_handle_t handle); | ||
|
||
SOURCEPP_API void gamepp_command(gamepp_game_instance_handle_t handle, const char* command); | ||
|
||
SOURCEPP_API void gamepp_input_begin(gamepp_game_instance_handle_t handle, const char* input); | ||
|
||
SOURCEPP_API void gamepp_input_end(gamepp_game_instance_handle_t handle, const char* input); | ||
|
||
SOURCEPP_API void gamepp_input_once(gamepp_game_instance_handle_t handle, const char* input); | ||
|
||
SOURCEPP_API void gamepp_input_hold(gamepp_game_instance_handle_t handle, const char* input, double sec); | ||
|
||
SOURCEPP_API void gamepp_wait(gamepp_game_instance_handle_t handle, double sec); |
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 @@ | ||
#include <gameppc/Convert.hpp> | ||
|
||
#include <gamepp/gamepp.h> | ||
|
||
using namespace gamepp; | ||
|
||
GameInstance* Convert::gameInstance(gamepp_game_instance_handle_t handle) { | ||
return static_cast<GameInstance*>(handle); | ||
} |
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,6 @@ | ||
add_pretty_parser(gamepp C | ||
SOURCES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/gameppc/Convert.hpp" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/lang/c/include/gameppc/gamepp.h" | ||
"${CMAKE_CURRENT_LIST_DIR}/Convert.cpp" | ||
"${CMAKE_CURRENT_LIST_DIR}/gamepp.cpp") |
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,98 @@ | ||
#include <gameppc/gamepp.h> | ||
|
||
#include <gamepp/gamepp.h> | ||
|
||
#include <gameppc/Convert.hpp> | ||
#include <sourceppc/Convert.hpp> | ||
#include <sourceppc/Helpers.h> | ||
|
||
using namespace gamepp; | ||
|
||
SOURCEPP_API gamepp_game_instance_handle_t gamepp_find_game_instance() { | ||
auto instance = GameInstance::find(); | ||
if (!instance) { | ||
return nullptr; | ||
} | ||
return new GameInstance{*instance}; | ||
} | ||
|
||
SOURCEPP_API gamepp_game_instance_handle_t gamepp_find_game_instance_with_name(const char* windowNameOverride) { | ||
auto instance = GameInstance::find(windowNameOverride); | ||
if (!instance) { | ||
return nullptr; | ||
} | ||
return new GameInstance{*instance}; | ||
} | ||
|
||
SOURCEPP_API void gamepp_game_instance_free(gamepp_game_instance_handle_t* handle) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
delete Convert::gameInstance(*handle); | ||
*handle = nullptr; | ||
} | ||
|
||
SOURCEPP_API sourcepp_string_t gamepp_get_window_title(gamepp_game_instance_handle_t handle) { | ||
SOURCEPP_EARLY_RETURN_VAL(handle, SOURCEPP_STRING_INVALID); | ||
|
||
return Convert::toString(Convert::gameInstance(handle)->getWindowTitle()); | ||
} | ||
|
||
SOURCEPP_API int gamepp_get_window_pos_x(gamepp_game_instance_handle_t handle) { | ||
SOURCEPP_EARLY_RETURN_VAL(handle, 0); | ||
|
||
return Convert::gameInstance(handle)->getWindowPos()[0]; | ||
} | ||
|
||
SOURCEPP_API int gamepp_get_window_pos_y(gamepp_game_instance_handle_t handle) { | ||
SOURCEPP_EARLY_RETURN_VAL(handle, 0); | ||
|
||
return Convert::gameInstance(handle)->getWindowPos()[1]; | ||
} | ||
|
||
SOURCEPP_API int gamepp_get_window_width(gamepp_game_instance_handle_t handle) { | ||
SOURCEPP_EARLY_RETURN_VAL(handle, 0); | ||
|
||
return Convert::gameInstance(handle)->getWindowSize()[0]; | ||
} | ||
|
||
SOURCEPP_API int gamepp_get_window_height(gamepp_game_instance_handle_t handle) { | ||
SOURCEPP_EARLY_RETURN_VAL(handle, 0); | ||
|
||
return Convert::gameInstance(handle)->getWindowSize()[1]; | ||
} | ||
|
||
SOURCEPP_API void gamepp_command(gamepp_game_instance_handle_t handle, const char* command) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->command(command); | ||
} | ||
|
||
SOURCEPP_API void gamepp_input_begin(gamepp_game_instance_handle_t handle, const char* input) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->inputBegin(input); | ||
} | ||
|
||
SOURCEPP_API void gamepp_input_end(gamepp_game_instance_handle_t handle, const char* input) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->inputEnd(input); | ||
} | ||
|
||
SOURCEPP_API void gamepp_input_once(gamepp_game_instance_handle_t handle, const char* input) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->inputOnce(input); | ||
} | ||
|
||
SOURCEPP_API void gamepp_input_hold(gamepp_game_instance_handle_t handle, const char* input, double sec) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->inputHold(input, sec); | ||
} | ||
|
||
SOURCEPP_API void gamepp_wait(gamepp_game_instance_handle_t handle, double sec) { | ||
SOURCEPP_EARLY_RETURN(handle); | ||
|
||
Convert::gameInstance(handle)->wait(sec); | ||
} |